Search in sources :

Example 1 with MainTitleMenu

use of cn.cerc.summer.android.core.MainTitleMenu in project summer-android by cn-cerc.

the class FrmMain method upDataAggre.

/**
 * 重新添加标题类
 *
 * @param list1
 * @param list2
 */
private void upDataAggre(List<MainTitleMenu> list1, List<MainTitleMenu> list2) {
    List<MainTitleMenu> tempList = new ArrayList<MainTitleMenu>();
    for (int i = 0; i < list1.size(); i++) {
        if (list1.get(i).getLayerSign() == 3) {
            tempList.add(list1.get(i));
        }
    }
    list1.removeAll(tempList);
    list1.addAll(list2);
}
Also used : MainTitleMenu(cn.cerc.summer.android.core.MainTitleMenu) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint)

Example 2 with MainTitleMenu

use of cn.cerc.summer.android.core.MainTitleMenu in project summer-android by cn-cerc.

the class FrmMain method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 沉浸式全屏设置
    initWindows();
    setContentView(R.layout.activity_main);
    // 自动监听虚拟按键的变化,改变高度
    VisualKeyboardTool.assistActivity(findViewById(android.R.id.content));
    instance = this;
    ActivityCompat.requestPermissions(FrmMain.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION }, 0x67);
    settings = getSharedPreferences(Constans.SHARED_SETTING_TAB, MODE_PRIVATE);
    mRightMenu = new ArrayList<MainTitleMenu>();
    mTitleMenu = new ArrayList<MainTitleMenu>();
    allTitleList = new ArrayList<ArrayList<MainTitleMenu>>();
    allRightList = new ArrayList<ArrayList<MainTitleMenu>>();
    myApp = MyApp.getInstance();
    for (int i = 0; i < 6; i++) {
        allTitleList.add(new ArrayList<MainTitleMenu>());
    }
    for (int i = 0; i < 6; i++) {
        allRightList.add(new ArrayList<MainTitleMenu>());
    }
    titlePage = new ArrayList<MainTitleMenu>();
    mTitleWinMenu = new ArrayList<MainTitleMenu>();
    initData();
    InitView();
    browser.loadUrl(myApp.getStartPage());
}
Also used : MainTitleMenu(cn.cerc.summer.android.core.MainTitleMenu) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint)

Example 3 with MainTitleMenu

use of cn.cerc.summer.android.core.MainTitleMenu in project summer-android by cn-cerc.

the class FrmMain method newsWebView.

private boolean newsWebView() {
    for (int i = 0; i < 6; i++) {
        if (newsWebView[i] != null) {
            webViewState = false;
        } else {
            webViewState = true;
            classWebView = i;
            break;
        }
    }
    if (webViewState) {
        // 每次新建重新初始化数据
        initData();
        titlePage.add(new MainTitleMenu("欢迎页", false, currentUrl, 3, classWebView));
        newsWebView[classWebView] = new BrowserView(this);
        mainframe.addView(newsWebView[classWebView]);
        newsWebView[classWebView].getSettings().setTextZoom(settings.getInt(Constans.SCALE_SHAREDKEY, ScreenUtils.getScales(this, ScreenUtils.getInches(this))));
        // jsAndroid 供web端js调用标识,修改请通知web开发者
        newsWebView[classWebView].addJavascriptInterface(new JavaScriptProxy(this), "JSobj");
        newsWebView[classWebView].setWebViewClient(new MyWebViewClient());
        newsWebView[classWebView].setWebChromeClient(new WebChromeClient() {

            // For Android  > 4.1.1
            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
                openFileChooserImpl(uploadMsg);
                mUploadMessage = uploadMsg;
            }

            // For Android  > 3.0
            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
                if (mUploadMessage != null)
                    return;
                mUploadMessage = uploadMsg;
            }

            // For Android  > 5.0
            @Override
            public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
                mUploadMessageForAndroid5 = filePathCallback;
                openFileChooserImplForAndroid5(filePathCallback);
                return true;
            }

            @Override
            public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
                callback.invoke(origin, true, false);
                super.onGeolocationPermissionsShowPrompt(origin, callback);
            }

            @Override
            public void onPermissionRequest(PermissionRequest request) {
                super.onPermissionRequest(request);
            }

            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
                    progress.setProgress(newProgress, true);
                else
                    progress.setProgress(newProgress);
                super.onProgressChanged(view, newProgress);
            }

            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
            }

            @Override
            public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
                super.onReceivedTouchIconUrl(view, url, precomposed);
            }
        });
        newsWebView[classWebView].setOnKeyListener(new View.OnKeyListener() {

            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if ((keyCode == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_UP) {
                    if (is_exit) {
                        Intent home = new Intent(Intent.ACTION_MAIN);
                        home.addCategory(Intent.CATEGORY_HOME);
                        startActivity(home);
                    } else {
                        if (newsWebView[classWebView].canGoBack())
                            // 返回键退回
                            newsWebView[classWebView].goBack();
                        else
                            finish();
                    }
                    return true;
                } else
                    return false;
            }
        });
    } else {
        Toast.makeText(this, "已达到新窗口上限", Toast.LENGTH_SHORT).show();
    }
    return webViewState;
}
Also used : PermissionRequest(android.webkit.PermissionRequest) GeolocationPermissions(android.webkit.GeolocationPermissions) MainTitleMenu(cn.cerc.summer.android.core.MainTitleMenu) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri) ImageView(android.widget.ImageView) View(android.view.View) DragPointView(cn.cerc.summer.android.forms.view.DragPointView) WebView(android.webkit.WebView) BrowserView(cn.cerc.summer.android.forms.view.BrowserView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) KeyEvent(android.view.KeyEvent) WebChromeClient(android.webkit.WebChromeClient) BrowserView(cn.cerc.summer.android.forms.view.BrowserView) WebView(android.webkit.WebView)

Example 4 with MainTitleMenu

use of cn.cerc.summer.android.core.MainTitleMenu in project summer-android by cn-cerc.

the class FrmMain method onClick.

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.imgBack:
            browser.goBack();
            break;
        case R.id.imgMore:
            initPopWindow();
            mpopWindow.showAsDropDown(boxTitle);
            mpopWindow.show(lblTitle);
            break;
        case R.id.lblTitle:
            // 标题菜单
            if (titlePage.size() > 1) {
                if (mTitleMenu.get(1).getName().equals("关闭页面")) {
                } else {
                    mTitleMenu.add(1, new MainTitleMenu("关闭页面", false, "", 1, classWebView));
                }
            } else {
                for (int i = 0; i < mTitleMenu.size(); i++) {
                    if (mTitleMenu.get(i).getName().equals("关闭页面")) {
                        mTitleMenu.remove(i);
                        break;
                    }
                }
            }
            initTitlePopWindow();
            mTitlePopWindow.showAsDropDown(boxTitle);
            mTitlePopWindow.show(view);
            break;
        case R.id.btn_reload:
            // 重新加载
            browser.reload();
            break;
        default:
            break;
    }
}
Also used : MainTitleMenu(cn.cerc.summer.android.core.MainTitleMenu) SuppressLint(android.annotation.SuppressLint)

Example 5 with MainTitleMenu

use of cn.cerc.summer.android.core.MainTitleMenu in project summer-android by cn-cerc.

the class FrmMain method initData.

/**
 * 固定数据初始化
 */
private void initData() {
    mTitleMenu.clear();
    mRightMenu.clear();
    // 设置初始化数据
    mTitleMenu.add(new MainTitleMenu("返回首页", false, myApp.getStartPage(), 1, classWebView));
    mTitleMenu.add(new MainTitleMenu("新建窗口", false, "", 1, classWebView));
    mRightMenu.add(new MainTitleMenu("设置", false, "", 1, ""));
    mRightMenu.add(new MainTitleMenu("刷新", false, "", 1, ""));
    // TODO 临时扫一扫
    // mRightMenu.add(new MainTitleMenu("扫一扫", true, "", 1));
    mRightMenu.add(new MainTitleMenu("退出系统", true, "", 1, ""));
}
Also used : MainTitleMenu(cn.cerc.summer.android.core.MainTitleMenu)

Aggregations

MainTitleMenu (cn.cerc.summer.android.core.MainTitleMenu)9 SuppressLint (android.annotation.SuppressLint)5 ArrayList (java.util.ArrayList)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 GeolocationPermissions (android.webkit.GeolocationPermissions)1 PermissionRequest (android.webkit.PermissionRequest)1 WebChromeClient (android.webkit.WebChromeClient)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BrowserView (cn.cerc.summer.android.forms.view.BrowserView)1 DragPointView (cn.cerc.summer.android.forms.view.DragPointView)1