package ai.pai.client.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import ai.pai.client.R;
import ai.pai.client.services.UpgradeService;
import ai.pai.client.utils.SystemUtils;

/**
 * Created by chengzhenyu on 2016/3/1.
 */
public class AboutUsActivity extends BaseActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        SystemUtils.setImmerseLayout(this,findViewById(R.id.title_layout));
        TextView title = (TextView)findViewById(R.id.title_bar_middle_txt);
        title.setText(R.string.slide_about_us);
        TextView curVersionText = (TextView)findViewById(R.id.tv_cur_version);
        try {
            curVersionText.setText( "v"+getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
        }catch (Exception e){
            e.printStackTrace();
        }
        findViewById(R.id.title_bar_back_layout).setOnClickListener(this);
        findViewById(R.id.title_bar_option_layout).setVisibility(View.INVISIBLE);
        findViewById(R.id.layout_about_declare).setOnClickListener(this);
        findViewById(R.id.layout_check_update).setOnClickListener(this);
        findViewById(R.id.layout_contact_us).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.title_bar_back_layout:
                finish();
                break;
            case R.id.layout_about_declare:
                Intent declareIntent = new Intent(this,WebViewActivity.class);
                declareIntent.putExtra("url","http://pai.ai/page/user_agreement");
                declareIntent.putExtra("title",getString(R.string.contract));
                startActivity(declareIntent);
                break;
            case R.id.layout_check_update:
                Intent intent = new Intent(this, UpgradeService.class);
                intent.putExtra("isMuteUpdate",false);
                startService(intent);
                break;
            case R.id.layout_contact_us:
                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);
                break;
            default:
                break;
        }
    }
}
