Repository: TannerGabriel/Blog Branch: master Commit: dabc03ab4c75 Files: 291 Total size: 239.1 KB Directory structure: gitextract_vk9h6cdj/ ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ └── bug_report.md │ └── workflows/ │ ├── codeql-analysis.yml │ └── stale.yml ├── .gitignore ├── Camera/ │ ├── .gitignore │ ├── .idea/ │ │ ├── codeStyles/ │ │ │ ├── Project.xml │ │ │ └── codeStyleConfig.xml │ │ ├── encodings.xml │ │ ├── gradle.xml │ │ ├── misc.xml │ │ └── vcs.xml │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ ├── androidTest/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── videorecorder/ │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main/ │ │ │ ├── AndroidManifest.xml │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── example/ │ │ │ │ └── videorecorder/ │ │ │ │ └── MainActivity.kt │ │ │ └── res/ │ │ │ ├── drawable/ │ │ │ │ ├── ic_camera.xml │ │ │ │ ├── ic_flash.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── ic_switch_camera.xml │ │ │ ├── drawable-v24/ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout/ │ │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26/ │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ └── values/ │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── example/ │ │ └── videorecorder/ │ │ └── ExampleUnitTest.kt │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── CameraX/ │ ├── .gitignore │ ├── .idea/ │ │ ├── codeStyles/ │ │ │ ├── Project.xml │ │ │ └── codeStyleConfig.xml │ │ ├── encodings.xml │ │ ├── gradle.xml │ │ ├── misc.xml │ │ ├── runConfigurations.xml │ │ └── vcs.xml │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ ├── androidTest/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── camerax/ │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main/ │ │ │ ├── AndroidManifest.xml │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── example/ │ │ │ │ └── camerax/ │ │ │ │ └── MainActivity.kt │ │ │ └── res/ │ │ │ ├── drawable/ │ │ │ │ ├── ic_camera.xml │ │ │ │ ├── ic_flash.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── ic_switch_camera.xml │ │ │ ├── drawable-v24/ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout/ │ │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26/ │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ └── values/ │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── example/ │ │ └── camerax/ │ │ └── ExampleUnitTest.kt │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── LICENSE ├── Nest-CRUD/ │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── docker-compose.yaml │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── src/ │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── items/ │ │ │ ├── dto/ │ │ │ │ └── create-item.dto.ts │ │ │ ├── interfaces/ │ │ │ │ └── item.interface.ts │ │ │ ├── item.controller.spec.ts │ │ │ ├── items.controller.ts │ │ │ ├── items.module.ts │ │ │ ├── items.service.ts │ │ │ └── schemas/ │ │ │ └── item.schema.ts │ │ └── main.ts │ ├── test/ │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tslint.json ├── NestVueChat/ │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── src/ │ │ ├── app.gateway.ts │ │ ├── app.module.ts │ │ └── main.ts │ ├── static/ │ │ ├── index.html │ │ ├── main.js │ │ └── styles.css │ ├── test/ │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tslint.json ├── Notifications/ │ ├── .gitignore │ ├── .idea/ │ │ ├── codeStyles/ │ │ │ ├── Project.xml │ │ │ └── codeStyleConfig.xml │ │ ├── encodings.xml │ │ ├── gradle.xml │ │ ├── misc.xml │ │ ├── runConfigurations.xml │ │ └── vcs.xml │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ ├── androidTest/ │ │ │ └── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── notifications/ │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main/ │ │ │ ├── AndroidManifest.xml │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── example/ │ │ │ │ └── notifications/ │ │ │ │ └── MainActivity.kt │ │ │ └── res/ │ │ │ ├── drawable/ │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── notification_icon.xml │ │ │ ├── drawable-v24/ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout/ │ │ │ │ ├── activity_main.xml │ │ │ │ ├── custom_notification_expended_layout.xml │ │ │ │ └── custom_notification_layout.xml │ │ │ ├── mipmap-anydpi-v26/ │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ └── values/ │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test/ │ │ └── java/ │ │ └── com/ │ │ └── example/ │ │ └── notifications/ │ │ └── ExampleUnitTest.kt │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── README.md ├── nest-auth/ │ ├── .dockerignore │ ├── .gitignore │ ├── .prettierrc │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── src/ │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── auth/ │ │ │ ├── auth.controller.ts │ │ │ ├── auth.module.ts │ │ │ ├── auth.service.ts │ │ │ └── jwt.strategy.ts │ │ ├── main.ts │ │ ├── models/ │ │ │ └── user.schema.ts │ │ ├── types/ │ │ │ ├── payload.ts │ │ │ └── user.ts │ │ └── user/ │ │ ├── dto/ │ │ │ ├── create-user.dto.ts │ │ │ └── login-user.dto.ts │ │ ├── user.module.ts │ │ └── user.service.ts │ ├── test/ │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tslint.json ├── nest-file-uploading/ │ ├── .dockerignore │ ├── .gitignore │ ├── .prettierrc │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── src/ │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── main.ts │ │ └── utils/ │ │ └── file-upload.utils.ts │ ├── test/ │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tslint.json ├── nest-graph-ql/ │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── docker-compose.yaml │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── schema.gql │ ├── src/ │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── items/ │ │ │ ├── dto/ │ │ │ │ └── create-item.dto.ts │ │ │ ├── input-items.input.ts │ │ │ ├── interfaces/ │ │ │ │ └── item.interface.ts │ │ │ ├── item.schema.ts │ │ │ ├── items.module.ts │ │ │ ├── items.resolver.ts │ │ │ ├── items.service.spec.ts │ │ │ └── items.service.ts │ │ └── main.ts │ ├── test/ │ │ ├── items.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tslint.json ├── nestjs-typeorm/ │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── docker-compose.yaml │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── src/ │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── item/ │ │ │ ├── item.controller.ts │ │ │ ├── item.dto.ts │ │ │ ├── item.entity.ts │ │ │ ├── item.module.ts │ │ │ └── item.service.ts │ │ └── main.ts │ ├── test/ │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tslint.json ├── nuxt-ghost/ │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── assets/ │ │ └── README.md │ ├── components/ │ │ └── README.md │ ├── jsconfig.json │ ├── layouts/ │ │ ├── README.md │ │ └── default.vue │ ├── middleware/ │ │ └── README.md │ ├── nuxt.config.js │ ├── package.json │ ├── pages/ │ │ ├── README.md │ │ └── index.vue │ ├── plugins/ │ │ └── README.md │ ├── static/ │ │ └── README.md │ ├── store/ │ │ └── README.md │ └── utils/ │ └── ghost.js ├── nuxt-supabase-auth/ │ ├── .editorconfig │ ├── .gitignore │ ├── README.md │ ├── assets/ │ │ └── css/ │ │ └── tailwind.css │ ├── jsconfig.json │ ├── layouts/ │ │ └── default.vue │ ├── middleware/ │ │ └── auth.js │ ├── nuxt.config.js │ ├── package.json │ ├── pages/ │ │ ├── index.vue │ │ ├── login.vue │ │ └── register.vue │ ├── plugins/ │ │ └── client.js │ ├── store/ │ │ └── README.md │ └── tailwind.config.js ├── prisma-crud/ │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── prisma/ │ │ ├── datamodel.prisma │ │ ├── prisma.yml │ │ └── seed.graphql │ ├── src/ │ │ ├── generated/ │ │ │ └── prisma-client/ │ │ │ ├── index.ts │ │ │ └── prisma-schema.ts │ │ ├── index.ts │ │ ├── schema.graphql │ │ └── utils.ts │ └── tsconfig.json └── renovate.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: [TannerGabriel]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Version [e.g. 22] **Smartphone (please complete the following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - Browser [e.g. stock browser, safari] - Version [e.g. 22] **Additional context** Add any other context about the problem here. ================================================ FILE: .github/workflows/codeql-analysis.yml ================================================ # For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ master ] pull_request: # The branches below must be a subset of the branches above branches: [ master ] schedule: - cron: '26 23 * * 2' jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'javascript' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - name: Checkout repository uses: actions/checkout@v2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v1 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 ================================================ FILE: .github/workflows/stale.yml ================================================ name: Mark stale issues and pull requests on: schedule: - cron: "0 0 * * *" jobs: stale: runs-on: ubuntu-latest steps: - uses: actions/stale@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'Stale pull request message' stale-issue-label: 'no-issue-activity' stale-pr-label: 'no-pr-activity' stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days' days-before-stale: 30 days-before-close: 5 ================================================ FILE: .gitignore ================================================ # compiled output /dist /node_modules # API Keys .env # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # OS .DS_Store # Tests /coverage /.nyc_output # IDEs and editors /.idea .project .classpath .c9/ *.launch .settings/ *.sublime-workspace # IDE - VSCode .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json ================================================ FILE: Camera/.gitignore ================================================ *.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 ================================================ FILE: Camera/.idea/codeStyles/Project.xml ================================================ ================================================ FILE: Camera/.idea/codeStyles/codeStyleConfig.xml ================================================ ================================================ FILE: Camera/.idea/encodings.xml ================================================ ================================================ FILE: Camera/.idea/gradle.xml ================================================ ================================================ FILE: Camera/.idea/misc.xml ================================================ ================================================ FILE: Camera/.idea/vcs.xml ================================================ ================================================ FILE: Camera/app/.gitignore ================================================ /build ================================================ FILE: Camera/app/build.gradle ================================================ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.videorecorder" minSdkVersion 15 targetSdkVersion 28 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.1.0-alpha03' 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' //Fotoapparat implementation 'io.fotoapparat:fotoapparat:2.6.1' //Picasso implementation 'com.squareup.picasso:picasso:2.71828' // Kotlin Android Coroutines implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0-RC1' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0-RC1" //Material Design implementation 'com.google.android.material:material:1.0.0-rc01' } ================================================ FILE: Camera/app/proguard-rules.pro ================================================ # 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 ================================================ FILE: Camera/app/src/androidTest/java/com/example/videorecorder/ExampleInstrumentedTest.kt ================================================ package com.example.videorecorder 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.videorecorder", appContext.packageName) } } ================================================ FILE: Camera/app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: Camera/app/src/main/java/com/example/videorecorder/MainActivity.kt ================================================ package com.example.videorecorder import android.Manifest import android.content.Intent import android.content.pm.PackageManager import android.os.Build import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Environment import androidx.annotation.RequiresApi import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import io.fotoapparat.Fotoapparat import io.fotoapparat.configuration.CameraConfiguration import io.fotoapparat.log.logcat import io.fotoapparat.log.loggers import io.fotoapparat.parameter.ScaleType import io.fotoapparat.selector.* import io.fotoapparat.view.CameraView import kotlinx.android.synthetic.main.activity_main.* import java.io.File import kotlinx.coroutines.* class MainActivity : AppCompatActivity() { var fotoapparat: Fotoapparat? = null val filename = "test.png" val sd = Environment.getExternalStorageDirectory() val dest = File(sd, filename) var fotoapparatState : FotoapparatState? = null var cameraStatus : CameraState? = null var flashState: FlashState? = null val permissions = arrayOf(android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) createFotoapparat() cameraStatus = CameraState.BACK flashState = FlashState.OFF fotoapparatState = FotoapparatState.OFF fab_camera.setOnClickListener { print("Taking photo") val test = "Test233" takePhoto() } fab_switch_camera.setOnClickListener { switchCamera() } fab_flash.setOnClickListener { changeFlashState() } } private fun createFotoapparat(){ val cameraView = findViewById(R.id.camera_view) fotoapparat = Fotoapparat( context = this, view = cameraView, scaleType = ScaleType.CenterCrop, lensPosition = back(), logger = loggers( logcat() ), cameraErrorCallback = { error -> println("Recorder errors: $error") } ) } private fun changeFlashState() { fotoapparat?.updateConfiguration( CameraConfiguration( flashMode = if(flashState == FlashState.TORCH) off() else torch() ) ) if(flashState == FlashState.TORCH) flashState = FlashState.OFF else flashState = FlashState.TORCH } private fun switchCamera() { fotoapparat?.switchTo( lensPosition = if (cameraStatus == CameraState.BACK) front() else back(), cameraConfiguration = CameraConfiguration() ) if(cameraStatus == CameraState.BACK) cameraStatus = CameraState.FRONT else cameraStatus = CameraState.BACK } private fun takePhoto() { if (hasNoPermissions()) { val permissions = arrayOf(android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE) ActivityCompat.requestPermissions(this, permissions,0) }else{ println("Has all permissions!") fotoapparat ?.takePicture() ?.saveToFile(dest) } } @RequiresApi(Build.VERSION_CODES.M) override fun onStart() { super.onStart() println("Onstart") if (hasNoPermissions()) { requestPermission() }else{ fotoapparat?.start() fotoapparatState = FotoapparatState.ON } } private fun hasNoPermissions(): Boolean{ return ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED } fun requestPermission(){ ActivityCompat.requestPermissions(this, permissions,0) } override fun onStop() { super.onStop() fotoapparat?.stop() FotoapparatState.OFF } override fun onPause() { super.onPause() println("OnPause") } override fun onResume() { super.onResume() println("OnResume") println(fotoapparatState) if(!hasNoPermissions() && fotoapparatState == FotoapparatState.OFF){ val intent = Intent(baseContext, MainActivity::class.java) startActivity(intent) finish() } } } enum class CameraState{ FRONT, BACK } enum class FlashState{ TORCH, OFF } enum class FotoapparatState{ ON, OFF } ================================================ FILE: Camera/app/src/main/res/drawable/ic_camera.xml ================================================ ================================================ FILE: Camera/app/src/main/res/drawable/ic_flash.xml ================================================ ================================================ FILE: Camera/app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: Camera/app/src/main/res/drawable/ic_switch_camera.xml ================================================ ================================================ FILE: Camera/app/src/main/res/drawable-v24/ic_launcher_foreground.xml ================================================ ================================================ FILE: Camera/app/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: Camera/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: Camera/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: Camera/app/src/main/res/values/colors.xml ================================================ #008577 #00574B #D81B60 ================================================ FILE: Camera/app/src/main/res/values/strings.xml ================================================ Camera ================================================ FILE: Camera/app/src/main/res/values/styles.xml ================================================ ================================================ FILE: Camera/app/src/test/java/com/example/videorecorder/ExampleUnitTest.kt ================================================ package com.example.videorecorder import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } } ================================================ FILE: Camera/build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.3.11' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.0-alpha09' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ================================================ FILE: Camera/gradle/wrapper/gradle-wrapper.properties ================================================ #Mon Dec 31 22:42:36 CET 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip ================================================ FILE: Camera/gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app's APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official ================================================ FILE: Camera/gradlew ================================================ #!/usr/bin/env sh ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi exec "$JAVACMD" "$@" ================================================ FILE: Camera/gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: Camera/settings.gradle ================================================ include ':app' ================================================ FILE: CameraX/.gitignore ================================================ *.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 ================================================ FILE: CameraX/.idea/codeStyles/Project.xml ================================================ ================================================ FILE: CameraX/.idea/codeStyles/codeStyleConfig.xml ================================================ ================================================ FILE: CameraX/.idea/encodings.xml ================================================ ================================================ FILE: CameraX/.idea/gradle.xml ================================================ ================================================ FILE: CameraX/.idea/misc.xml ================================================ ================================================ FILE: CameraX/.idea/runConfigurations.xml ================================================ ================================================ FILE: CameraX/.idea/vcs.xml ================================================ ================================================ FILE: CameraX/app/.gitignore ================================================ /build ================================================ FILE: CameraX/app/build.gradle ================================================ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.camerax" minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { // Kotlin lang implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' // AndroidX libraries implementation 'androidx.appcompat:appcompat:1.1.0-alpha04' implementation 'androidx.core:core-ktx:1.0.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' //Material Design implementation 'com.google.android.material:material:1.1.0-alpha05' // CameraX def camerax_version = "1.0.0-alpha01" implementation "androidx.camera:camera-core:${camerax_version}" implementation "androidx.camera:camera-camera2:${camerax_version}" // Unit testing testImplementation 'androidx.test.ext:junit:1.1.0' testImplementation 'androidx.test:rules:1.1.1' testImplementation 'androidx.test:runner:1.1.1' testImplementation 'androidx.test.espresso:espresso-core:3.1.1' testImplementation "org.robolectric:robolectric:4.1" // Instrumented testing androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test:rules:1.1.1' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } ================================================ FILE: CameraX/app/proguard-rules.pro ================================================ # 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 ================================================ FILE: CameraX/app/src/androidTest/java/com/example/camerax/ExampleInstrumentedTest.kt ================================================ package com.example.camerax import android.support.test.InstrumentationRegistry import android.support.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.camerax", appContext.packageName) } } ================================================ FILE: CameraX/app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: CameraX/app/src/main/java/com/example/camerax/MainActivity.kt ================================================ package com.example.camerax import android.Manifest import android.content.pm.PackageManager import android.os.Bundle import android.os.Environment import android.util.Log import android.util.Rational import android.util.Size import android.view.TextureView import androidx.camera.core.* import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import androidx.lifecycle.LifecycleOwner import kotlinx.android.synthetic.main.activity_main.* import java.io.File val permissions = arrayOf(android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE) class MainActivity : AppCompatActivity() { private val filename = "test.png" private val sd = Environment.getExternalStorageDirectory() private val dest = File(sd, filename) private var lensFacing = CameraX.LensFacing.BACK private var imageCapture: ImageCapture? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) bindCamera() // Takes an images and saves it in the local storage fab_camera.setOnClickListener { imageCapture?.takePicture(dest, object : ImageCapture.OnImageSavedListener { override fun onError(error: ImageCapture.UseCaseError, message: String, exc: Throwable?) { Log.e("Image", error.toString()) } override fun onImageSaved(file: File) { Log.v("Image", "Successfully saved image") } }) } // Changes the flash mode when the button is clicked fab_flash.setOnClickListener { val flashMode = imageCapture?.flashMode if(flashMode == FlashMode.ON) imageCapture?.flashMode = FlashMode.OFF else imageCapture?.flashMode = FlashMode.ON } // Changes the lens direction if the button is clicked fab_switch_camera.setOnClickListener { lensFacing = if (CameraX.LensFacing.FRONT == lensFacing) { CameraX.LensFacing.BACK } else { CameraX.LensFacing.FRONT } bindCamera() } } /** * Check if the app has all permissions */ private fun hasNoPermissions(): Boolean{ return ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED } /** * Request all permissions */ private fun requestPermission(){ ActivityCompat.requestPermissions(this, permissions,0) } /** * Bind the Camera to the lifecycle */ private fun bindCamera(){ CameraX.unbindAll() // Preview config for the camera val previewConfig = PreviewConfig.Builder() .setLensFacing(lensFacing) .build() val preview = Preview(previewConfig) // Image capture config which controls the Flash and Lens val imageCaptureConfig = ImageCaptureConfig.Builder() .setTargetRotation(windowManager.defaultDisplay.rotation) .setLensFacing(lensFacing) .setFlashMode(FlashMode.ON) .build() imageCapture = ImageCapture(imageCaptureConfig) // The view that displays the preview val textureView: TextureView = findViewById(R.id.view_finder) // Handles the output data of the camera preview.setOnPreviewOutputUpdateListener { previewOutput -> // Displays the camera image in our preview view textureView.surfaceTexture = previewOutput.surfaceTexture } // Bind the camera to the lifecycle CameraX.bindToLifecycle(this as LifecycleOwner, imageCapture, preview) } override fun onStart() { super.onStart() // Check and request permissions if (hasNoPermissions()) { requestPermission() } } } ================================================ FILE: CameraX/app/src/main/res/drawable/ic_camera.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/drawable/ic_flash.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/drawable/ic_switch_camera.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/drawable-v24/ic_launcher_foreground.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: CameraX/app/src/main/res/values/colors.xml ================================================ #008577 #00574B #D81B60 ================================================ FILE: CameraX/app/src/main/res/values/strings.xml ================================================ CameraX ================================================ FILE: CameraX/app/src/main/res/values/styles.xml ================================================ ================================================ FILE: CameraX/app/src/test/java/com/example/camerax/ExampleUnitTest.kt ================================================ package com.example.camerax import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } } ================================================ FILE: CameraX/build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.3.30' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ================================================ FILE: CameraX/gradle/wrapper/gradle-wrapper.properties ================================================ #Thu May 09 11:52:47 CEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip ================================================ FILE: CameraX/gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official android.useAndroidX=true android.enableJetifier=true ================================================ FILE: CameraX/gradlew ================================================ #!/usr/bin/env sh ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi exec "$JAVACMD" "$@" ================================================ FILE: CameraX/gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: CameraX/settings.gradle ================================================ include ':app' ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 Tanner Gabriel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Nest-CRUD/.gitignore ================================================ # compiled output /dist /node_modules # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # OS .DS_Store # Tests /coverage /.nyc_output # IDEs and editors /.idea .project .classpath .c9/ *.launch .settings/ *.sublime-workspace # IDE - VSCode .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json ================================================ FILE: Nest-CRUD/.prettierrc ================================================ { "singleQuote": true, "trailingComma": "all" } ================================================ FILE: Nest-CRUD/README.md ================================================ # Nestjs MongoDB CRUD Simple MongoDB CRUD example demonstrating the Nestjs application structure as well as how you can work with databases. For an in-depth explanation of the application and the basic Nestjs concepts, you can follow [this article](https://gabrieltanner.org/blog/nestjs-crashcourse). ## Requirements - [NodeJS](https://nodejs.org/en/) - MongoDB database ## Getting started ### Installing dependencies First, you need to install all the needed dependencies. ```bash $ npm install ``` ### Configuring the database Before starting the application, you will need to create a MongoDB database and edit the connection string in the `app.modules.ts` file to match your database configuration. The repository includes a Docker-Compose file that helps you start MongoDB. ``` docker-compose up ``` The default database configuration in the `app.module.ts` file looks like this: ``` @Module({ imports: [MongooseModule.forRoot('mongodb://localhost/nest')], }) ``` If you are not running the database on your local machine, replace localhost with the correct IP-Address. ### Starting the application After installing the dependencies, you can run the application using one of the following commands. ```bash # development $ npm run start # watch mode $ npm run start:dev # production mode $ npm run start:prod ``` ================================================ FILE: Nest-CRUD/docker-compose.yaml ================================================ version: '3.7' services: mongodb: image: mongo:latest ports: - 27017:27017 volumes: - mongodb_data:/data/db volumes: mongodb_data: ================================================ FILE: Nest-CRUD/nest-cli.json ================================================ { "language": "ts", "collection": "@nestjs/schematics", "sourceRoot": "src" } ================================================ FILE: Nest-CRUD/nodemon-debug.json ================================================ { "watch": ["src"], "ext": "ts", "ignore": ["src/**/*.spec.ts"], "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts" } ================================================ FILE: Nest-CRUD/nodemon.json ================================================ { "watch": ["dist"], "ext": "js", "exec": "node dist/main" } ================================================ FILE: Nest-CRUD/package.json ================================================ { "name": "nest-crud", "version": "0.0.1", "description": "", "author": "", "license": "MIT", "scripts": { "build": "tsc -p tsconfig.build.json", "format": "prettier --write \"src/**/*.ts\"", "start": "ts-node -r tsconfig-paths/register src/main.ts", "start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ", "start:debug": "nodemon --config nodemon-debug.json", "prestart:prod": "rimraf dist && npm run build", "start:prod": "node dist/main.js", "lint": "tslint -p tsconfig.json -c tslint.json", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@nestjs/common": "8.2.6", "@nestjs/core": "8.2.6", "@nestjs/mongoose": "9.0.2", "@nestjs/platform-express": "8.2.6", "mongoose": "6.1.8", "reflect-metadata": "0.1.13", "rimraf": "3.0.2", "rxjs": "7.5.2" }, "devDependencies": { "@nestjs/testing": "8.2.6", "@types/express": "4.17.13", "@types/jest": "27.4.0", "@types/node": "17.0.12", "@types/supertest": "2.0.11", "concurrently": "7.0.0", "jest": "27.4.7", "nodemon": "2.0.15", "prettier": "2.5.1", "supertest": "6.2.2", "ts-jest": "27.1.3", "ts-node": "10.4.0", "tsconfig-paths": "3.12.0", "tslint": "5.20.1", "typescript": "4.5.5", "wait-on": "6.0.0" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, "coverageDirectory": "../coverage", "testEnvironment": "node" }, "keywords": [ "Nestjs", "Typescript", "CRUD", "MongoDB" ] } ================================================ FILE: Nest-CRUD/src/app.controller.spec.ts ================================================ import { Test, TestingModule } from '@nestjs/testing'; import { AppController } from './app.controller'; import { AppService } from './app.service'; describe('AppController', () => { let appController: AppController; beforeEach(async () => { const app: TestingModule = await Test.createTestingModule({ controllers: [AppController], providers: [AppService], }).compile(); appController = app.get(AppController); }); describe('root', () => { it('should return "Hello World!"', () => { expect(appController.getHello()).toBe('Hello World!'); }); }); }); ================================================ FILE: Nest-CRUD/src/app.controller.ts ================================================ import { Controller, Get } from '@nestjs/common'; import { AppService } from './app.service'; @Controller() export class AppController { constructor(private readonly appService: AppService) {} @Get() getHello(): string { return this.appService.getHello(); } } ================================================ FILE: Nest-CRUD/src/app.module.ts ================================================ import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { MongooseModule } from '@nestjs/mongoose'; import { ItemsModule } from './items/items.module'; @Module({ imports: [MongooseModule.forRoot('mongodb://localhost/nest'), ItemsModule], controllers: [AppController], providers: [AppService], }) export class AppModule {} ================================================ FILE: Nest-CRUD/src/app.service.ts ================================================ import { Injectable } from '@nestjs/common'; @Injectable() export class AppService { getHello(): string { return 'Hello World!'; } } ================================================ FILE: Nest-CRUD/src/items/dto/create-item.dto.ts ================================================ export class CreateItemDto { readonly name: string; readonly description: string; readonly qty: number; } ================================================ FILE: Nest-CRUD/src/items/interfaces/item.interface.ts ================================================ import { Document } from 'mongoose'; export interface Item extends Document { id?: string; name: string; description?: string; qty: number; } ================================================ FILE: Nest-CRUD/src/items/item.controller.spec.ts ================================================ ================================================ FILE: Nest-CRUD/src/items/items.controller.ts ================================================ import { Controller, Get, Post, Put, Delete, Body, Param, } from '@nestjs/common'; import { CreateItemDto } from './dto/create-item.dto'; import { ItemsService } from './items.service'; import { Item } from './interfaces/item.interface'; @Controller('items') export class ItemsController { constructor(private readonly itemsService: ItemsService) {} @Get() findAll(): Promise { return this.itemsService.findAll(); } @Get(':id') findOne(@Param('id') id): Promise { return this.itemsService.findOne(id); } @Post() create(@Body() createItemDto: CreateItemDto): Promise { return this.itemsService.create(createItemDto); } @Delete(':id') delete(@Param('id') id): Promise { return this.itemsService.delete(id); } @Put(':id') update(@Body() updateItemDto: CreateItemDto, @Param('id') id): Promise { return this.itemsService.update(id, updateItemDto); } } ================================================ FILE: Nest-CRUD/src/items/items.module.ts ================================================ import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { ItemsController } from './items.controller'; import { ItemsService } from './items.service'; import { ItemSchema } from './schemas/item.schema'; @Module({ imports: [MongooseModule.forFeature([{ name: 'Item', schema: ItemSchema }])], controllers: [ItemsController], providers: [ItemsService], }) export class ItemsModule {} ================================================ FILE: Nest-CRUD/src/items/items.service.ts ================================================ import { Injectable } from '@nestjs/common'; import { Item } from './interfaces/item.interface'; import { Model } from 'mongoose'; import { InjectModel } from '@nestjs/mongoose'; import { CreateItemDto } from './dto/create-item.dto'; @Injectable() export class ItemsService { constructor(@InjectModel('Item') private readonly itemModel: Model) {} async findAll(): Promise { return await this.itemModel.find(); } async findOne(id: string): Promise { return await this.itemModel.findOne({ _id: id }); } async create(item: CreateItemDto): Promise { const newItem = new this.itemModel(item); return await newItem.save(); } async delete(id: string): Promise { return await this.itemModel.findByIdAndRemove(id); } async update(id: string, item: CreateItemDto): Promise { return await this.itemModel.findByIdAndUpdate(id, item, { new: true }); } } ================================================ FILE: Nest-CRUD/src/items/schemas/item.schema.ts ================================================ import * as mongoose from 'mongoose'; export const ItemSchema = new mongoose.Schema({ name: String, qty: Number, description: String, }); ================================================ FILE: Nest-CRUD/src/main.ts ================================================ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); await app.listen(4000); } bootstrap(); ================================================ FILE: Nest-CRUD/test/app.e2e-spec.ts ================================================ import { Test, TestingModule } from '@nestjs/testing'; import * as request from 'supertest'; import { AppModule } from './../src/app.module'; describe('AppController (e2e)', () => { let app; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule], }).compile(); app = moduleFixture.createNestApplication(); await app.init(); }); it('/ (GET)', () => { return request(app.getHttpServer()) .get('/') .expect(200) .expect('Hello World!'); }); }); ================================================ FILE: Nest-CRUD/test/jest-e2e.json ================================================ { "moduleFileExtensions": ["js", "json", "ts"], "rootDir": ".", "testEnvironment": "node", "testRegex": ".e2e-spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" } } ================================================ FILE: Nest-CRUD/tsconfig.build.json ================================================ { "extends": "./tsconfig.json", "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] } ================================================ FILE: Nest-CRUD/tsconfig.json ================================================ { "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true }, "exclude": ["node_modules"] } ================================================ FILE: Nest-CRUD/tslint.json ================================================ { "defaultSeverity": "error", "extends": ["tslint:recommended"], "jsRules": { "no-unused-expression": true }, "rules": { "quotemark": [true, "single"], "member-access": [false], "ordered-imports": [false], "max-line-length": [true, 150], "member-ordering": [false], "interface-name": [false], "arrow-parens": false, "object-literal-sort-keys": false }, "rulesDirectory": [] } ================================================ FILE: NestVueChat/.gitignore ================================================ # compiled output /dist /node_modules # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # OS .DS_Store # Tests /coverage /.nyc_output # IDEs and editors /.idea .project .classpath .c9/ *.launch .settings/ *.sublime-workspace # IDE - VSCode .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json ================================================ FILE: NestVueChat/.prettierrc ================================================ { "singleQuote": true, "trailingComma": "all" } ================================================ FILE: NestVueChat/README.md ================================================ # Nestjs file uploading Nestjs Vue real-time chat, which utilizes Websockets to implement real-time communication in Nestjs. For an in-depth explanation of the application, you can follow [this article](https://gabrieltanner.org/blog/nestjs-realtime-chat). ## Requirements - [NodeJS](https://nodejs.org/en/) ## Getting started ### Installing dependencies First, you need to install all the needed dependencies. ```bash $ npm install ``` ### Starting the application After installing the dependencies, you can run the application using one of the following commands. ```bash # development $ npm run start # watch mode $ npm run start:dev # production mode $ npm run start:prod ``` ## Testing the application After starting the application, you should see our layout when visiting http://localhost:3000 in your browser. After opening the application in multiple browser windows, you can test the functionality. ================================================ FILE: NestVueChat/nest-cli.json ================================================ { "language": "ts", "collection": "@nestjs/schematics", "sourceRoot": "src" } ================================================ FILE: NestVueChat/nodemon-debug.json ================================================ { "watch": ["src"], "ext": "ts", "ignore": ["src/**/*.spec.ts"], "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts" } ================================================ FILE: NestVueChat/nodemon.json ================================================ { "watch": ["dist"], "ext": "js", "exec": "node dist/main" } ================================================ FILE: NestVueChat/package.json ================================================ { "name": "backend", "version": "0.0.1", "description": "", "author": "", "license": "MIT", "scripts": { "build": "tsc -p tsconfig.build.json", "format": "prettier --write \"src/**/*.ts\"", "start": "ts-node -r tsconfig-paths/register src/main.ts", "start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ", "start:debug": "nodemon --config nodemon-debug.json", "prestart:prod": "rimraf dist && npm run build", "start:prod": "node dist/main.js", "lint": "tslint -p tsconfig.json -c tslint.json", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@nestjs/common": "8.2.6", "@nestjs/core": "8.2.6", "@nestjs/platform-express": "8.2.6", "@nestjs/platform-socket.io": "8.2.6", "@nestjs/websockets": "8.2.6", "reflect-metadata": "0.1.13", "rimraf": "3.0.2", "rxjs": "7.5.2" }, "devDependencies": { "@nestjs/testing": "8.2.6", "@types/express": "4.17.13", "@types/jest": "27.4.0", "@types/node": "17.0.12", "@types/socket.io": "3.0.1", "@types/supertest": "2.0.11", "concurrently": "7.0.0", "jest": "27.4.7", "nodemon": "2.0.15", "prettier": "2.5.1", "supertest": "6.2.2", "ts-jest": "27.1.3", "ts-node": "10.4.0", "tsconfig-paths": "3.12.0", "tslint": "5.20.1", "typescript": "4.5.5", "wait-on": "6.0.0" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, "coverageDirectory": "../coverage", "testEnvironment": "node" }, "keywords": [ "Nestjs", "Typescript", "Chat application", "Nestjs Chat", "Websockets", "Nestjs Websockets" ] } ================================================ FILE: NestVueChat/src/app.gateway.ts ================================================ import { SubscribeMessage, WebSocketGateway, OnGatewayInit, WebSocketServer, OnGatewayConnection, OnGatewayDisconnect, } from '@nestjs/websockets'; import { Logger } from '@nestjs/common'; import { Socket, Server } from 'socket.io'; @WebSocketGateway({ cors: { origin: '*', }, }) export class AppGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect { @WebSocketServer() server: Server; private logger: Logger = new Logger('AppGateway'); @SubscribeMessage('msgToServer') handleMessage(client: Socket, payload: string): void { this.server.emit('msgToClient', payload); } afterInit(server: Server) { this.logger.log('Init'); } handleDisconnect(client: Socket) { this.logger.log(`Client disconnected: ${client.id}`); } handleConnection(client: Socket, ...args: any[]) { this.logger.log(`Client connected: ${client.id}`); } } ================================================ FILE: NestVueChat/src/app.module.ts ================================================ import { Module } from '@nestjs/common'; import { AppGateway } from './app.gateway'; @Module({ imports: [], controllers: [], providers: [AppGateway], }) export class AppModule {} ================================================ FILE: NestVueChat/src/main.ts ================================================ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { NestExpressApplication } from '@nestjs/platform-express'; import { join } from 'path'; async function bootstrap() { const app = await NestFactory.create(AppModule); app.useStaticAssets(join(__dirname, '..', 'static')); await app.listen(3000); } bootstrap(); ================================================ FILE: NestVueChat/static/index.html ================================================ Nestjs SocketIO

{{ title }}



  • {{ message.name }}: {{ message.text }}


================================================ FILE: NestVueChat/static/main.js ================================================ const app = new Vue({ el: '#app', data: { title: 'Nestjs Websockets Chat', name: '', text: '', messages: [], socket: null }, methods: { sendMessage() { if(this.validateInput()) { const message = { name: this.name, text: this.text } this.socket.emit('msgToServer', message) this.text = '' } }, receivedMessage(message) { this.messages.push(message) }, validateInput() { return this.name.length > 0 && this.text.length > 0 } }, created() { this.socket = io('http://localhost:3000') this.socket.on('msgToClient', (message) => { this.receivedMessage(message) }) } }) ================================================ FILE: NestVueChat/static/styles.css ================================================ #messages{ height:300px; overflow-y: scroll; } #app { margin-top: 2rem; } ================================================ FILE: NestVueChat/test/app.e2e-spec.ts ================================================ import { Test, TestingModule } from '@nestjs/testing'; import * as request from 'supertest'; import { AppModule } from './../src/app.module'; describe('AppController (e2e)', () => { let app; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule], }).compile(); app = moduleFixture.createNestApplication(); await app.init(); }); it('/ (GET)', () => { return request(app.getHttpServer()) .get('/') .expect(200) .expect('Hello World!'); }); }); ================================================ FILE: NestVueChat/test/jest-e2e.json ================================================ { "moduleFileExtensions": ["js", "json", "ts"], "rootDir": ".", "testEnvironment": "node", "testRegex": ".e2e-spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" } } ================================================ FILE: NestVueChat/tsconfig.build.json ================================================ { "extends": "./tsconfig.json", "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] } ================================================ FILE: NestVueChat/tsconfig.json ================================================ { "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true }, "exclude": ["node_modules"] } ================================================ FILE: NestVueChat/tslint.json ================================================ { "defaultSeverity": "error", "extends": ["tslint:recommended"], "jsRules": { "no-unused-expression": true }, "rules": { "quotemark": [true, "single"], "member-access": [false], "ordered-imports": [false], "max-line-length": [true, 150], "member-ordering": [false], "interface-name": [false], "arrow-parens": false, "object-literal-sort-keys": false }, "rulesDirectory": [] } ================================================ FILE: Notifications/.gitignore ================================================ *.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 ================================================ FILE: Notifications/.idea/codeStyles/Project.xml ================================================ ================================================ FILE: Notifications/.idea/codeStyles/codeStyleConfig.xml ================================================ ================================================ FILE: Notifications/.idea/encodings.xml ================================================ ================================================ FILE: Notifications/.idea/gradle.xml ================================================ ================================================ FILE: Notifications/.idea/misc.xml ================================================ ================================================ FILE: Notifications/.idea/runConfigurations.xml ================================================ ================================================ FILE: Notifications/.idea/vcs.xml ================================================ ================================================ FILE: Notifications/app/.gitignore ================================================ /build ================================================ FILE: Notifications/app/build.gradle ================================================ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.notifications" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.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 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation "com.android.support:support-compat:28.0.0" } ================================================ FILE: Notifications/app/proguard-rules.pro ================================================ # 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 ================================================ FILE: Notifications/app/src/androidTest/java/com/example/notifications/ExampleInstrumentedTest.kt ================================================ package com.example.notifications import android.support.test.InstrumentationRegistry import android.support.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.notifications", appContext.packageName) } } ================================================ FILE: Notifications/app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: Notifications/app/src/main/java/com/example/notifications/MainActivity.kt ================================================ package com.example.notifications import android.app.Notification.VISIBILITY_PUBLIC import android.os.Build import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.support.v4.app.NotificationCompat import android.support.v4.app.NotificationManagerCompat import kotlinx.android.synthetic.main.activity_main.* import android.R.attr.name import android.annotation.SuppressLint import android.annotation.TargetApi import android.app.Notification.VISIBILITY_PRIVATE import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent import android.content.Context import android.content.Intent import android.graphics.BitmapFactory import android.os.HandlerThread import android.support.annotation.RequiresApi import android.widget.RemoteViews class MainActivity : AppCompatActivity() { private val CHANNEL_ID = "CHANNEL_ID" @SuppressLint("NewApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) createNotificationChannel() default_notification_btn.setOnClickListener { createNormalNotification() } head_up_notification_btn.setOnClickListener { createHeadsUpNotification() } lock_screen_notification_btn.setOnClickListener { createLockScreenNotification() } notification_badged.setOnClickListener { createBadgedNotification() } notification_click_action_btn.setOnClickListener { createNotificationWithClickAction() } notification_action_button_btn.setOnClickListener { createNotificationWithActionButtons() } expandable_notification.setOnClickListener { createExpandableNotification() } progress_bar_notification.setOnClickListener { createProgressBarNotification() } group_notification.setOnClickListener { createGroupNotification() } custom_notification.setOnClickListener { createCustomNotification() } } // Creates a standard notification fun createNormalNotification(){ val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Normal Notification") .setContentText("Really great content for this notification") .setPriority(NotificationCompat.PRIORITY_DEFAULT) createNotification(0, builder) } // Creates a headup notification fun createHeadsUpNotification(){ val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Heads up notification") .setContentText("Really great content for this notification") .setPriority(NotificationCompat.PRIORITY_HIGH) if (Build.VERSION.SDK_INT >= 21) builder.setVibrate(LongArray(0)) createNotification(1, builder) } // Create a notification which will be visible on the lockscreen @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun createLockScreenNotification(){ val publicBuilder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Alternative notification") .setPriority(NotificationCompat.PRIORITY_HIGH) .setVisibility(VISIBILITY_PUBLIC) val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Lock screen Notification") .setContentText("Really great content for this notification") .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setVisibility(VISIBILITY_PRIVATE) .setPublicVersion(publicBuilder.build()) createNotification(2, builder) } // Create a notification which shows a badged on newer android versions fun createBadgedNotification(){ val builder = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID) .setContentTitle("Badged Notification") .setContentText("New badged notification") .setSmallIcon(R.drawable.notification_icon) .setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL) createNotification(3, builder) } // Create a notification with a click event fun createNotificationWithClickAction(){ val intent = Intent(this, MainActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK } val pendingIntent: PendingIntent = PendingIntent.getActivity(this, 0, intent, 0) val builder = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID) .setContentTitle("Notification with click action") .setContentText("New notification with great click action") .setSmallIcon(R.drawable.notification_icon) .setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL) .setContentIntent(pendingIntent) .setAutoCancel(true) createNotification(4, builder) } // Create a notification with an action button fun createNotificationWithActionButtons(){ val intent = Intent(this, MainActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK } val pendingIntent: PendingIntent = PendingIntent.getActivity(this, 0, intent, 0) val builder = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID) .setContentTitle("Notification with click action") .setContentText("New notification with great click action") .setSmallIcon(R.drawable.notification_icon) .setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL) .addAction(R.drawable.notification_icon, "Open Activity", pendingIntent) createNotification(5, builder) } // Create a notification that can be expanded for more information fun createExpandableNotification(){ val bitmap = BitmapFactory.decodeResource(resources, R.drawable.notification_icon) val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Simple expandable notification") .setContentText("Simple notification that can be expended ") .setLargeIcon(bitmap) .setStyle(NotificationCompat.BigPictureStyle() .bigPicture(bitmap) .bigLargeIcon(null)) /* Add large text .setStyle(NotificationCompat.BigTextStyle() .bigText("Some great big text") */ createNotification(6, builder) } // Create a notification with a simple progress bar fun createProgressBarNotification(){ val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Simple progress bar notification") .setContentText("Simple notification with a progress bar ") // Progress values val PROGRESS_MAX = 100 val PROGRESS_CURRENT = 0 NotificationManagerCompat.from(this).apply { // Sets the initial progress to 0 builder.setProgress(PROGRESS_MAX, PROGRESS_CURRENT, false) notify(7 , builder.build()) for(i in 0 until 100){ builder.setProgress(PROGRESS_MAX, i, false) HandlerThread.sleep(100) } // Updates the notification when the progress is done builder.setContentText("Download complete") .setProgress(0, 0, false) notify(7, builder.build()) } } val GROUP_KEY = "com.android.example.KEY" // Create a simple group notification fun createGroupNotification(){ val groupBuilderOne = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Simple group notification") .setContentText("Simple notification group") .setGroup(GROUP_KEY) val groupBuilderTwo = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Second simple group notification") .setContentText("Simple notification group") .setGroup(GROUP_KEY) // For older versions than 7.0 val summaryNotification = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID) .setContentTitle("Notification group summary") .setContentText("Notification group summary") .setSmallIcon(R.drawable.notification_icon) .setGroup(GROUP_KEY) .setGroupSummary(true) createNotification(8, groupBuilderOne) createNotification(9, groupBuilderTwo) createNotification(10, summaryNotification) } fun createCustomNotification(){ // Get the layouts to use in the custom notification val notificationLayout = RemoteViews(packageName, R.layout.custom_notification_layout) val notificationLayoutExpanded = RemoteViews(packageName, R.layout.custom_notification_expended_layout) notificationLayout.setTextViewText(R.id.notification_title, "Title") notificationLayout.setTextViewText(R.id.notification_info, "Expand for more information") // Apply the layouts to the notification val customNotification = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setStyle(NotificationCompat.DecoratedCustomViewStyle()) .setCustomContentView(notificationLayout) .setCustomBigContentView(notificationLayoutExpanded) createNotification(11, customNotification) } // Creates the notification and displays it fun createNotification(id: Int, builder: NotificationCompat.Builder){ with(NotificationManagerCompat.from(this)) { notify(id, builder.build()) } } // Create the notification channel private fun createNotificationChannel() { // Create the NotificationChannel, but only on API 26+ because // the NotificationChannel class is new and not in the support library if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val name = "Channel" val descriptionText = "Simple channel example" val importance = NotificationManager.IMPORTANCE_DEFAULT val channel = NotificationChannel(CHANNEL_ID, name, importance).apply { description = descriptionText //setShowBadge(false) } // Register the channel with the system val notificationManager: NotificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.createNotificationChannel(channel) } } } ================================================ FILE: Notifications/app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: Notifications/app/src/main/res/drawable/notification_icon.xml ================================================ ================================================ FILE: Notifications/app/src/main/res/drawable-v24/ic_launcher_foreground.xml ================================================ ================================================ FILE: Notifications/app/src/main/res/layout/activity_main.xml ================================================