diff --git a/ImageViewer/.gitignore b/ImageViewer/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/ImageViewer/.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/ImageViewer/.idea/codeStyles/Project.xml b/ImageViewer/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..1bec35e --- /dev/null +++ b/ImageViewer/.idea/codeStyles/Project.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/ImageViewer/.idea/codeStyles/codeStyleConfig.xml b/ImageViewer/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/ImageViewer/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/ImageViewer/.idea/encodings.xml b/ImageViewer/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/ImageViewer/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ImageViewer/.idea/gradle.xml b/ImageViewer/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/ImageViewer/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/ImageViewer/.idea/misc.xml b/ImageViewer/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/ImageViewer/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/ImageViewer/.idea/runConfigurations.xml b/ImageViewer/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/ImageViewer/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/ImageViewer/.idea/vcs.xml b/ImageViewer/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/ImageViewer/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ImageViewer/ImageViewer.iml b/ImageViewer/ImageViewer.iml new file mode 100644 index 0000000..a446000 --- /dev/null +++ b/ImageViewer/ImageViewer.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ImageViewer/app/.gitignore b/ImageViewer/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/ImageViewer/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/ImageViewer/app/app.iml b/ImageViewer/app/app.iml new file mode 100644 index 0000000..7fa8fa6 --- /dev/null +++ b/ImageViewer/app/app.iml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ImageViewer/app/build.gradle b/ImageViewer/app/build.gradle new file mode 100644 index 0000000..692f5b6 --- /dev/null +++ b/ImageViewer/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + defaultConfig { + applicationId "com.example.imageviewer" + 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/ImageViewer/app/build/generated/source/buildConfig/debug/com/example/imageviewer/BuildConfig.java b/ImageViewer/app/build/generated/source/buildConfig/debug/com/example/imageviewer/BuildConfig.java new file mode 100644 index 0000000..a6eee2a --- /dev/null +++ b/ImageViewer/app/build/generated/source/buildConfig/debug/com/example/imageviewer/BuildConfig.java @@ -0,0 +1,13 @@ +/** + * Automatically generated file. DO NOT MODIFY + */ +package com.example.imageviewer; + +public final class BuildConfig { + public static final boolean DEBUG = Boolean.parseBoolean("true"); + public static final String APPLICATION_ID = "com.example.imageviewer"; + public static final String BUILD_TYPE = "debug"; + public static final String FLAVOR = ""; + public static final int VERSION_CODE = 1; + public static final String VERSION_NAME = "1.0"; +} diff --git a/ImageViewer/app/proguard-rules.pro b/ImageViewer/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/ImageViewer/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/ImageViewer/app/src/androidTest/java/com/example/imageviewer/ExampleInstrumentedTest.kt b/ImageViewer/app/src/androidTest/java/com/example/imageviewer/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..f95a8dc --- /dev/null +++ b/ImageViewer/app/src/androidTest/java/com/example/imageviewer/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.imageviewer + +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.imageviewer", appContext.packageName) + } +} diff --git a/ImageViewer/app/src/main/AndroidManifest.xml b/ImageViewer/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fe60184 --- /dev/null +++ b/ImageViewer/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ImageViewer/app/src/main/java/com/example/imageviewer/DetailsActivity.kt b/ImageViewer/app/src/main/java/com/example/imageviewer/DetailsActivity.kt new file mode 100644 index 0000000..00ddef2 --- /dev/null +++ b/ImageViewer/app/src/main/java/com/example/imageviewer/DetailsActivity.kt @@ -0,0 +1,31 @@ +package com.example.imageviewer + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.provider.ContactsContract +import android.provider.MediaStore +import androidx.core.net.toUri +import kotlinx.android.synthetic.main.activity_details.* + +class DetailsActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_details) + + val stringData: String = intent.getStringExtra(MainActivity.STRING_REQUEST_CODE) ?: "No Data" + text_view.text = stringData + text_view.textSize = 16f + + image_view.setImageURI(stringData.toUri()) + // this stuff below is the hard way to set an image haha + //val bitmap = MediaStore.Images.Media.getBitmap(this.contentResolver, stringData.toUri()) + //image_view.setImageBitmap(bitmap) + + //var myObject = intent.getSerializableExtra(MainActivity.STRING_REQUEST_CODE) as ImageData + + image_view.setOnClickListener { + + } + } +} diff --git a/ImageViewer/app/src/main/java/com/example/imageviewer/ImageData.kt b/ImageViewer/app/src/main/java/com/example/imageviewer/ImageData.kt new file mode 100644 index 0000000..8bb51e1 --- /dev/null +++ b/ImageViewer/app/src/main/java/com/example/imageviewer/ImageData.kt @@ -0,0 +1,13 @@ +package com.example.imageviewer + +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.net.Uri +import android.os.ParcelFileDescriptor +import androidx.core.net.toUri +import java.io.FileDescriptor +import java.io.Serializable + +class ImageData(imageUri : Uri) : Serializable { + var imageUri = imageUri.toString() +} \ No newline at end of file diff --git a/ImageViewer/app/src/main/java/com/example/imageviewer/MainActivity.kt b/ImageViewer/app/src/main/java/com/example/imageviewer/MainActivity.kt new file mode 100644 index 0000000..0f63fea --- /dev/null +++ b/ImageViewer/app/src/main/java/com/example/imageviewer/MainActivity.kt @@ -0,0 +1,75 @@ +package com.example.imageviewer + +import android.app.Activity +import android.content.Intent +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import kotlinx.android.synthetic.main.activity_main.* +import android.provider.MediaStore +import android.view.ViewGroup.LayoutParams.MATCH_PARENT +import android.view.ViewGroup.LayoutParams.WRAP_CONTENT +import android.widget.FrameLayout +import java.io.Serializable + + +class MainActivity : AppCompatActivity() { + // This array is needed to help create the UI of Images and data + private var imageAndDataList: ArrayList = ArrayList() + var imageDataIndex = 0 + var buttonIndex = 0 + + companion object{ + val IMAGE_REQUEST_CODE = 3 + val STRING_REQUEST_CODE = "REQUEST_CODE" + } + + + private fun addTextToList(text: String, listIndex: Int): TextView { + val aTextView = TextView(this) + aTextView.width = MATCH_PARENT + aTextView.height = 100 + aTextView.text = text + aTextView.textSize = 16f + + aTextView.setOnClickListener { + val intent = Intent(this, DetailsActivity::class.java) + intent.putExtra(STRING_REQUEST_CODE, imageAndDataList[imageDataIndex-1].imageUri) + startActivity(intent) + } + return aTextView + } + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + //This button is set to make it possible for user to retrieve image from system + add_image_button.setOnClickListener { + val intent = Intent(Intent.ACTION_GET_CONTENT) + intent.type = "image/*" + if(intent.resolveActivity(packageManager) != null){ + startActivityForResult(intent, IMAGE_REQUEST_CODE) + } + } + } + + /*This particular lifecycle OnActivityResult takes place when the user has either retrieved + *data or canceled that process. The process is initiated through startActivityForResult() + */ + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if(requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK){ + val imageInformation = data?.data + if(imageInformation != null) { + scroll_list.addView(addTextToList(ImageData(imageInformation).imageUri, buttonIndex++)) + imageAndDataList.add(imageDataIndex++, ImageData(imageInformation)) + } + } + super.onActivityResult(requestCode, resultCode, data) + } +} diff --git a/ImageViewer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ImageViewer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/ImageViewer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/ImageViewer/app/src/main/res/drawable/ic_launcher_background.xml b/ImageViewer/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..a0ad202 --- /dev/null +++ b/ImageViewer/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ImageViewer/app/src/main/res/layout/activity_details.xml b/ImageViewer/app/src/main/res/layout/activity_details.xml new file mode 100644 index 0000000..beb55ff --- /dev/null +++ b/ImageViewer/app/src/main/res/layout/activity_details.xml @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/ImageViewer/app/src/main/res/layout/activity_main.xml b/ImageViewer/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..fb06770 --- /dev/null +++ b/ImageViewer/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + +