Skip to content

Commit

Permalink
Merge pull request #3 from zaheeraws/androidx-updata
Browse files Browse the repository at this point in the history
Androidx update
  • Loading branch information
reitblatt authored Nov 2, 2023
2 parents 2320aa6 + c36aec1 commit db72692
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 31 deletions.
12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 31
defaultConfig {
applicationId "nl.rogro82.pipup"
minSdkVersion 24
targetSdkVersion 28
versionCode 6
versionName "0.1.5-beta"
targetSdkVersion 31
versionCode 1
versionName "1"
}
buildTypes {
release {
Expand All @@ -24,13 +24,13 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:leanback-v17:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'

implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.+'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.+'

implementation 'org.nanohttpd:nanohttpd:2.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:exported="true"
android:banner="@drawable/ic_banner"
android:icon="@drawable/ic_banner"
android:logo="@drawable/ic_banner"
Expand Down
31 changes: 29 additions & 2 deletions app/src/main/java/nl/rogro82/pipup/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@ package nl.rogro82.pipup

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.View
import android.widget.TextView
import androidx.annotation.Nullable
import androidx.annotation.RequiresApi
import nl.rogro82.pipup.Utils.getIpAddress

class MainActivity : Activity() {

class MainActivity : Activity() {
var ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE = 5469
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

//Ask permission to draw over other apps
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
askPermission();
}
// start service in foreground

val textViewConnection = findViewById<TextView>(R.id.textViewServerAddress)
Expand Down Expand Up @@ -59,4 +67,23 @@ class MainActivity : Activity() {
startService(serviceIntent)
}
}

private fun askPermission() {

val intent =
Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName"))
startActivityForResult(intent, ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE)
}

@RequiresApi(api = Build.VERSION_CODES.M)
override fun onActivityResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE) {
if (!Settings.canDrawOverlays(this)) {
askPermission()
}
}
}


}
6 changes: 3 additions & 3 deletions app/src/main/java/nl/rogro82/pipup/PiPupService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.graphics.PixelFormat
import android.os.Build
import android.os.Handler
import android.os.IBinder
import android.support.v4.app.NotificationCompat
import androidx.core.app.NotificationCompat
import android.util.Log
import android.view.Gravity
import android.view.View
Expand All @@ -33,7 +33,7 @@ class PiPupService : Service(), WebServer.Handler {

val pendingIntent = PendingIntent.getActivity(
this, 0,
Intent(this, MainActivity::class.java), 0
Intent(this, MainActivity::class.java), PendingIntent.FLAG_IMMUTABLE
)

val mBuilder = NotificationCompat.Builder(this, "service_channel")
Expand Down Expand Up @@ -269,7 +269,7 @@ class PiPupService : Service(), WebServer.Handler {


} catch (ex: Throwable) {
Log.e(LOG_TAG, ex.message)
Log.e(LOG_TAG, ex.message.toString())
InvalidRequest(ex.message)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/nl/rogro82/pipup/Receiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
import android.support.v4.content.ContextCompat.startForegroundService
import androidx.core.content.ContextCompat.startForegroundService

class Receiver : BroadcastReceiver() {

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
Expand Down Expand Up @@ -40,4 +40,4 @@
app:layout_constraintEnd_toEndOf="@+id/textViewConnection"
android:layout_marginTop="4dp" app:layout_constraintTop_toBottomOf="@+id/textViewConnection"
app:layout_constraintStart_toStartOf="@+id/textViewConnection"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.31'
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
Expand All @@ -19,7 +18,6 @@ allprojects {
repositories {
google()
jcenter()

}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ Form-fields:
| 3 | BottomLeft |
| 4 | Center |

Color-properties are in `[AA]RRGGBB` where the alpha channel is optional e.g. #FFFFFF or #CCFFFFFF
Color-properties are in `[AA]RRGGBB` where the alpha channel is optional e.g. #FFFFFF or #CCFFFFFF


### Contributors:
- Zaheer <[email protected]>

0 comments on commit db72692

Please sign in to comment.