Skip to content

Commit 2bafc15

Browse files
committed
second finish
1 parent 9e0e97a commit 2bafc15

File tree

87 files changed

+2320
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2320
-0
lines changed

ToDoList/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

ToDoList/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDoList/.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDoList/.idea/gradle.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDoList/.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDoList/.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDoList/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDoList/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# AndroidToDoList
2+
안드로이드 스튜디오로 To Do List 만들기

ToDoList/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

ToDoList/app/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "30.0.2"
8+
9+
defaultConfig {
10+
applicationId "org.techtown.todolist"
11+
minSdkVersion 16
12+
targetSdkVersion 30
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
33+
implementation 'androidx.appcompat:appcompat:1.2.0'
34+
implementation 'com.google.android.material:material:1.2.1'
35+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
36+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
37+
testImplementation 'junit:junit:4.+'
38+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
39+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
40+
}

ToDoList/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.techtown.todolist;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("org.techtown.todolist", appContext.getPackageName());
25+
}
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.techtown.todolist">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.ToDoList">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package org.techtown.todolist;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
import androidx.fragment.app.Fragment;
5+
6+
import android.content.Context;
7+
import android.os.Bundle;
8+
import android.util.Log;
9+
import android.view.View;
10+
import android.widget.Button;
11+
import android.widget.EditText;
12+
import android.widget.Toast;
13+
14+
public class MainActivity extends AppCompatActivity {
15+
private static final String TAG = "MainActivity";
16+
17+
Fragment mainFragment;
18+
EditText inputToDo;
19+
Context context;
20+
21+
public static NoteDatabase noteDatabase = null;
22+
23+
@Override
24+
protected void onCreate(Bundle savedInstanceState) {
25+
super.onCreate(savedInstanceState);
26+
setContentView(R.layout.activity_main);
27+
28+
mainFragment = new MainFragment();
29+
30+
//getSupportFragmentManager 을 이용하여 이전에 만들었던 **FrameLayout**에 `fragment_main.xml`이 추가
31+
getSupportFragmentManager().beginTransaction().replace(R.id.container, mainFragment).commit();
32+
33+
Button saveButton = findViewById(R.id.saveButton);
34+
saveButton.setOnClickListener(new View.OnClickListener(){
35+
@Override
36+
public void onClick(View view){
37+
38+
saveToDo();
39+
40+
Toast.makeText(getApplicationContext(),"추가되었습니다.",Toast.LENGTH_SHORT).show();
41+
42+
}
43+
});
44+
openDatabase();
45+
}
46+
private void saveToDo(){
47+
inputToDo = findViewById(R.id.inputToDo);
48+
49+
//EditText에 적힌 글을 가져오기
50+
String todo = inputToDo.getText().toString();
51+
52+
//테이블에 값을 추가하는 sql구문 insert...
53+
String sqlSave = "insert into " + NoteDatabase.TABLE_NOTE + " (TODO) values (" +
54+
"'" + todo + "')";
55+
56+
//sql문 실행
57+
NoteDatabase database = NoteDatabase.getInstance(context);
58+
database.execSQL(sqlSave);
59+
60+
//저장과 동시에 EditText 안의 글 초기화
61+
inputToDo.setText("");
62+
}
63+
64+
65+
public void openDatabase() {
66+
// open database
67+
if (noteDatabase != null) {
68+
noteDatabase.close();
69+
noteDatabase = null;
70+
}
71+
72+
noteDatabase = NoteDatabase.getInstance(this);
73+
boolean isOpen = noteDatabase.open();
74+
if (isOpen) {
75+
Log.d(TAG, "Note database is open.");
76+
} else {
77+
Log.d(TAG, "Note database is not open.");
78+
}
79+
}
80+
@Override
81+
protected void onDestroy() {
82+
super.onDestroy();
83+
84+
if (noteDatabase != null) {
85+
noteDatabase.close();
86+
noteDatabase = null;
87+
}
88+
}
89+
90+
91+
}

0 commit comments

Comments
 (0)