新建笔记 重命名

private void newnote() {
    final Intent intent = new Intent(this, PaintNoteActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    View popuView = View.inflate(this, R.layout.item_createnote, null);
    final PopupWindow popupWindow = new PopupWindow(popuView, 560, 290);
    popupWindow.setBackgroundDrawable(new ColorDrawable());
    popupWindow.setFocusable(true);
    popupWindow.setAnimationStyle(R.style.PopuAnim);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(mVpContainer, Gravity.CENTER, 0, 0);
    long ti = System.currentTimeMillis();
    String dirpath = Constants.NOTEPATH + FileUtils.getTime5(ti) + "-" + FileUtils.getCurrentTime(ti + "");
    final String dirname = FileUtils.getSplit(dirpath, 5);
    final EditText edit = (EditText) popuView.findViewById(R.id.cnote_newname);
    InputMethodManager imm = (InputMethodManager) edit.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
    edit.setText(dirname);
    popuView.findViewById(R.id.cnote_blank).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            createNewJson(newdirpath, neweditpath, 0);
            intent.putExtra("backgroundtype", 0);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        }
    });
    popuView.findViewById(R.id.cnote_horizon).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            intent.putExtra("backgroundtype", 1);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        }
    });
    popuView.findViewById(R.id.cnote_vertical).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            createNewJson(newdirpath, neweditpath, 1);
            intent.putExtra("backgroundtype", 1);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        }
    });
    popuView.findViewById(R.id.cnote_grid).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            createNewJson(newdirpath, neweditpath, 2);
            intent.putExtra("backgroundtype", 2);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        }
    });
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="560dp"
              android:layout_height="290dp"
              android:background="@drawable/button"
              android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:paddingLeft="6dp"
        android:text="Create new note"
        android:textSize="24dp"
        android:textStyle="bold"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="Please input a note name"/>

        <EditText
            android:id="@+id/cnote_newname"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_weight="1"
            android:background="@drawable/button"
            android:selectAllOnFocus="true"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="请选择背景样式"/>

        <RadioGroup
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center_horizontal"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/cnote_blank"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_blank"
                android:button="@null"
                android:scaleType="center"
                android:text="空白"/>

            <RadioButton
                android:id="@+id/cnote_vertical"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_line"
                android:button="@null"
                android:scaleType="center"
                android:text="条纹1"/>

            <RadioButton
                android:id="@+id/cnote_horizon"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_line"
                android:button="@null"
                android:scaleType="center"
                android:text="条纹2"/>

            <RadioButton
                android:id="@+id/cnote_grid"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_rect"
                android:button="@null"
                android:scaleType="center"
                android:text="米格"/>
        </RadioGroup>
    </LinearLayout>

</LinearLayout>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值