commit f36506d92e5debdcacf8b83ff6428595ecaec9c1 Author: Marcin Wozniak Date: Tue Oct 15 13:33:13 2019 +0200 First Update diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.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 diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..b3405b3 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +My Application \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..d291b3d --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..dfd2c79 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..75a4212 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + defaultConfig { + applicationId "com.zadanie1.mw" + minSdkVersion 28 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -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 diff --git a/app/src/androidTest/java/com/zadanie1/mw/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/zadanie1/mw/ExampleInstrumentedTest.java new file mode 100644 index 0000000..aaa54e6 --- /dev/null +++ b/app/src/androidTest/java/com/zadanie1/mw/ExampleInstrumentedTest.java @@ -0,0 +1,28 @@ +package com.zadanie1.mw; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + assertEquals("com.zadanie1.mw", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c20e00e --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/zadanie1/mw/FormPassword.java b/app/src/main/java/com/zadanie1/mw/FormPassword.java new file mode 100644 index 0000000..401c8ee --- /dev/null +++ b/app/src/main/java/com/zadanie1/mw/FormPassword.java @@ -0,0 +1,17 @@ +package com.zadanie1.mw; + +import android.os.Bundle; +import android.app.Activity; + +public class FormPassword extends Activity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_form_password); + + + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/zadanie1/mw/MainActivity.java b/app/src/main/java/com/zadanie1/mw/MainActivity.java new file mode 100644 index 0000000..6a0e18d --- /dev/null +++ b/app/src/main/java/com/zadanie1/mw/MainActivity.java @@ -0,0 +1,57 @@ +package com.zadanie1.mw; +import androidx.appcompat.app.AppCompatActivity; + +import android.Manifest; +import android.content.Intent; +import android.os.Bundle; +import android.os.Environment; +import android.view.View; +import android.widget.Button; +import android.view.View.OnClickListener; +import android.widget.EditText; +import android.widget.TextView; + +import java.io.File; + +public class MainActivity extends AppCompatActivity { + + + TextView response; + Button button; + Button restartpassword; + private EditText textPassword; + private View viewPassword; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + response = (TextView) findViewById(R.id.textView); + button = (Button) findViewById(R.id.button); + restartpassword = (Button) findViewById(R.id.restartpassword); + textPassword = findViewById(R.id.editText); + + restartpassword.setOnClickListener(new OnClickListener() { + public void onClick(View arg0) { + Intent myIntent = new Intent(MainActivity.this, + FormPassword.class); + startActivity(myIntent); + finish(); + } + }); + + button.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + response.setText(textPassword.getText()); + if (textPassword.getText().toString().equals("123")) { + Intent myIntent2 = new Intent(MainActivity.this, + Noto.class); + startActivity(myIntent2); + finish(); + } + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/zadanie1/mw/Noto.java b/app/src/main/java/com/zadanie1/mw/Noto.java new file mode 100644 index 0000000..b747fe5 --- /dev/null +++ b/app/src/main/java/com/zadanie1/mw/Noto.java @@ -0,0 +1,88 @@ +package com.zadanie1.mw; + +import androidx.appcompat.app.AppCompatActivity; +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class Noto extends AppCompatActivity { + EditText ChangeNote; + Button SaveNote; + + private static final String FILE_NAME = "notes.txt"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_noto); + + ChangeNote = (EditText) findViewById(R.id.changeNote); + SaveNote = (Button) findViewById(R.id.SaveNote); + FileInputStream fis = null; + + try { + fis = openFileInput(FILE_NAME); + InputStreamReader isr = new InputStreamReader(fis); + BufferedReader br = new BufferedReader(isr); + StringBuffer sb = new StringBuffer(); + String text; + + while ((text = br.readLine()) != null) { + sb.append(text).append("\n"); + } + + if (sb.toString() != null) { + ChangeNote.setText(sb.toString()); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fis != null){ + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + public void save (View v) throws IOException { + + String text = ChangeNote.getText().toString(); + FileOutputStream fos = null; + + try { + fos = openFileOutput(FILE_NAME, MODE_PRIVATE); + fos.write(text.getBytes()); + + ChangeNote.getText().clear(); + Toast.makeText(this, "Saved to " + getFilesDir() + "/" + FILE_NAME, Toast.LENGTH_LONG).show(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fos != null){ + fos.close(); + } + } + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_form_password.xml b/app/src/main/res/layout/activity_form_password.xml new file mode 100644 index 0000000..0f885bb --- /dev/null +++ b/app/src/main/res/layout/activity_form_password.xml @@ -0,0 +1,38 @@ + + + + + + + + +