package com.wisape.android.activity;

import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.webkit.JavascriptInterface;

import com.wisape.android.util.EnvironmentUtils;

/**
 * Created by LeiGuoting on 7/7/15.
 */
public class StoryTemplateActivity extends AbsCordovaActivity {
    private static final String START_URL = "file:///android_asset/www/views/editor_index.html";

    public static void launch(Fragment fragment, int requestCode){
        Intent intent = new Intent(fragment.getActivity().getApplicationContext(), StoryTemplateActivity.class);
        fragment.startActivityForResult(intent, requestCode);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_FILE).encodedPath(EnvironmentUtils.getAppDataDirectory().getPath()).appendEncodedPath("template_light/index.html").build();
        String url = uri.toString();
        Log.d(TAG, "#onCreate url:" + url);
        loadUrl(START_URL);
    }

    public void invodeJavascriptTest(){
        appView.loadUrl("javascript:test2()");
    }

    /**
     * JSýӿڣڱStory
     * @param storyId id
     * @param html storyhtml
     * @param paths ļʵ··()
     */
    @JavascriptInterface
    public boolean save(int storyId, String html, String[] paths){
        return false;
    }

    /**
     * ȡӦIDĹĿ¼·
     * @param storyId Storyģid
     * @return Ŀ¼·
     */
    public String getStoryPath(int storyId){
        return null;
    }

    /**
     * ȡӦIDģĿ¼·
     * @param stageId ģid
     * @return ģĿ¼·
     */
    public String getStagePath(int stageId){
        return null;
    }

    /**
     * ȡHTMLļ
     * @param path ļ·
     * @return ļ
     */
    public String read(String path){
        return null;
    }

    /**
     *ûԴļӲ·滻ļ·
     * @param sourcePath Դ·
     * @param destPath 滻·
     */
    public boolean replaceFile(String sourcePath,String destPath){
        return false;
    }

    /**
     * JSýӿڣ
     * @param type
     * @param id
     * @return
     */
    public Object start(int type, int id){
        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}

@@ -220,51 +220,8 @@
 Log;
-%0Aimport android.webkit.JavascriptInterface;
 %0A%0Aim
@@ -1239,1017 +1239,8 @@
  %7D%0A%0A
-    /**%0A     * JS%C3%BD%D3%BF%DA%A3%DA%B1Story%0A     * @param storyId id%0A     * @param html storyhtml%0A     * @param paths %C4%BC%CA%B5%C2%B7%C2%B7()%0A     */%0A    @JavascriptInterface%0A    public boolean save(int storyId, String html, String%5B%5D paths)%7B%0A        return false;%0A    %7D%0A%0A    /**%0A     * %C8%A1%D3%A6ID%C4%B9%C4%BF%C2%BC%C2%B7%0A     * @param storyId Story%C4%A3id%0A     * @return %C4%BF%C2%BC%C2%B7%0A     */%0A    public String getStoryPath(int storyId)%7B%0A        return null;%0A    %7D%0A%0A    /**%0A     * %C8%A1%D3%A6ID%C4%A3%C4%BF%C2%BC%C2%B7%0A     * @param stageId %C4%A3id%0A     * @return %C4%A3%C4%BF%C2%BC%C2%B7%0A     */%0A    public String getStagePath(int stageId)%7B%0A        return null;%0A    %7D%0A%0A    /**%0A     * %C8%A1HTML%C4%BC%0A     * @param path %C4%BC%C2%B7%0A     * @return %C4%BC%0A     */%0A    public String read(String path)%7B%0A        return null;%0A    %7D%0A%0A    /**%0A     *%C3%BB%D4%B4%C4%BC%D3%B2%C2%B7%E6%BB%BB%C4%BC%C2%B7%0A     * @param sourcePath %D4%B4%C2%B7%0A     * @param destPath %E6%BB%BB%C2%B7%0A     */%0A    public boolean replaceFile(String sourcePath,String destPath)%7B%0A        return false;%0A    %7D%0A%0A    /**%0A     * JS%C3%BD%D3%BF%DA%A3%0A     * @param type%0A     * @param id%0A     * @return%0A     */%0A    public Object start(int type, int id)%7B%0A        return null;%0A    %7D%0A%0A
     

remove code