|
|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
package net.micode.notes.ui;
|
|
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
@ -30,16 +29,11 @@ import android.content.Context;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
|
import android.graphics.Paint;
|
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
|
import android.location.Address;
|
|
|
|
|
import android.location.Geocoder;
|
|
|
|
|
import android.location.Location;
|
|
|
|
|
import android.location.LocationListener;
|
|
|
|
|
import android.location.LocationManager;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
@ -74,8 +68,6 @@ import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
|
|
|
|
|
|
import android.speech.tts.TextToSpeech;
|
|
|
|
|
import android.speech.tts.TextToSpeech.OnInitListener;
|
|
|
|
|
|
|
|
|
@ -94,29 +86,21 @@ import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
|
|
|
|
|
import net.micode.notes.widget.NoteWidgetProvider_2x;
|
|
|
|
|
import net.micode.notes.widget.NoteWidgetProvider_4x;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
//import android.support.v13.app.ActivityCompat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
NoteSettingChangedListener, OnTextViewChangeListener {
|
|
|
|
|
public static final int LOCATION_CODE = 301;
|
|
|
|
|
private LocationManager locationManager;
|
|
|
|
|
private String locationProvider = null;
|
|
|
|
|
private static class HeadViewHolder {
|
|
|
|
|
public TextView tvModified;
|
|
|
|
|
|
|
|
|
@ -130,7 +114,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
|
|
|
|
|
public ImageButton note_Read;
|
|
|
|
|
|
|
|
|
|
public ImageButton note_revoke;
|
|
|
|
|
private static ImageButton note_revoke;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
|
|
|
|
@ -177,8 +161,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
|
|
|
|
|
private View mNoteBgColorSelector;
|
|
|
|
|
|
|
|
|
|
//private View mDraw = findViewById(R.id.img);
|
|
|
|
|
|
|
|
|
|
private View mFontSizeSelector;
|
|
|
|
|
|
|
|
|
|
private EditText mNoteEditor;
|
|
|
|
@ -187,8 +169,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
|
|
|
|
|
private View mNoteEditorPanel;
|
|
|
|
|
|
|
|
|
|
//private final static int REQUEST_CODE_NEW_NODE = 103;
|
|
|
|
|
|
|
|
|
|
private WorkingNote mWorkingNote;
|
|
|
|
|
|
|
|
|
|
private boolean mIsRevort;
|
|
|
|
@ -486,7 +466,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
int result = mTTS.setLanguage(Locale.US);
|
|
|
|
|
if (result != TextToSpeech.LANG_COUNTRY_AVAILABLE
|
|
|
|
|
&& result != TextToSpeech.LANG_AVAILABLE){
|
|
|
|
|
//Toast.makeText(NoteEditActivity.this,"暂不支持此种语言", Toast.LENGTH_LONG);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -581,7 +560,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
mNoteHeaderHolder.note_revoke.setEnabled(false);
|
|
|
|
|
return;
|
|
|
|
|
}else{
|
|
|
|
|
mNoteEditor.setText((CharSequence) mHistory.elementAt(stack_size - 2));
|
|
|
|
|
mNoteEditor.setText(mHistory.elementAt(stack_size - 2));
|
|
|
|
|
mHistory.removeElementAt(stack_size - 1);
|
|
|
|
|
if (stack_size == 2){
|
|
|
|
|
mNoteHeaderHolder.note_revoke.setEnabled(false);
|
|
|
|
@ -634,10 +613,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
}
|
|
|
|
|
mFontSizeSelector.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
if (id == R.id.imageButton2){
|
|
|
|
|
//mDraw.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1163,118 +1138,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
Toast.makeText(this, resId, duration).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getLocation(){
|
|
|
|
|
//1.获取位置管理器
|
|
|
|
|
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
|
|
|
|
|
|
|
|
|
//2.获取位置提供器,GPS或是NetWork
|
|
|
|
|
List<String> providers = locationManager.getProviders(true);
|
|
|
|
|
|
|
|
|
|
if (providers.contains(LocationManager.GPS_PROVIDER)) {
|
|
|
|
|
//如果是GPS
|
|
|
|
|
locationProvider = LocationManager.GPS_PROVIDER;
|
|
|
|
|
Log.v("TAG", "定位方式GPS");
|
|
|
|
|
} else if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
|
|
|
|
|
//如果是Network
|
|
|
|
|
locationProvider = LocationManager.NETWORK_PROVIDER;
|
|
|
|
|
Log.v("TAG", "定位方式Network");
|
|
|
|
|
}else {
|
|
|
|
|
Toast.makeText(this, "没有可用的位置提供器", Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Location location = locationManager.getLastKnownLocation(locationProvider);
|
|
|
|
|
if (location!=null){
|
|
|
|
|
Toast.makeText(this, location.getLongitude() + " " +
|
|
|
|
|
location.getLatitude() + "", Toast.LENGTH_SHORT).show();
|
|
|
|
|
Log.v("TAG", "获取上次的位置-经纬度:"+location.getLongitude()+" "+location.getLatitude());
|
|
|
|
|
getAddress(location);
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
//监视地理位置变化,第二个和第三个参数分别为更新的最短时间minTime和最短距离minDistace
|
|
|
|
|
locationManager.requestLocationUpdates(locationProvider, 3000, 1,locationListener);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LocationListener locationListener = new LocationListener() {
|
|
|
|
|
// Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
|
|
|
|
|
@Override
|
|
|
|
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
|
|
|
}
|
|
|
|
|
// Provider被enable时触发此函数,比如GPS被打开
|
|
|
|
|
@Override
|
|
|
|
|
public void onProviderEnabled(String provider) {
|
|
|
|
|
}
|
|
|
|
|
// Provider被disable时触发此函数,比如GPS被关闭
|
|
|
|
|
@Override
|
|
|
|
|
public void onProviderDisabled(String provider) {
|
|
|
|
|
}
|
|
|
|
|
//当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
|
|
|
|
|
@Override
|
|
|
|
|
public void onLocationChanged(Location location) {
|
|
|
|
|
if (location != null) {
|
|
|
|
|
//如果位置发生变化,重新显示地理位置经纬度
|
|
|
|
|
Toast.makeText(NoteEditActivity.this, location.getLongitude() + " " +
|
|
|
|
|
location.getLatitude() + "", Toast.LENGTH_SHORT).show();
|
|
|
|
|
Log.v("TAG", "监视地理位置变化-经纬度:"+location.getLongitude()+" "+location.getLatitude());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
|
switch (requestCode) {
|
|
|
|
|
case LOCATION_CODE:
|
|
|
|
|
if(grantResults.length > 0 && grantResults[0] == getPackageManager().PERMISSION_GRANTED
|
|
|
|
|
&& grantResults[1] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
Toast.makeText(this, "申请权限", Toast.LENGTH_LONG).show();
|
|
|
|
|
try {
|
|
|
|
|
List<String> providers = locationManager.getProviders(true);
|
|
|
|
|
if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
|
|
|
|
|
//如果是Network
|
|
|
|
|
locationProvider = LocationManager.NETWORK_PROVIDER;
|
|
|
|
|
|
|
|
|
|
}else if (providers.contains(LocationManager.GPS_PROVIDER)) {
|
|
|
|
|
//如果是GPS
|
|
|
|
|
locationProvider = LocationManager.GPS_PROVIDER;
|
|
|
|
|
}
|
|
|
|
|
Location location = locationManager.getLastKnownLocation(locationProvider);
|
|
|
|
|
if (location!=null){
|
|
|
|
|
Toast.makeText(this, location.getLongitude() + " " +
|
|
|
|
|
location.getLatitude() + "", Toast.LENGTH_SHORT).show();
|
|
|
|
|
Log.v("TAG", "获取上次的位置-经纬度:"+location.getLongitude()+" "+location.getLatitude());
|
|
|
|
|
}else{
|
|
|
|
|
// 监视地理位置变化,第二个和第三个参数分别为更新的最短时间minTime和最短距离minDistace
|
|
|
|
|
locationManager.requestLocationUpdates(locationProvider, 0, 0,locationListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch (SecurityException e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(this, "缺少权限", Toast.LENGTH_LONG).show();
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取地址信息:城市、街道等信息
|
|
|
|
|
private List<Address> getAddress(Location location) {
|
|
|
|
|
List<Address> result = null;
|
|
|
|
|
try {
|
|
|
|
|
if (location != null) {
|
|
|
|
|
Geocoder gc = new Geocoder(this, Locale.getDefault());
|
|
|
|
|
result = gc.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
|
|
|
|
|
Toast.makeText(this, "获取地址信息:"+result.toString(), Toast.LENGTH_LONG).show();
|
|
|
|
|
Log.v("TAG", "获取地址信息:"+result.toString());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AlertDialog alertDialog2;
|
|
|
|
|
|
|
|
|
|
public void showSingleAlertDiglog(){
|
|
|
|
@ -1297,6 +1160,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
case 3:
|
|
|
|
|
mNoteEditor.setTypeface(Typeface.MONOSPACE);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -1330,7 +1195,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
String path = s.replaceAll("\\<img src=\"|\"\\/>", "").trim();//得到路径
|
|
|
|
|
|
|
|
|
|
int width = ScreenUtils.getScreenWidth(NoteEditActivity.this);//屏幕的宽度
|
|
|
|
|
//int height = ScreenUtils.getScreenHeight(NoteEditActivity.this);
|
|
|
|
|
try {
|
|
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
|
|
Bitmap bitmap = BitmapFactory.decodeFile(path, options);
|
|
|
|
@ -1354,7 +1218,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
private SpannableString getBitmapMime(String path, String tagPath) {
|
|
|
|
|
SpannableString ss = new SpannableString(tagPath);//这里使用加了<img>标签的图片路径
|
|
|
|
|
int width = ScreenUtils.getScreenWidth(NoteEditActivity.this);
|
|
|
|
|
//int height = ScreenUtils.getScreenHeight(NoteEditActivity.this);
|
|
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
|
|
//路径对应的图片
|
|
|
|
|
Bitmap bitmap = BitmapFactory.decodeFile(path, options);
|
|
|
|
|