Skip to content

Commit

Permalink
* Converted AboutFragment to Kotlin (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelMess committed Oct 7, 2020
1 parent e84c85b commit b1d00aa
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 85 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 29
Expand Down Expand Up @@ -41,8 +42,16 @@ android {
}
}

repositories {
mavenCentral()
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'androidx.exifinterface:exifinterface:1.3.0'
testImplementation 'junit:junit:4.13'
implementation 'androidx.appcompat:appcompat:1.2.0'
Expand Down

This file was deleted.

@@ -0,0 +1,53 @@
package com.todobom.opennotescanner.helpers

import android.content.Intent
import android.graphics.Point
import android.os.Bundle
import android.view.*
import androidx.fragment.app.DialogFragment
import com.todobom.opennotescanner.OpenNoteScannerApplication
import com.todobom.opennotescanner.R
import org.matomo.sdk.extra.TrackHelper
import us.feras.mdv.MarkdownView

class AboutFragment : DialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val aboutView = inflater.inflate(R.layout.about_view, container)
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
return aboutView
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//These two in case the fragment detached
val activity = activity ?: return
val window = dialog?.window ?: return

val markdownView = view.findViewById<MarkdownView>(R.id.about_markdown)
markdownView.loadMarkdownFile("file:///android_asset/" + getString(R.string.about_filename))
val size = Point()
activity.windowManager.defaultDisplay.getRealSize(size)
window.setLayout((size.x * 0.9).toInt(), (size.y * 0.9).toInt())
window.setGravity(Gravity.CENTER)
val about_shareapp = view.findViewById<View>(R.id.about_shareapp)
about_shareapp.setOnClickListener {
val shareBody = getString(R.string.share_app_body) + APP_LINK
val sharingIntent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_app_subject))
putExtra(Intent.EXTRA_TEXT, shareBody)
}
val tracker = (activity.application as OpenNoteScannerApplication).tracker
TrackHelper.track().screen("/shareapp").title("Share Application").with(tracker)
startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_app_using)))
}
}

companion object {
private const val APP_LINK = "https://goo.gl/2JwEPq"
}
}
2 changes: 2 additions & 0 deletions build.gradle
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.10'
repositories {
jcenter()
maven {
Expand All @@ -11,6 +12,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
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
Expand Down

0 comments on commit b1d00aa

Please sign in to comment.