Skip to content

Commit

Permalink
Android GUI: Update language and dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <[email protected]>
  • Loading branch information
g-maxime committed Sep 27, 2023
1 parent 692083a commit b4947eb
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 153 deletions.
44 changes: 23 additions & 21 deletions Source/GUI/Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

import com.android.build.OutputFile
Expand All @@ -14,6 +12,7 @@ android {
viewBinding true
}
compileSdk 34
namespace "net.mediaarea.mediainfo"
defaultConfig {
applicationId "net.mediaarea.mediainfo"
multiDexEnabled = true
Expand Down Expand Up @@ -68,6 +67,11 @@ android {
}
}

compileOptions {
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
}

def abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3, 'x86_64':4]
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK.
Expand Down Expand Up @@ -165,37 +169,35 @@ preBuild.dependsOn copyLocales

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.material:material:1.7.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha01'
implementation 'com.google.android.material:material:1.11.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha12'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.android.support:design:32.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'com.android.support:design:34.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// Android Room
implementation 'androidx.room:room-runtime:2.4.2'
implementation 'androidx.room:room-rxjava2:2.4.2'
kapt 'androidx.room:room-compiler:2.4.2'
implementation 'androidx.room:room-runtime:2.5.2'
implementation 'androidx.room:room-rxjava2:2.5.2'
kapt 'androidx.room:room-compiler:2.5.2'
//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
// Android Lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
kapt "androidx.lifecycle:lifecycle-common-java8:2.4.1"
kapt "androidx.lifecycle:lifecycle-common-java8:2.6.2"
// Legacy file picker
implementation 'com.github.angads25:filepicker:1.1.1'
// Google Billing
implementation "com.android.billingclient:billing:5.0.0"
implementation "com.android.billingclient:billing-ktx:5.0.0"
implementation "com.android.billingclient:billing:6.0.1"
implementation "com.android.billingclient:billing-ktx:6.0.1"
// KotlinX Coroutines
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
// Locales manager
implementation 'com.github.YarikSOffice:lingver:1.2.1'
}
4 changes: 2 additions & 2 deletions Source/GUI/Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
be found in the License.html file in the root of the source tree.
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="net.mediaarea.mediainfo">
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand All @@ -26,6 +25,7 @@
android:name=".ReportListActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:launchMode="singleInstance"
android:configChanges="locale|layoutDirection"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,32 @@ import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.net.Uri
import android.content.Intent

import kotlinx.android.synthetic.main.activity_about.*
import net.mediaarea.mediainfo.databinding.ActivityAboutBinding

class AboutActivity : AppCompatActivity() {
private lateinit var activityAboutBinding: ActivityAboutBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_about)
setSupportActionBar(toolbar)

activityAboutBinding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(activityAboutBinding.root)

setSupportActionBar(activityAboutBinding.toolbar)

supportActionBar?.setDisplayHomeAsUpEnabled(true)

about_about_textview.text = about_about_textview.text.toString()
activityAboutBinding.aboutAboutTextview.text = activityAboutBinding.aboutAboutTextview.text.toString()
.replace("%MI_VERSION%", getString(R.string.app_version))
.replace("%MIL_VERSION%", Core.version)

website_btn.setOnClickListener {
activityAboutBinding.websiteBtn.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(getString(R.string.website_url))
startActivity(intent)
}

email_btn.setOnClickListener {
activityAboutBinding.emailBtn.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(getString(R.string.email_url))
startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object Core {
}
}

val ARG_REPORT_ID = "id"
const val ARG_REPORT_ID = "id"
val mi: MediaInfo = MediaInfo()
val views: MutableList<ReportView> = mutableListOf()
val version: String = mi.Option("Info_Version").replace("MediaInfoLib - v", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,43 @@

package net.mediaarea.mediainfo

import androidx.annotation.NonNull
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.ColumnInfo

@Entity(tableName = "reports")
data class Report(@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id")
@NonNull
val id: Int,
@ColumnInfo(name = "filename")
@NonNull
val filename: String,
@ColumnInfo(name = "report", typeAffinity = ColumnInfo.BLOB)
@NonNull
val report: ByteArray,
@ColumnInfo(name = "version")
@NonNull
val version: String) {
override fun toString(): String {
return filename
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Report

if (id != other.id) return false
if (filename != other.filename) return false
if (!report.contentEquals(other.report)) return false
if (version != other.version) return false

return true
}

override fun hashCode(): Int {
var result = id
result = 31 * result + filename.hashCode()
result = 31 * result + report.contentHashCode()
result = 31 * result + version.hashCode()
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import androidx.viewpager.widget.ViewPager
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import io.reactivex.android.schedulers.AndroidSchedulers

import kotlinx.android.synthetic.main.activity_report_detail.*
import net.mediaarea.mediainfo.databinding.ActivityReportDetailBinding

class ReportDetailActivity : AppCompatActivity(), ReportActivityListener {
private lateinit var activityReportDetailBinding: ActivityReportDetailBinding

private inner class PageChangeListener(private val reports: List<Report>) : ViewPager.SimpleOnPageChangeListener() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
Expand All @@ -52,8 +53,11 @@ class ReportDetailActivity : AppCompatActivity(), ReportActivityListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_report_detail)
setSupportActionBar(detail_toolbar)

activityReportDetailBinding = ActivityReportDetailBinding.inflate(layoutInflater)
setContentView(activityReportDetailBinding.root)

setSupportActionBar(activityReportDetailBinding.detailToolbar)

// Show the Up button in the action bar.
supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand All @@ -64,20 +68,20 @@ class ReportDetailActivity : AppCompatActivity(), ReportActivityListener {
}

val viewModelFactory = Injection.provideViewModelFactory(this)
reportModel = ViewModelProvider(this, viewModelFactory).get(ReportViewModel::class.java)
reportModel = ViewModelProvider(this, viewModelFactory)[ReportViewModel::class.java]

disposable.add(reportModel.getAllReports()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { reports: List<Report> ->
pager.addOnPageChangeListener(PageChangeListener(reports))
pager.adapter = PagerAdapter(supportFragmentManager, reports)
.subscribe { reports: List<Report> ->
activityReportDetailBinding.pager.addOnPageChangeListener(PageChangeListener(reports))
activityReportDetailBinding.pager.adapter = PagerAdapter(supportFragmentManager, reports)
val id = intent.getIntExtra(Core.ARG_REPORT_ID, -1)
if (id!=-1) {
val index = reports.indexOfFirst { it.id == id }
if (index!=-1) {
title = reports.elementAt(index).filename
pager.setCurrentItem(index, false)
activityReportDetailBinding.pager.setCurrentItem(index, false)
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import io.reactivex.schedulers.Schedulers
import com.github.angads25.filepicker.model.DialogConfigs
import com.github.angads25.filepicker.model.DialogProperties
import com.github.angads25.filepicker.view.FilePickerDialog
import net.mediaarea.mediainfo.databinding.ReportDetailBinding

import kotlinx.android.synthetic.main.report_detail.view.*

class ReportDetailFragment : Fragment() {
companion object {
Expand All @@ -42,6 +42,7 @@ class ReportDetailFragment : Fragment() {
private val disposable: CompositeDisposable = CompositeDisposable()
private lateinit var activityListener: ReportActivityListener
private var sharedPreferences: SharedPreferences? = null
private lateinit var reportDetailBinding: ReportDetailBinding
private var view: String = "HTML"
var id: Int? = null

Expand All @@ -62,6 +63,8 @@ class ReportDetailFragment : Fragment() {
override fun onAttach(context: Context) {
super.onAttach(context)

reportDetailBinding = ReportDetailBinding.inflate(layoutInflater)

try {
activityListener = activity as ReportActivityListener
} catch (_: Throwable) {
Expand Down Expand Up @@ -92,8 +95,9 @@ class ReportDetailFragment : Fragment() {
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val rootView = inflater.inflate(R.layout.report_detail, container, false)
savedInstanceState: Bundle?): View {

//val rootView = inflater.inflate(R.layout.report_detail, container, false)
// Show the report
id?.let { id ->
disposable.add(activityListener.getReportViewModel().getReport(id)
Expand All @@ -114,11 +118,11 @@ class ReportDetailFragment : Fragment() {
val foreground=resources.getString(0+R.color.foreground).removeRange(1, 3)
content = content.replace("<body>", "<body style=\"background-color: ${background}; color: ${foreground};\">")

rootView.report_detail.loadDataWithBaseURL(null, content, "text/html", "utf-8", null)
reportDetailBinding.reportDetail.loadDataWithBaseURL(null, content, "text/html", "utf-8", null)
}.subscribe())
}

return rootView
return reportDetailBinding.root
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
Expand Down
Loading

0 comments on commit b4947eb

Please sign in to comment.