package com.fichardu.viewshot;

import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import com.tplink.halohoop.screenshot.R;


public class MainActivity extends ActionBarActivity {

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

        final GlobalScreenshot screenshot = new GlobalScreenshot(this);
        final View viewById1 = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
        final View viewById = findViewById(R.id.main_btn);
//        final View viewById2 = findViewById(R.id.tv);
        viewById.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(!Settings.canDrawOverlays(MainActivity.this)) {
                    Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                    startActivity(intent);
                    return;
                } else {
                    //Android6.0以上
                    Toast.makeText(MainActivity.this, "Halohoop", Toast.LENGTH_SHORT).show();
//                screenshot.takeScreenshot(getWindow().getDecorView(), new Runnable() {
                    screenshot.takeScreenshot(viewById1, new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, "Halohoop", Toast.LENGTH_SHORT).show();
                        }
                    }, true, true);
                }
            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

@@ -994,24 +994,82 @@
 iew v) %7B%0D%0A%0D%0A
+                //6.0%E5%A2%9E%E5%8A%A0%E4%BA%86%E8%BF%90%E8%A1%8C%E6%97%B6%E6%9D%83%E9%99%90%EF%BC%8C%E9%9C%80%E8%A6%81%E5%8A%A8%E6%80%81%E6%A3%80%E6%B5%8B%E4%BB%A5%E4%B8%8B%E6%98%AF%E5%90%A6%E5%8F%AF%E7%94%A8%EF%BC%8C%E7%94%A8%E6%88%B7%E6%89%8B%E5%8A%A8%E5%85%81%E8%AE%B8%E7%9A%84%E6%97%B6%E5%80%99%E6%89%8D%E5%8F%AF%E7%94%A8%EF%BC%9B%0D%0A
             

add comments