Skip to content

Team ForeLook submit #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

buildFeatures{
viewBinding true
}

defaultConfig {
applicationId "com.example.aipd"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
//implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0' //1.3.0
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//testImplementation 'junit:junit:4.13.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' //1.1.2
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' //3.3.0
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.aipd

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.aipd", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aipd">

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



<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AIPD">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RecordingActivity" />
<activity android:name=".ShowResultActivity" />
<activity android:name=".ProfileActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.example.aipd

import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log.d
import android.view.View
import android.widget.Button
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.core.widget.addTextChangedListener
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar

class MainActivity : AppCompatActivity() {



override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)


val usrName = findViewById<EditText>(R.id.userName)
val passWord = findViewById<EditText>(R.id.password)
val signInButton = findViewById<Button>(R.id.signIn)
val registerButton = findViewById<Button>(R.id.register)

// enabled btn
val inputTexts = listOf(usrName, passWord)
for (editText in inputTexts){
editText.addTextChangedListener(object : TextWatcher{
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
var et1 = usrName.text.toString().trim()
var et2 = passWord.text.toString().trim()

signInButton.isEnabled = et1.isNotEmpty() && et2.isNotEmpty()
registerButton.isEnabled = et1.isNotEmpty() && et2.isNotEmpty()
}
override fun beforeTextChanged(
s: CharSequence, start: Int, count: Int, after: Int) {
}

override fun afterTextChanged(
s: Editable) {
}
})
}



registerButton.setOnClickListener {
val name = usrName.text.toString()
val psswd = passWord.text.toString()
d("Amy","Name: $name")
d("Amy","Psswd: $psswd")

val database = getSharedPreferences("database", Context.MODE_PRIVATE)
database.edit().apply{
putString( name, psswd)
}.apply()

val errorBuilder= AlertDialog.Builder(this)
.setTitle("Message")
.setMessage("Register Successfully! ")
.setPositiveButton("OK"
) { dialog, which ->
//do nothing
}
.show()
}

signInButton.setOnClickListener {
val name = usrName.text.toString()
val psswd = passWord.text.toString()
d("Amy","Name: $name")
d("Amy","Psswd: $psswd")
val preferences = getSharedPreferences("database",Context.MODE_PRIVATE)
val databasePsswd = preferences.getString( name, "Doesn't exist.")
d("Amy", "saved password is : $databasePsswd")
if(databasePsswd == psswd){

val database = getSharedPreferences("usrName", Context.MODE_PRIVATE)
database.edit().apply{
putString( "User", name)
}.apply()

startActivity(Intent(this, RecordingActivity::class.java))
}
else if(databasePsswd == "Doesn't exist."){
val errorBuilder= AlertDialog.Builder(this)
.setTitle("Invalid Account")
.setMessage("Your account doesn't exist. Register now!")
.setPositiveButton("Reister Now"
) { dialog, which ->
//store user info
val database = getSharedPreferences("database", Context.MODE_PRIVATE)
database.edit().apply{
putString( name, psswd)
}.apply()

//log in
val database2 = getSharedPreferences("usrName", Context.MODE_PRIVATE)
database2.edit().apply{
putString( "User", name)
}.apply()
startActivity(Intent(this, RecordingActivity::class.java))
}

.setNegativeButton("Cancel"
) { dialog, which ->
}
.show()
}

else{
d("Amy","wrong psswd")

val errorBuilder= AlertDialog.Builder(this)
.setTitle("Wrong Password")
.setMessage("Your password is wrong. Try again!")
.setPositiveButton("OK"
) { dialog, which ->
//do nothing
}
.show()
}


}
}







}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.example.aipd

import android.content.Context
import android.content.Intent
import android.graphics.drawable.TransitionDrawable
import android.os.Bundle
import android.view.animation.AnimationUtils
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class ProfileActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?){
super.onCreate(savedInstanceState)
setContentView(R.layout.profile)


val mainMenuButton = findViewById<Button>(R.id.mainMenu)
val logOutButton = findViewById<Button>(R.id.logOut)

val preferences = getSharedPreferences("usrName", Context.MODE_PRIVATE)
val user = preferences.getString( "User", "Doesn't exist.")
val profileText = findViewById<TextView>(R.id.profileText)

profileText.text = user

mainMenuButton.setOnClickListener {
startActivity(Intent(this, RecordingActivity::class.java))
}

logOutButton.setOnClickListener {
startActivity(Intent(this, MainActivity::class.java))
}


// test
// val roun dButton = findViewById<Button>(R.id.tester)
// roundButton.getba
// val transitiondrawable = TransitionDrawable.


val rtl = AnimationUtils.loadAnimation(this, R.anim.ltr);
val shoe = findViewById<ImageView>(R.id.shoe)

shoe.startAnimation(rtl)

}






}
Loading