package ai.pai.lensman.activities;

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

import ai.pai.lensman.R;
import ai.pai.lensman.base.BaseActivity;
import ai.pai.lensman.service.UpgradeService;
import ai.pai.lensman.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.about_us);
        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);
    }

    @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:
                Toast.makeText(this,R.string.check_update_processing,Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(this, UpgradeService.class);
                intent.putExtra("isMuteUpdate",false);
                startService(intent);
                break;
            default:
                break;
        }
    }
}
