package com.dspread.pos.ui.screensaver;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.VideoView;

import androidx.appcompat.app.AppCompatActivity;

import com.dspread.pos.common.manager.ScreensaverManager;
import com.dspread.pos.ui.main.MainActivity;
import com.dspread.pos_android_app.R;

public class ScreensaverActivity extends AppCompatActivity {
    //    private VideoView videoView;
    private ImageView imageView;
    private ScreensaverManager screensaverManager;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        screensaverManager = new ScreensaverManager(this);

        // 👇 Add this code to hide both bars
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION  // Hides back/home buttons
                        | View.SYSTEM_UI_FLAG_FULLSCREEN       // Hides status bar (clock, battery)
        );

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        setContentView(R.layout.activity_screensaver);

        imageView = findViewById(R.id.screensaverImage);
        imageView.setImageResource(R.drawable.am_mulberry_wallpaper_m60);

//        videoView = findViewById(R.id.videoView);
        // Set video URI (place your video in res/raw folder)
//        String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.alfabankwallpaper;
//        videoView.setVideoURI(Uri.parse(videoPath));
//
//        videoView.setOnPreparedListener(mp -> {
//            mp.setLooping(true); // Loop the video
//            videoView.start();
//        });

        // Set click listener to return to MainActivity
        findViewById(android.R.id.content).setOnClickListener(v -> {
//            startActivity(new Intent(this, MainActivity.class));
            screensaverManager.resetTimer();
            finish();
        });
    }
}