package ai.pai.lensman.settings;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.EditText;
import android.widget.Toast;

import ai.pai.lensman.R;
import ai.pai.lensman.activities.AboutUsActivity;
import ai.pai.lensman.activities.FeedbackActivity;
import ai.pai.lensman.activities.WebViewActivity;
import ai.pai.lensman.base.BaseActivity;
import ai.pai.lensman.utils.BoxUrlContainer;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class SettingsActivity extends BaseActivity {

    @BindView(R.id.et_box_ip)    EditText boxIPET;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        unbinder = ButterKnife.bind(this);
        boxIPET.setText(BoxUrlContainer.BOX_IP);
    }

    @OnClick(R.id.title_bar_back_layout)
    void back(){
        finish();
    }

    @OnClick(R.id.layout_about_us)
    void go2About(){
        startActivity(new Intent(this, AboutUsActivity.class));
    }

    @OnClick(R.id.layout_contact)
    void go2Contact(){
        Intent contactIntent = new Intent(this,WebViewActivity.class);
        contactIntent.putExtra("url","http://pai.ai/page/contact_us");
        contactIntent.putExtra("title",getString(R.string.contact_us));
        startActivity(contactIntent);
    }

    @OnClick(R.id.layout_feedback)
    void go2Feedback(){
        startActivity(new Intent(this, FeedbackActivity.class));
    }

    @OnClick(R.id.btn_confirm_ip)
    void resetIP(){
        BoxUrlContainer.resetIPHost( boxIPET.getText().toString());
        Toast.makeText(this,"IP已设置为"+BoxUrlContainer.BOX_IP,Toast.LENGTH_SHORT).show();
    }

}
