add new function : show length of the notes

This commit is contained in:
ziji Wu 2019-10-18 00:07:38 +08:00
parent bad253c27f
commit c415aae208
19 changed files with 36 additions and 4 deletions

View File

@ -1,4 +1,4 @@
#Thu Oct 17 22:05:25 CST 2019 #Fri Oct 18 00:06:03 CST 2019
base.0=C\:\\Project\\minote\\src\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\out\\classes.dex base.0=C\:\\Project\\minote\\src\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\out\\classes.dex
path.0=classes.dex path.0=classes.dex
renamed.0=classes.dex renamed.0=classes.dex

View File

@ -30,9 +30,11 @@ import android.content.SharedPreferences;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan; import android.text.style.BackgroundColorSpan;
import android.util.Log; import android.util.Log;
@ -161,6 +163,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//保存便签字符数量 //保存便签字符数量
private int mNoteLength; private int mNoteLength;
private String mFormateDataTime;
//记录默认字体大小 //记录默认字体大小
private static final String PREFERENCE_FONT_SIZE = "pref_font_size"; private static final String PREFERENCE_FONT_SIZE = "pref_font_size";
@ -297,7 +301,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@ -326,10 +329,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//获取已保存便签的字符数 //获取已保存便签的字符数
mNoteLength = mNoteEditor.getText().toString().length(); mNoteLength = mNoteEditor.getText().toString().length();
mNoteHeaderHolder.tvModified.setText(DateUtils.formatDateTime(this, mFormateDataTime = DateUtils.formatDateTime(this,
mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_SHOW_YEAR) | DateUtils.FORMAT_SHOW_YEAR);
mNoteHeaderHolder.tvModified.setText(mFormateDataTime
+ space_after_title_time +getResources().getString(R.string.note_length) + " : " + space_after_title_time +getResources().getString(R.string.note_length) + " : "
+ mNoteLength); + mNoteLength);
@ -416,7 +421,34 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mFormateDataTime = DateUtils.formatDateTime(this,
mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_SHOW_YEAR);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view); mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
mNoteEditor.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(count == 0){
mNoteLength -= before;
}else{
mNoteLength += count;
}
mNoteHeaderHolder.tvModified.setText(mFormateDataTime
+ space_after_title_time +getResources().getString(R.string.note_length) + " : "
+ mNoteLength);
}
@Override
public void afterTextChanged(Editable s) {
}
});
mNoteLength = mNoteEditor.getText().toString().length(); mNoteLength = mNoteEditor.getText().toString().length();
mNoteEditorPanel = findViewById(R.id.sv_note_edit); mNoteEditorPanel = findViewById(R.id.sv_note_edit);
mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector);