package net.qiujuer.powerback.ankey.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;

import net.qiujuer.genius.ui.Ui;
import net.qiujuer.powerback.ankey.R;
import net.qiujuer.powerback.ankey.presenter.KeyVerifyPresenter;
import net.qiujuer.powerback.ankey.presenter.view.KeyVerifyView;
import net.qiujuer.powerback.ankey.ui.SuperActivity;

public class KeyVerifyActivity extends SuperActivity implements KeyVerifyView, View.OnClickListener {
    private KeyVerifyPresenter mPresenter;
    private EditText mKey;

    public static void show(Context context) {
        Intent intent = new Intent(context, KeyVerifyActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_key_verify);
        setCenterTitle(true);

        mPresenter = new KeyVerifyPresenter(this);

        mKey = (EditText) findViewById(R.id.edit_key);
        Typeface typeface = Ui.getFont(this, "FZLanTingHeiS-L-GB-Regular.TTF");
        mKey.setTypeface(typeface);
        findViewById(R.id.btn_submit).setOnClickListener(this);
    }

    @Override
    protected String getTitleFont() {
        return "fonts/Lobster.otf";
    }

    @Override
    protected void onInflateMenu(Toolbar toolbar) {
        //toolbar.inflateMenu(R.menu.menu_key_verify);
    }

    @Override
    public String getKey() {
        return mKey.getText().toString();
    }

    @Override
    public void verifyOk() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    public void verifyError() {
        showToast("Error");
    }

    @Override
    public void needCreate() {
        Intent intent = new Intent(this, KeyCreateActivity.class);
        startActivity(intent);
    }

    @Override
    public void onClick(View v) {
        mPresenter.verify();
    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        if (item.getItemId() == R.id.action_add) {
            Intent intent = new Intent(this, KeyCreateActivity.class);
            startActivity(intent);
            return true;

        }
        return super.onMenuItemClick(item);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.checkKeyStatus();
    }
}

@@ -110,42 +110,8 @@
 nt;%0A
-import android.graphics.Typeface;%0A
 impo
@@ -620,16 +620,65 @@
 tener %7B%0A
+    private final static String KEY_CLX = %22clx%22;%0A
     priv
@@ -738,16 +738,43 @@
 xt mKey;
+%0A    private Class%3C?%3E mClx;
 %0A%0A    pu
@@ -810,24 +810,121 @@
  context) %7B%0A
+        show(context, null);%0A    %7D%0A%0A    public static void show(Context context, Class%3C?%3E clx) %7B%0A
         Inte
@@ -973,32 +973,100 @@
 ctivity.class);%0A
+        if (clx != null)%0A            intent.putExtra(KEY_CLX, clx);%0A
         context.
@@ -1291,24 +1291,64 @@
 tle(true);%0A%0A
+        initBound();%0A        initUi();%0A%0A
         mPre
@@ -1386,16 +1386,189 @@
 (this);%0A
+    %7D%0A%0A    private void initBound() %7B%0A        Intent intent = getIntent();%0A        mClx = (Class%3C?%3E) intent.getSerializableExtra(KEY_CLX);%0A    %7D%0A%0A    private void initUi() %7B
 %0A       
@@ -1627,28 +1627,25 @@
     
-Typeface t
+mKey.setT
 ypeface
- = 
+(
 Ui.g
@@ -1694,43 +1694,8 @@
 TF%22)
-;%0A        mKey.setTypeface(typeface
 );%0A 
@@ -2118,24 +2118,56 @@
 erifyOk() %7B%0A
+        if (mClx != null) %7B%0A    
         Inte
@@ -2199,29 +2199,19 @@
 is, 
-MainActivity.class);%0A
+mClx);%0A    
     
@@ -2229,32 +2229,42 @@
 tivity(intent);%0A
+        %7D%0A
         finish()

Change key skip method