src/Android/Receiver/app/src/main/java/com/example/receiver/fragments/Settings.java
<reponame>GuillaumeLandry/GMT3060-ProjetGeniepackage com.example.receiver.fragments;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.receiver.MainActivity;
import com.example.receiver.R;

public class Settings extends Fragment implements View.OnClickListener {
    private Button btnApply;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_settings, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        TextView actual = getView().findViewById(R.id.actual);
        actual.setText(MainActivity.getURL());

        btnApply = view.findViewById(R.id.btn_apply);
        btnApply.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_apply:
                EditText userInput = getView().findViewById(R.id.user_input);
                MainActivity.setURL(userInput.getText().toString());
                userInput.setText("");

                TextView actual = getView().findViewById(R.id.actual);
                actual.setText(MainActivity.getURL());
        }
    }
}