nextNoteVault #23
							
								
								
									
										6
									
								
								.idea/AndroidProjectSystem.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/AndroidProjectSystem.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="AndroidProjectSystem">
 | 
			
		||||
    <option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
							
								
								
									
										47
									
								
								.idea/inspectionProfiles/Project_Default.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								.idea/inspectionProfiles/Project_Default.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
			
		||||
<component name="InspectionProjectProfileManager">
 | 
			
		||||
  <profile version="1.0">
 | 
			
		||||
    <option name="myName" value="Project Default" />
 | 
			
		||||
    <inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
    <inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
 | 
			
		||||
      <option name="composableFile" value="true" />
 | 
			
		||||
    </inspection_tool>
 | 
			
		||||
  </profile>
 | 
			
		||||
</component>
 | 
			
		||||
@ -1,4 +1,3 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="ExternalStorageConfigurationManager" enabled="true" />
 | 
			
		||||
  <component name="FrameworkDetectionExcludesConfiguration">
 | 
			
		||||
 | 
			
		||||
@ -3,9 +3,14 @@
 | 
			
		||||
  <component name="RunConfigurationProducerService">
 | 
			
		||||
    <option name="ignoredProducers">
 | 
			
		||||
      <set>
 | 
			
		||||
        <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
 | 
			
		||||
        <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
 | 
			
		||||
        <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
 | 
			
		||||
        <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
 | 
			
		||||
        <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
 | 
			
		||||
        <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
 | 
			
		||||
        <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
 | 
			
		||||
        <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
 | 
			
		||||
      </set>
 | 
			
		||||
    </option>
 | 
			
		||||
  </component>
 | 
			
		||||
 | 
			
		||||
@ -55,4 +55,5 @@ dependencies {
 | 
			
		||||
    androidTestImplementation(libs.androidx.ui.test.junit4)
 | 
			
		||||
    debugImplementation(libs.androidx.ui.tooling)
 | 
			
		||||
    debugImplementation(libs.androidx.ui.test.manifest)
 | 
			
		||||
    implementation(libs.androidx.foundation)
 | 
			
		||||
}
 | 
			
		||||
@ -23,6 +23,8 @@
 | 
			
		||||
                <category android:name="android.intent.category.LAUNCHER"/>
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
        </activity>
 | 
			
		||||
        <activity android:name=".FullscreenImageViewerActivity" />
 | 
			
		||||
 | 
			
		||||
    </application>
 | 
			
		||||
 | 
			
		||||
</manifest>
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
package come.stormborntales.notevault
 | 
			
		||||
 | 
			
		||||
import android.net.Uri
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
import androidx.activity.ComponentActivity
 | 
			
		||||
import androidx.activity.compose.setContent
 | 
			
		||||
import come.stormborntales.notevault.ui.screens.FullscreenImageViewer
 | 
			
		||||
import come.stormborntales.notevault.ui.theme.NoteVaultTheme
 | 
			
		||||
 | 
			
		||||
// FullscreenImageViewerActivity.kt
 | 
			
		||||
class FullscreenImageViewerActivity : ComponentActivity() {
 | 
			
		||||
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
			
		||||
        super.onCreate(savedInstanceState)
 | 
			
		||||
 | 
			
		||||
        val imageUris = intent.getParcelableArrayListExtra<Uri>("imageUris") ?: emptyList()
 | 
			
		||||
 | 
			
		||||
        setContent {
 | 
			
		||||
            NoteVaultTheme {
 | 
			
		||||
                FullscreenImageViewer(
 | 
			
		||||
                    images = imageUris,
 | 
			
		||||
                    onClose = { finish() }
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,58 @@
 | 
			
		||||
package come.stormborntales.notevault.ui.screens
 | 
			
		||||
import androidx.compose.foundation.Image
 | 
			
		||||
import androidx.compose.foundation.background
 | 
			
		||||
import androidx.compose.foundation.layout.*
 | 
			
		||||
import androidx.compose.foundation.pager.HorizontalPager
 | 
			
		||||
import androidx.compose.foundation.pager.rememberPagerState
 | 
			
		||||
import androidx.compose.material.icons.Icons
 | 
			
		||||
import androidx.compose.material.icons.filled.ArrowBack
 | 
			
		||||
import androidx.compose.material3.*
 | 
			
		||||
import androidx.compose.runtime.*
 | 
			
		||||
import androidx.compose.ui.Alignment
 | 
			
		||||
import androidx.compose.ui.Modifier
 | 
			
		||||
import androidx.compose.ui.graphics.Color
 | 
			
		||||
import androidx.compose.ui.platform.LocalContext
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import android.net.Uri
 | 
			
		||||
import androidx.compose.foundation.ExperimentalFoundationApi
 | 
			
		||||
import androidx.compose.material.icons.filled.Close
 | 
			
		||||
import androidx.compose.ui.layout.ContentScale
 | 
			
		||||
import kotlinx.coroutines.launch
 | 
			
		||||
 | 
			
		||||
@OptIn(ExperimentalFoundationApi::class)
 | 
			
		||||
@Composable
 | 
			
		||||
fun FullscreenImageViewer(
 | 
			
		||||
    images: List<Uri>,
 | 
			
		||||
    onClose: () -> Unit
 | 
			
		||||
) {
 | 
			
		||||
    val pagerState = rememberPagerState(pageCount = { images.size })
 | 
			
		||||
 | 
			
		||||
    Box(modifier = Modifier.fillMaxSize()) {
 | 
			
		||||
        HorizontalPager(state = pagerState) { page ->
 | 
			
		||||
            val context = LocalContext.current
 | 
			
		||||
            val imageBitmap = remember(images[page]) {
 | 
			
		||||
                loadImageBitmap(context, images[page])
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            imageBitmap?.let {
 | 
			
		||||
                Image(
 | 
			
		||||
                    bitmap = it,
 | 
			
		||||
                    contentDescription = "Notenbild",
 | 
			
		||||
                    modifier = Modifier
 | 
			
		||||
                        .fillMaxSize()
 | 
			
		||||
                        .background(Color.Black),
 | 
			
		||||
                    contentScale = ContentScale.Fit
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        IconButton(
 | 
			
		||||
            onClick = onClose,
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .align(Alignment.TopStart)
 | 
			
		||||
                .padding(16.dp)
 | 
			
		||||
        ) {
 | 
			
		||||
            Icon(Icons.Default.Close, contentDescription = "Schließen", tint = Color.White)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package come.stormborntales.notevault.ui.screens
 | 
			
		||||
 | 
			
		||||
import android.content.Context
 | 
			
		||||
import android.content.Intent
 | 
			
		||||
import android.graphics.BitmapFactory
 | 
			
		||||
import android.graphics.ImageDecoder
 | 
			
		||||
import android.media.Image
 | 
			
		||||
@ -21,6 +22,7 @@ import androidx.compose.ui.graphics.ImageBitmap
 | 
			
		||||
import androidx.compose.ui.graphics.asImageBitmap
 | 
			
		||||
import androidx.compose.ui.platform.LocalContext
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import come.stormborntales.notevault.FullscreenImageViewerActivity
 | 
			
		||||
import come.stormborntales.notevault.data.model.NoteEntry
 | 
			
		||||
import java.io.InputStream
 | 
			
		||||
 | 
			
		||||
@ -35,17 +37,6 @@ fun loadImageBitmap(context: Context, uri: Uri): ImageBitmap? {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fun getFileNameFromUri(context: Context, uri: Uri): String? {
 | 
			
		||||
    val cursor = context.contentResolver.query(uri, null, null, null, null)
 | 
			
		||||
    cursor?.use {
 | 
			
		||||
        val nameIndex = it.getColumnIndex(android.provider.OpenableColumns.DISPLAY_NAME)
 | 
			
		||||
        if (it.moveToFirst() && nameIndex >= 0) {
 | 
			
		||||
            return it.getString(nameIndex)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return null
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
fun NoteCard(note: NoteEntry) {
 | 
			
		||||
    val context = LocalContext.current
 | 
			
		||||
@ -108,7 +99,12 @@ fun NoteCard(note: NoteEntry) {
 | 
			
		||||
                    horizontalArrangement = Arrangement.spacedBy(8.dp)
 | 
			
		||||
                ) {
 | 
			
		||||
                    OutlinedButton(
 | 
			
		||||
                        onClick = { /* TODO */ },
 | 
			
		||||
                        onClick = {
 | 
			
		||||
                            val intent = Intent(context, FullscreenImageViewerActivity::class.java).apply {
 | 
			
		||||
                                putParcelableArrayListExtra("imageUris", ArrayList(note.images))
 | 
			
		||||
                            }
 | 
			
		||||
                            context.startActivity(intent)
 | 
			
		||||
                        },
 | 
			
		||||
                        contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
 | 
			
		||||
                    ) {
 | 
			
		||||
                        Text("Anzeigen", style = MaterialTheme.typography.labelLarge)
 | 
			
		||||
@ -142,6 +138,7 @@ fun MainScreen(
 | 
			
		||||
    notes: MutableList<NoteEntry>, // Liste der Notenbilder (hier als URI),
 | 
			
		||||
) {
 | 
			
		||||
    val dummyNotes = notes
 | 
			
		||||
    var noteToShow by remember { mutableStateOf<NoteEntry?>(null) }
 | 
			
		||||
    // Hole den aktuellen Context
 | 
			
		||||
    val context = LocalContext.current
 | 
			
		||||
    Scaffold(
 | 
			
		||||
@ -170,9 +167,4 @@ fun MainScreen(
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
[versions]
 | 
			
		||||
agp = "8.8.0-alpha05"
 | 
			
		||||
agp = "8.8.2"
 | 
			
		||||
composeBomVersion = "2024.01.00"
 | 
			
		||||
kotlin = "2.0.0"
 | 
			
		||||
coreKtx = "1.10.1"
 | 
			
		||||
junit = "4.13.2"
 | 
			
		||||
@ -11,7 +12,9 @@ composeBom = "2024.04.01"
 | 
			
		||||
navigationCompose = "2.8.9"
 | 
			
		||||
 | 
			
		||||
[libraries]
 | 
			
		||||
androidx-compose-bom-v20240100 = { module = "androidx.compose:compose-bom", version.ref = "composeBomVersion" }
 | 
			
		||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
 | 
			
		||||
androidx-foundation = { module = "androidx.compose.foundation:foundation" }
 | 
			
		||||
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
 | 
			
		||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
 | 
			
		||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user