diff --git a/Image_Viewer/.gitignore b/Image_Viewer/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/Image_Viewer/.gitignore @@ -0,0 +1,13 @@ +*.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 diff --git a/Image_Viewer/.idea/codeStyles/Project.xml b/Image_Viewer/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..1bec35e --- /dev/null +++ b/Image_Viewer/.idea/codeStyles/Project.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/Image_Viewer/.idea/codeStyles/codeStyleConfig.xml b/Image_Viewer/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/Image_Viewer/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/Image_Viewer/.idea/encodings.xml b/Image_Viewer/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/Image_Viewer/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Image_Viewer/.idea/gradle.xml b/Image_Viewer/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/Image_Viewer/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/Image_Viewer/.idea/misc.xml b/Image_Viewer/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/Image_Viewer/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Image_Viewer/.idea/runConfigurations.xml b/Image_Viewer/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/Image_Viewer/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Image_Viewer/.idea/vcs.xml b/Image_Viewer/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Image_Viewer/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Image_Viewer/app/.gitignore b/Image_Viewer/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/Image_Viewer/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/Image_Viewer/app/build.gradle b/Image_Viewer/app/build.gradle new file mode 100644 index 0000000..f873586 --- /dev/null +++ b/Image_Viewer/app/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.1" + defaultConfig { + applicationId "com.example.image_viewer" + minSdkVersion 21 + 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"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.core:core-ktx:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} diff --git a/Image_Viewer/app/proguard-rules.pro b/Image_Viewer/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/Image_Viewer/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/Image_Viewer/app/src/androidTest/java/com/example/image_viewer/ExampleInstrumentedTest.kt b/Image_Viewer/app/src/androidTest/java/com/example/image_viewer/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..d651547 --- /dev/null +++ b/Image_Viewer/app/src/androidTest/java/com/example/image_viewer/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.image_viewer + +import androidx.test.InstrumentationRegistry +import androidx.test.runner.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.getTargetContext() + assertEquals("com.example.image_viewer", appContext.packageName) + } +} diff --git a/Image_Viewer/app/src/main/AndroidManifest.xml b/Image_Viewer/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f98ff6f --- /dev/null +++ b/Image_Viewer/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Image_Viewer/app/src/main/java/com/example/image_viewer/MainActivity.kt b/Image_Viewer/app/src/main/java/com/example/image_viewer/MainActivity.kt new file mode 100644 index 0000000..8f29964 --- /dev/null +++ b/Image_Viewer/app/src/main/java/com/example/image_viewer/MainActivity.kt @@ -0,0 +1,85 @@ +package com.example.image_viewer + +import android.app.Activity +import android.content.Intent +import android.media.Image +import android.net.Uri +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.ScrollView +import android.widget.TextView +import kotlinx.android.synthetic.main.activity_main.* +import java.io.Serializable + +class MainActivity : AppCompatActivity() { + + companion object { + const val IMAGE_REQUEST_CODE = 1 + val imageUri = null + val imageList = mutableListOf() + val ImageData = null + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + //do this 10 times with a for loop + image_scroll_linear.addView(createTextView("", 1)) + + button_add_image.setOnClickListener { + val intent = Intent(Intent.ACTION_GET_CONTENT) + intent.type = "image/*" + if (intent.resolveActivity(packageManager) != null) { + startActivityForResult(intent, IMAGE_REQUEST_CODE) + } + } + + } + + fun createTextView(name: String, listPositionIndex: Int): TextView { + val textview = TextView(this) + + textview.text = name + textview.id = listPositionIndex + + return textview + + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + + if(requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK) { + ImageData(imageUri = imageUri) + + + imageList.add(ImageData()) + image_scroll_linear.addView(createTextView("", 1)) + + } + + + + super.onActivityResult(requestCode, resultCode, data) + } +} + +class ImageData(imageUri: Uri) : Serializable { + + private val imageUri: Uri? = null + private var stringUri: String = "" + + fun setName(){ + val path = stringUri.split("/".toRegex()).dropLastWhile{ it.isEmpty() }.toTypedArray() + val name = path[path.size-1] + } + + fun setUri(imageUri: Uri) { + stringUri = imageUri.toString() + } + + fun getUri():Uri { + return Uri.parse(stringUri) + } + + +} \ No newline at end of file diff --git a/Image_Viewer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Image_Viewer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/Image_Viewer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/Image_Viewer/app/src/main/res/drawable/ic_launcher_background.xml b/Image_Viewer/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..a0ad202 --- /dev/null +++ b/Image_Viewer/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Image_Viewer/app/src/main/res/layout/activity_main.xml b/Image_Viewer/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..dcdf531 --- /dev/null +++ b/Image_Viewer/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + +