// Path: app/src/main/java/am/project/x/business/others/ftp/FtpFragmentCallback.java
// public interface FtpFragmentCallback {
// 
//     /**
//      * 切换
//      *
//      * @param legacy 是否为传统方式
//      */
//     void onSwitch(boolean legacy);
// }


import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.am.appcompat.app.Fragment;
import com.am.tool.support.utils.InputMethodUtils;
import java.util.Locale;
import am.project.x.R;
import am.project.x.business.others.ftp.FtpFragmentCallback;
import am.project.x.utils.ContextUtils;
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setHasOptionsMenu(true);
        mVPort = findViewById(R.id.advanced_edt_port);
        mVAuto = findViewById(R.id.advanced_cb_auto);
        mVUri = findViewById(R.id.advanced_btn_uri);

        mConfig = new AdvancedFtpConfig(requireContext());
        mVPort.setText(String.format(Locale.getDefault(), "%d", mConfig.getPort()));
        mVAuto.setChecked(mConfig.isAutoChangePort());
        mVUri.setText(mConfig.getUri());

        mVPort.addTextChangedListener(this);
        mVAuto.setOnCheckedChangeListener(this);
        mVUri.addTextChangedListener(this);
        findViewById(R.id.advanced_btn_open).setOnClickListener(this);
        findViewById(R.id.advanced_btn_close).setOnClickListener(this);
        mVUri.setOnClickListener(this);
    }

    @Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.menu_ftp_advanced, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.ftp_legacy) {
            final Activity activity = getActivity();
// Path: app/src/main/java/am/project/x/business/others/ftp/FtpFragmentCallback.java
// public interface FtpFragmentCallback {
// 
//     /**
//      * 切换
//      *
//      * @param legacy 是否为传统方式
//      */
//     void onSwitch(boolean legacy);
// }


// Path: app/src/main/java/am/project/x/business/others/ftp/advanced/AdvancedFragment.java
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.am.appcompat.app.Fragment;
import com.am.tool.support.utils.InputMethodUtils;
import java.util.Locale;
import am.project.x.R;
import am.project.x.business.others.ftp.FtpFragmentCallback;
import am.project.x.utils.ContextUtils;

    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setHasOptionsMenu(true);
        mVPort = findViewById(R.id.advanced_edt_port);
        mVAuto = findViewById(R.id.advanced_cb_auto);
        mVUri = findViewById(R.id.advanced_btn_uri);

        mConfig = new AdvancedFtpConfig(requireContext());
        mVPort.setText(String.format(Locale.getDefault(), "%d", mConfig.getPort()));
        mVAuto.setChecked(mConfig.isAutoChangePort());
        mVUri.setText(mConfig.getUri());

        mVPort.addTextChangedListener(this);
        mVAuto.setOnCheckedChangeListener(this);
        mVUri.addTextChangedListener(this);
        findViewById(R.id.advanced_btn_open).setOnClickListener(this);
        findViewById(R.id.advanced_btn_close).setOnClickListener(this);
        mVUri.setOnClickListener(this);
    }

    @Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.menu_ftp_advanced, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.ftp_legacy) {
            final Activity activity = getActivity();
            if (activity instanceof FtpFragmentCallback)