Skip to content

Commit

Permalink
google sucks
Browse files Browse the repository at this point in the history
  • Loading branch information
U-METAL103\103 authored and U-METAL103\103 committed Mar 31, 2024
1 parent df3bda0 commit e416ebc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 893 deletions.
80 changes: 7 additions & 73 deletions app/src/main/java/joshuatee/wx/radar/VideoRecordActivity.kt
Expand Up @@ -18,21 +18,14 @@
along with wX. If not, see <http://www.gnu.org/licenses/>.
*/
//Modded by ELY M.

package joshuatee.wx.radar

import android.Manifest
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.media.projection.MediaProjectionManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import joshuatee.wx.R
Expand All @@ -45,8 +38,6 @@ import joshuatee.wx.util.UtilityLog
abstract class VideoRecordActivity : AppCompatActivity() {

companion object {
private const val CREATE_SCREEN_CAPTURE = 4242

/** code to post/handler request for permission */
private const val REQUEST_CODE_PERM = 999
}
Expand All @@ -56,6 +47,7 @@ abstract class VideoRecordActivity : AppCompatActivity() {
lateinit var toolbarBottom: Toolbar
lateinit var objectToolbar: ObjectToolbar
lateinit var objectToolbarBottom: ObjectToolbar
private lateinit var telecineService: TelecineService

protected fun onCreate(savedInstanceState: Bundle?, layoutResId: Int, menuResId: Int?, bottomToolbar: Boolean) {
setTheme(UIPreferences.themeInt)
Expand Down Expand Up @@ -90,96 +82,38 @@ abstract class VideoRecordActivity : AppCompatActivity() {
}

protected fun checkOverlayPerms() {
UtilityLog.d("wx", "checkOverlayPerms start")
if (isStoragePermissionGranted) {
UtilityLog.d("wx", "checkOverlayPerms start, storage granted")
checkDrawOverlayPermission()
} else {
UtilityLog.d("wx", "checkOverlayPerms start, storage not granted")
}
}

private fun fireScreenCaptureIntent() {
val manager = getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
val intent = manager.createScreenCaptureIntent()
startActivityForResult(intent, CREATE_SCREEN_CAPTURE)
checkDrawOverlayPermission()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CODE_PERM) {
if (Settings.canDrawOverlays(this)) {
fireScreenCaptureIntent()
}
}
if (requestCode == CREATE_SCREEN_CAPTURE && resultCode == Activity.RESULT_OK) {
if (Build.VERSION.SDK_INT > 31) { // was 32, Android 12L is showing in crash reports
val intent = TelecineService.newIntent(this, 1, Intent())
intent.putExtra("show_distance_tool", showDistanceTool)
intent.putExtra("show_recording_tools", "false")
startService(intent)
} else {
val intent = TelecineService.newIntent(applicationContext, resultCode, data)
intent.putExtra("show_distance_tool", showDistanceTool)
intent.putExtra("show_recording_tools", "true")
startService(intent)
telecineService = TelecineService()
telecineService.start(this)
}
// draw tools only?
// val intent = TelecineService.newIntent(this, 1, Intent())
// intent.putExtra("show_distance_tool", showDistanceTool)
// intent.putExtra("show_recording_tools", "false")
// startService(intent)
}
}

private fun checkDrawOverlayPermission() {
/** check if we already have permission to draw over other apps */
if (!Settings.canDrawOverlays(this)) {
UtilityLog.d("wx", "checkDrawOverlayPermission - perm check")
/** if not construct intent to request permission */
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName"))
/** request permission via start activity for result */
startActivityForResult(intent, REQUEST_CODE_PERM)
} else {
UtilityLog.d("wx", "checkDrawOverlayPermission - fireScreenCaptureIntent")
fireScreenCaptureIntent()
telecineService = TelecineService()
telecineService.start(this)
}
}

private val isStoragePermissionGranted: Boolean
get() {
if (Build.VERSION.SDK_INT >= 33) {
return true
}
return if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
true
} else {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
false
}
}

// private val isStoragePermissionGranted: Boolean
// get() {
// return if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
// true
// } else {
// ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
// false
// }
// }

// https://developer.android.com/training/permissions/requesting.html

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
when (requestCode) {
1 -> {
// If request is cancelled, the result arrays are empty.
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
checkDrawOverlayPermission()
// permission was granted, yay! Do the
// contacts-related task you need to do.
}
}
}// other 'case' lines to check for other
}
}
}
Expand Up @@ -35,7 +35,6 @@ import joshuatee.wx.objects.PolygonWarning
import joshuatee.wx.objects.PolygonType
import joshuatee.wx.objects.PolygonWarningType
import joshuatee.wx.radar.RadarGeometry
import joshuatee.wx.telecine.SettingsTelecineActivity
import joshuatee.wx.ui.BaseActivity
import joshuatee.wx.ui.CardText
import joshuatee.wx.ui.NumberPicker
Expand All @@ -62,7 +61,6 @@ class SettingsRadarActivity : BaseActivity() {
box.addWidget(CardText(this, "Colors", SettingsColorsActivity::class.java))
box.addWidget(CardText(this, "Color Palettes (Beta)", SettingsColorPaletteListingActivity::class.java))
box.addWidget(CardText(this, "Line / Marker sizes", SettingsRadarSizesActivity::class.java))
box.addWidget(CardText(this, "Screen Recorder", SettingsTelecineActivity::class.java))
}

private fun addSwitch1() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/joshuatee/wx/settings/UIPreferences.kt
Expand Up @@ -37,7 +37,7 @@ import joshuatee.wx.util.UtilityFavorites
object UIPreferences {

// These are set in myapp still
const val TELECINE_SWITCH_SHOW_TOUCHES = false
// const val TELECINE_SWITCH_SHOW_TOUCHES = false
var telecineVideoSizePercentage = 0
var telecineSwitchShowCountdown = false
var telecineSwitchRecordingNotification = false
Expand Down Expand Up @@ -166,7 +166,7 @@ object UIPreferences {
}
tilesPerRow = Utility.readPrefInt(context, "UI_TILES_PER_ROW", tilesPerRowDefault)
themeStr = Utility.readPref(context, "THEME_BLUE", "BlackAqua")
themeInt = Utility.theme(themeStr)
themeInt = UtilityUI.theme(themeStr)
if (themeInt == R.style.MyCustomTheme_white_NOAB || themeInt == R.style.MyCustomTheme_whiter_NOAB || themeInt == R.style.MyCustomTheme_whitest_NOAB) {
textSmallThemeColor = Color.GRAY
textHighlightColor = Color.rgb(14, 71, 161)
Expand Down
60 changes: 0 additions & 60 deletions app/src/main/java/joshuatee/wx/telecine/FlashView.kt

This file was deleted.

0 comments on commit e416ebc

Please sign in to comment.