Merge pull request '合并显示字数、修改字体的功能' (#8) from dingzijian_branch into develop

pull/9/head
pz4kybsvg 3 years ago
commit 9b2cfa5299

@ -16,6 +16,8 @@
package net.micode.notes.ui; package net.micode.notes.ui;
import static net.micode.notes.R.drawable.list_background;
import android.app.Activity; import android.app.Activity;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -27,13 +29,19 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
//import android.support.v7.app.AppCompatActivity; //import android.support.v7.app.AppCompatActivity;
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;
@ -52,7 +60,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
//维护 添加read //维护_丁梓坚_朗读
//import android.support.v7.app.AppCompatActivity; //import android.support.v7.app.AppCompatActivity;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener; import android.speech.tts.TextToSpeech.OnInitListener;
@ -72,6 +80,9 @@ import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
import net.micode.notes.widget.NoteWidgetProvider_2x; import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x; import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
@ -156,9 +167,12 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
//维护 添加Read //维护_丁梓坚_朗读
private TextToSpeech mNoteRead; private TextToSpeech mNoteRead;
//维护_王京
CharSequence tmp;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -168,9 +182,9 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
finish(); finish();
return; return;
} }
initResources(); initResources();
} }
/** /**
* Current activity may be killed when the memory is low. Once it is killed, for another time * Current activity may be killed when the memory is low. Once it is killed, for another time
* user load this activity, we should restore the former state * user load this activity, we should restore the former state
@ -406,7 +420,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
} }
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list); mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
//维护 添加Read //维护_丁梓坚_朗读
mNoteRead = new TextToSpeech(this, new OnInitListener() mNoteRead = new TextToSpeech(this, new OnInitListener()
{ {
@Override @Override
@ -426,9 +440,55 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
} }
} }
); );
//维护_王京
EditText e = findViewById(R.id.note_edit_view);
//CharSequence tmp;
e.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
tmp = charSequence;
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
//NoteEditText noteEditText = (NoteEditText) findViewById(R.id.note_edit_view); //获取当前的edit
//Editable edit = noteEditText.getText();//1.获取text
String s = editable.toString(); //2.将note内容转换为字符串
int len = editable.length(); //内容的长度
for (int i = 0; i < len; i++) {
for (int j = i; j < len; j++) {
Log.i(TAG, s);
String img_fragment = s.substring(i, j + 1); //img_fragment关于图片路径的片段
if (img_fragment.length() > 15 && img_fragment.endsWith("[/local]") && img_fragment.startsWith("[local]")) {
String b = s.substring(0, i);
String c = s.substring(j + 1, len);
s = b + c;
len = len + i - j - 1;
}
}
/* (int k = 0; k < len; k++) {
for (int j = k; j < len; j++) {
String img_fragment = s.substring(k, j + 1); //img_fragment关于图片路径的片段
if (img_fragment.length() > 15 && img_fragment.endsWith("[/local]") && img_fragment.startsWith("[local]")) {
String b = s.substring(0,k);
String c = s.substring(j+1,len);
s = b + c;
len = len + k - j - 16;
}
}
}*/
}
TextView length = findViewById(R.id.length);
length.setText("字符数:" + operateText(s).length());
}
});
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
@ -579,17 +639,87 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
case R.id.menu_delete_remind: case R.id.menu_delete_remind:
mWorkingNote.setAlertDate(0, false); mWorkingNote.setAlertDate(0, false);
break; break;
//维护 添加read //维护_丁梓坚_朗读
case R.id.menu_read: case R.id.menu_read:
noteRead(); noteRead();
break; break;
//维护_刘彦辰
case R.id.menu_font_select:
showSingleAlertDiglog();
break;
default: default:
break; break;
} }
return true; return true;
} }
//维护 添加read //维护_刘彦辰
public void showSingleAlertDiglog(){
final String[] items = {"默认-普通","默认-非衬线","默认-衬线","默认-等宽","仿宋","黑体","楷体","姚体","隶书","行楷","新魏","中宋"};
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder.setTitle("选择字体");
alertBuilder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i) {
case 0:
mNoteEditor.setTypeface(Typeface.DEFAULT);
break;
case 1:
mNoteEditor.setTypeface(Typeface.SANS_SERIF);
break;
case 2:
mNoteEditor.setTypeface(Typeface.SERIF);
break;
case 3:
mNoteEditor.setTypeface(Typeface.MONOSPACE);
break;
case 4:
Typeface typeface0 = Typeface.createFromAsset(getAssets(), "font/simfang.ttf");
mNoteEditor.setTypeface(typeface0);
break;
case 5:
Typeface typeface1 = Typeface.createFromAsset(getAssets(), "font/simhei.ttf");
mNoteEditor.setTypeface(typeface1);
break;
case 6:
Typeface typeface2 = Typeface.createFromAsset(getAssets(), "font/simkai.ttf");
mNoteEditor.setTypeface(typeface2);
break;
case 7:
Typeface typeface3 = Typeface.createFromAsset(getAssets(), "font/FZYTK.TTF");
mNoteEditor.setTypeface(typeface3);
break;
case 8:
Typeface typeface4 = Typeface.createFromAsset(getAssets(), "font/STLITI.TTF");
mNoteEditor.setTypeface(typeface4);
break;
case 9:
Typeface typeface5 = Typeface.createFromAsset(getAssets(), "font/STXINGKA.TTF");
mNoteEditor.setTypeface(typeface5);
break;
case 10:
Typeface typeface6 = Typeface.createFromAsset(getAssets(), "font/STXINWEI.TTF");
mNoteEditor.setTypeface(typeface6);
break;
case 11:
Typeface typeface7 = Typeface.createFromAsset(getAssets(), "font/STZHONGS.TTF");
mNoteEditor.setTypeface(typeface7);
break;
}
Toast.makeText(NoteEditActivity.this, items[i], Toast.LENGTH_SHORT).show();
alertDialog2.dismiss();
}
});
alertDialog2 = alertBuilder.create();
alertDialog2.show();
}
//维护_刘彦辰
private AlertDialog alertDialog2;
//维护_丁梓坚_朗读
private void noteRead(){ private void noteRead(){
mNoteRead.speak(mNoteEditor.getText().toString(),TextToSpeech.QUEUE_FLUSH,null); mNoteRead.speak(mNoteEditor.getText().toString(),TextToSpeech.QUEUE_FLUSH,null);
} }
@ -911,4 +1041,34 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
private void showToast(int resId, int duration) { private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show(); Toast.makeText(this, resId, duration).show();
} }
//维护_王京
public void xianshi() {
NoteEditText noteEditText = (NoteEditText) findViewById(R.id.note_edit_view); //获取当前的edit
Editable editable = noteEditText.getText();//1.获取text
String s = editable.toString(); //2.将note内容转换为字符串
int len = editable.length(); //内容的长度
for (int i = 0; i < len; i++) {
for (int j = i; j < len; j++) {
String img_fragment = s.substring(i, j + 1);
if (img_fragment.length() > 15 && img_fragment.endsWith("[/local]") && img_fragment.startsWith("[local]")) {
String b = s.substring(0, i);
String c = s.substring(j + 1, len);
s = b + c;
//Log.i(TAG, s);
len = len + i - j - 1;
}
}
}
TextView length = findViewById(R.id.length);
length.setText("字符数:" + s.length());
}
public String operateText(String str){
String dest = "";
Pattern p = Pattern.compile("\\s*|t|r|n");
Matcher m = p.matcher(str);
dest = m.replaceAll("");
return dest;
}
} }

@ -34,6 +34,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
//维护_丁梓坚_个性化背景_裁剪图片
public class UCropPictureActivity extends AppCompatActivity { public class UCropPictureActivity extends AppCompatActivity {
Button btnTest; Button btnTest;

@ -10,6 +10,7 @@ import android.app.Activity;
* An example full-screen activity that shows and hides the system UI (i.e. * An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction. * status bar and navigation/system bar) with user interaction.
*/ */
//维护_丁梓坚_欢迎界面
public class WelcomeActivity extends Activity { public class WelcomeActivity extends Activity {
Handler mHandler=new Handler(); Handler mHandler=new Handler();

@ -55,7 +55,14 @@
android:layout_marginLeft="2dip" android:layout_marginLeft="2dip"
android:layout_marginRight="8dip" android:layout_marginRight="8dip"
android:textAppearance="@style/TextAppearanceSecondaryItem" /> android:textAppearance="@style/TextAppearanceSecondaryItem" />
<TextView
android:id="@+id/length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dip"
android:layout_marginRight="8dip"
android:textAppearance="@style/TextAppearanceSecondaryItem" />
<ImageButton <ImageButton
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

@ -52,4 +52,7 @@
<item <item
android:id="@+id/menu_read" android:id="@+id/menu_read"
android:title="Read" /> android:title="Read" />
<item
android:id="@+id/menu_font_select"
android:title="@string/menu_font_style" />
</menu> </menu>

@ -123,4 +123,5 @@
<item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 条符合“<xliff:g id="SEARCH">%2$s</xliff:g>”的搜索结果</item> <item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 条符合“<xliff:g id="SEARCH">%2$s</xliff:g>”的搜索结果</item>
</plurals> </plurals>
<string name="menu_font_style">设置字体</string>
</resources> </resources>

@ -124,4 +124,5 @@
<item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 條符合”<xliff:g id="SEARCH">%2$s</xliff:g>“的搜尋結果</item> <item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 條符合”<xliff:g id="SEARCH">%2$s</xliff:g>“的搜尋結果</item>
</plurals> </plurals>
<string name="menu_font_style">设置字体</string>
</resources> </resources>

@ -134,4 +134,5 @@
<string name="dummy_button">Dummy Button</string> <string name="dummy_button">Dummy Button</string>
<string name="dummy_content">DUMMY\nCONTENT</string> <string name="dummy_content">DUMMY\nCONTENT</string>
<string name="menu_font_style">Set font</string>
</resources> </resources>

Loading…
Cancel
Save