Skip to content

Commit

Permalink
Merge pull request #24 from SSUMC-6th/kara/#23
Browse files Browse the repository at this point in the history
[kara/#23] feat :: 5주차 구현 완료
  • Loading branch information
hyowon0204 authored May 14, 2024
2 parents 80f9ffc + d6b30c6 commit c5c774d
Show file tree
Hide file tree
Showing 59 changed files with 1,263 additions and 40 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

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

1 change: 1 addition & 0 deletions .idea/vcs.xml

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

15 changes: 15 additions & 0 deletions NotePad2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions NotePad2/.idea/.gitignore

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

1 change: 1 addition & 0 deletions NotePad2/.idea/.name

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

6 changes: 6 additions & 0 deletions NotePad2/.idea/compiler.xml

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

10 changes: 10 additions & 0 deletions NotePad2/.idea/deploymentTargetDropDown.xml

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

19 changes: 19 additions & 0 deletions NotePad2/.idea/gradle.xml

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

6 changes: 6 additions & 0 deletions NotePad2/.idea/kotlinc.xml

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

10 changes: 10 additions & 0 deletions NotePad2/.idea/migrations.xml

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

10 changes: 10 additions & 0 deletions NotePad2/.idea/misc.xml

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

1 change: 1 addition & 0 deletions NotePad2/Android_A
Submodule Android_A added at 9b0e4d
1 change: 1 addition & 0 deletions NotePad2/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
58 changes: 58 additions & 0 deletions NotePad2/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
}

android {
namespace = "com.example.notepad"
compileSdk = 34

defaultConfig {
applicationId = "com.example.notepad"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = 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"
}
android {
buildFeatures {
dataBinding = true // 데이터 바인딩
}

buildFeatures {
viewBinding = true // 뷰 바인딩
}
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

}
21 changes: 21 additions & 0 deletions NotePad2/app/proguard-rules.pro
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.notepad

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.notepad", appContext.packageName)
}
}
35 changes: 35 additions & 0 deletions NotePad2/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.NotePad"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MemoActivity"
android:exported="true">
</activity>
<activity
android:name=".MemoCheckActivity"
android:exported="true">
</activity>

</application>

</manifest>
56 changes: 56 additions & 0 deletions NotePad2/app/src/main/java/com/example/notepad/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.notepad

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.Button
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.example.notepad.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

lateinit var binding : ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

}

override fun onStart() {
super.onStart()
binding.button.setOnClickListener {
val intent = Intent(this, MemoActivity::class.java)
val sharedPreferences = this.getSharedPreferences("memo", AppCompatActivity.MODE_PRIVATE)
val tempMemo = sharedPreferences.getString("tempMemo", null)

if(tempMemo != null) {
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog, null)
val builder = AlertDialog.Builder(this)
.setView(dialogView)
.setTitle("메모 복원하기")

val alertDialog = builder.show()
val yesBtn = alertDialog.findViewById<Button>(R.id.yes)
val noBtn = alertDialog.findViewById<Button>(R.id.no)

yesBtn!!.setOnClickListener {
startActivity(intent)
}

noBtn!!.setOnClickListener {
val editor = sharedPreferences.edit()
editor.remove("tempMemo")
editor.apply()
startActivity(intent)
}

} else {
startActivity(intent)
}
}
}

}
44 changes: 44 additions & 0 deletions NotePad2/app/src/main/java/com/example/notepad/MemoActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.example.notepad

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.notepad.databinding.ActivityMemoBinding

class MemoActivity : AppCompatActivity() {

lateinit var binding : ActivityMemoBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMemoBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.nextBtn.setOnClickListener {
val intent = Intent(this, MemoCheckActivity::class.java)
val memoTxt = binding.memoEt.text.toString()
intent.putExtra("memo", memoTxt)
startActivity(intent)
}
}
override fun onPause() {
super.onPause()
val sharedPreferences = getSharedPreferences("memo", MODE_PRIVATE)
val editor = sharedPreferences.edit()
val tempMemo = binding.memoEt.text.toString()

if(tempMemo.isNotEmpty()) {
editor.putString("tempMemo", tempMemo)
editor.apply()
}
}
override fun onResume() {
super.onResume()
val sharedPreferences = getSharedPreferences("memo", MODE_PRIVATE)
val tempMemo = sharedPreferences.getString("tempMemo", null)

if(tempMemo != null) {
binding.memoEt.setText(tempMemo)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.notepad

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.notepad.databinding.ActivityMemocheckBinding

class MemoCheckActivity : AppCompatActivity() {

lateinit var binding : ActivityMemocheckBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityMemocheckBinding.inflate(layoutInflater)
setContentView(binding.root)

if(intent.hasExtra("memo")) {
binding.memoCheckText.text = intent.getStringExtra("memo")!!
}
}
}
Loading

0 comments on commit c5c774d

Please sign in to comment.