package com.ejada.hmg
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.ContentResolver
import android.media.AudioAttributes
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.os.Build
import android.view.WindowManager
import androidx.annotation.NonNull;
import com.ejada.hmg.utils.*
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterFragmentActivity() {
    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
        // Create Flutter Platform Bridge
        this.window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON)

        PlatformBridge(flutterEngine, this).create()
        OpenTokPlatformBridge(flutterEngine, this).create()

//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//            val mChannel = NotificationChannel("video_call_noti", "video call", NotificationManager.IMPORTANCE_HIGH)
//            val soundUri = Uri.parse("android.resource://" + getApplicationContext()
//                    .getPackageName() + "/" + R.raw.alert)
//            System.out.println("soundUri");
//            System.out.println("soundUri: $soundUri");
//            System.out.println("soundUri : ${soundUri.path}");
//            val att = AudioAttributes.Builder()
//                    .setUsage(AudioAttributes.USAGE_NOTIFICATION)
//                    .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
//                    .build();
//            mChannel.setSound(soundUri , att)
//            mChannel.description = "Video Call Notifications"
//            val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
//            notificationManager.createNotificationChannel(mChannel)
//        }

//        val time = timeToMillis("04:00:00", "HH:mm:ss")

    }

    override fun onResume() {
        super.onResume()
    }
}