package dev.nachlakes.hevybridge;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle b) {
        super.onCreate(b);
        LinearLayout root = new LinearLayout(this);
        root.setOrientation(LinearLayout.VERTICAL);
        root.setPadding(40, 80, 40, 40);

        TextView title = new TextView(this);
        title.setText("Hevy Bridge\n\nEnable Accessibility Service, then keep Hevy open during workout. Fitbit companion talks to http://127.0.0.1:18090");
        title.setTextSize(18);
        root.addView(title);

        Button settings = new Button(this);
        settings.setText("Open Accessibility Settings");
        settings.setOnClickListener(v -> startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)));
        root.addView(settings);

        Button hevy = new Button(this);
        hevy.setText("Open Hevy");
        hevy.setOnClickListener(v -> {
            Intent launch = getPackageManager().getLaunchIntentForPackage("com.hevy");
            if (launch != null) startActivity(launch);
        });
        root.addView(hevy);

        setContentView(root);
    }
}
