Skip to content

Commit

Permalink
rewritten to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Oct 20, 2020
1 parent c322a53 commit bb71e85
Show file tree
Hide file tree
Showing 21 changed files with 1,158 additions and 1,337 deletions.
10 changes: 6 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
Expand All @@ -25,9 +27,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.amitshekhar.android:android-networking:1.0.2'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.0'
implementation 'com.github.GrenderG:Toasty:7be5e09'
Expand All @@ -39,5 +40,6 @@ dependencies {
implementation 'com.mikepenz:aboutlibraries-core:8.3.0'
implementation 'com.mikepenz:aboutlibraries:8.3.0'
implementation 'org.adw.library:discrete-seekbar:1.0.1'
implementation 'com.github.cyb3rko:about-icons:a9e4ccc'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.github.cyb3rko:about-icons:master-SNAPSHOT'
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cyb3rko.logviewerforopenhab" >

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

Expand Down
132 changes: 0 additions & 132 deletions app/src/main/java/com/cyb3rko/logviewerforopenhab/About.java

This file was deleted.

106 changes: 106 additions & 0 deletions app/src/main/java/com/cyb3rko/logviewerforopenhab/About.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.cyb3rko.logviewerforopenhab

import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import android.os.Bundle
import android.os.PersistableBundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.mikepenz.aboutlibraries.LibsBuilder
import mehdi.sakout.aboutpage.AboutPage
import mehdi.sakout.aboutpage.Element

class About : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// load save file
val mySPR = getSharedPreferences("Safe", 0)

// restore set orientation
requestedOrientation = mySPR.getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)

// create and show about page
val aboutPage = AboutPage(this)
.setImage(R.mipmap.ic_launcher_foreground)
.setDescription(getString(R.string.about_description)) // first item
.addItem(
Element().setTitle(String.format(getString(R.string.about_element_1), BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE))
.setIconDrawable(R.drawable.about_icon_github).setOnClickListener(showChangelog())
) // first group
.addGroup(getString(R.string.about_group_1)) // second item
.addItem(
Element().setTitle(getString(R.string.about_element_2)).setIconDrawable(R.drawable._icon_libraries)
.setOnClickListener(showLibraries())
) // third item
.addItem(
Element().setTitle(getString(R.string.about_element_3)).setIconDrawable(R.drawable._icon_question).setOnClickListener(showIcons())
) // second group
.addGroup(getString(R.string.about_group_2)) // feddback item
.addItem(
Element().setTitle(getString(R.string.about_element_feedback_text)).setIconDrawable(R.drawable.about_icon_github)
.setOnClickListener(openOnGithub())
) // email item
.addEmail(getString(R.string.about_element_email_value), getString(R.string.about_element_email_text)) // website item
.addWebsite(getString(R.string.about_element_website_value), getString(R.string.about_element_website_text)) // YouTube item
.addItem(
Element().setTitle(getString(R.string.about_element_youtube_text)).setIconDrawable(R.drawable.about_icon_youtube)
.setIconTint(R.color.about_youtube_color).setOnClickListener(openYouTubeProfile())
) // GitHub item
.addGitHub(getString(R.string.about_element_github_value), getString(R.string.about_element_github_text)) // Instagram item
.addItem(
Element().setTitle(getString(R.string.about_element_instagram_text)).setIconDrawable(R.drawable.about_icon_instagram)
.setIconTint(R.color.about_instagram_color).setOnClickListener(openInstaPage())
)
.create()

// set view (the about page)
setContentView(aboutPage)
}

// show youtube profile
private fun openYouTubeProfile(): View.OnClickListener? {
return View.OnClickListener { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_element_youtube_value)))) }
}

// show changelog
private fun showChangelog(): View.OnClickListener? {
return View.OnClickListener { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_changelog_link)))) }
}

// get and show library credits on click
private fun showLibraries(): View.OnClickListener? {
return View.OnClickListener { // open library credits
LibsBuilder()
.withShowLoadingProgress(true)
.withAboutVersionShownCode(false)
.withAboutVersionShownName(false)
.withAutoDetect(true)
.withAboutIconShown(false)
.withAboutVersionShown(false)
.withVersionShown(true)
.withLicenseDialog(true)
.withLicenseShown(true)
.withCheckCachedDetection(true)
.withSortEnabled(true)
.start(application)
}
}

// show icon credits on click
private fun showIcons(): View.OnClickListener? {
return View.OnClickListener { startActivity(Intent(applicationContext, IconCredits::class.java)) }
}

// open project on GitHub on click
private fun openOnGithub(): View.OnClickListener? {
return View.OnClickListener { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_element_feedback_value)))) }
}

// show instagram page
private fun openInstaPage(): View.OnClickListener? {
return View.OnClickListener { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_element_instagram_value)))) }
}
}
Loading

0 comments on commit bb71e85

Please sign in to comment.