Compare commits

...

2 Commits

Author SHA1 Message Date
Ryuki 7335568c5d s
2 years ago
Ryuki ecaabdc260 z
2 years ago

@ -47,6 +47,7 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -85,8 +86,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public ImageView ibSetBgColor;
}
//使用Map实现数据存储
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
sBgSelectorBtnsMap.put(R.id.iv_bg_red, ResourceParser.RED);
@ -97,6 +100,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sBgSelectorSelectionMap = new HashMap<Integer, Integer>();
static {
sBgSelectorSelectionMap.put(ResourceParser.YELLOW, R.id.iv_bg_yellow_select);
sBgSelectorSelectionMap.put(ResourceParser.RED, R.id.iv_bg_red_select);
@ -107,6 +111,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sFontSizeBtnsMap = new HashMap<Integer, Integer>();
static {
sFontSizeBtnsMap.put(R.id.ll_font_large, ResourceParser.TEXT_LARGE);
sFontSizeBtnsMap.put(R.id.ll_font_small, ResourceParser.TEXT_SMALL);
@ -116,6 +121,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sFontSelectorSelectionMap = new HashMap<Integer, Integer>();
static {
sFontSelectorSelectionMap.put(ResourceParser.TEXT_LARGE, R.id.iv_large_select);
sFontSelectorSelectionMap.put(ResourceParser.TEXT_SMALL, R.id.iv_small_select);
@ -220,7 +226,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
} else if (TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
// New note
// intent.getAction()
// 大多用于broadcast发送广播时给机制intent设置一个action就是一个字符串
@ -287,6 +293,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
super.onResume();
initNoteScreen(); //调用方法初始化笔记屏幕
}
//初始化笔记界面的方法
private void initNoteScreen() {
//设置笔记编辑器的文字样式
@ -341,8 +348,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//没有提醒时,隐藏提醒日期和图标
mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
};
}
;
}
//当活动通过意图重新初始化时调用
@Override
protected void onNewIntent(Intent intent) {
@ -390,7 +399,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//判断触摸事件是否在给定的视图的范围内的方法
private boolean inRangeOfView(View view, MotionEvent ev) {
int []location = new int[2];
int[] location = new int[2];
//获取视图在屏幕上的位置
view.getLocationOnScreen(location);
int x = location[0];
@ -429,7 +438,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
for (int id : sFontSizeBtnsMap.keySet()) {
View view = findViewById(id);
view.setOnClickListener(this);
};
}
;
//获取共享偏好设置,用于恢复特定的笔记属性,如字体的大小
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE);
@ -439,7 +449,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
*/
//如果字体大小ID超出资源数组大小设置为默认字体大小
if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
if (mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
}
//初始化笔记编辑列表视图
@ -451,7 +461,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
protected void onPause() {
super.onPause();
//尝试保存笔记,如果成功则记录保存的长度
if(saveNote()) {
if (saveNote()) {
Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length());
}
//清除设置状态
@ -473,7 +483,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return;
}
//添加小部件ID到intent中
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{
mWorkingNote.getWidgetId()
});
//发送广播以通知小部件更新
@ -481,6 +491,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//设置结果为OK
setResult(RESULT_OK, intent);
}
//处理点击事件
public void onClick(View v) {
int id = v.getId();
@ -488,7 +499,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
- View.VISIBLE);
-View.VISIBLE);
//更改背景颜色或字体大小的逻辑
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
@ -515,7 +526,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
@Override
public void onBackPressed() {
//清除设置状态,如果已经处理则返回
if(clearSettingState()) {
if (clearSettingState()) {
return;
}
//保存笔记然后正常处理返回事件
@ -620,7 +631,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
//当用户设置了日期时间后,将这个时间保存为提醒的时间
mWorkingNote.setAlertDate(date , true);
mWorkingNote.setAlertDate(date, true);
}
});
//显示日期时间选择对话框
@ -707,7 +718,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
//显示提醒的头部信息
showAlertHeader();
if(!set) {
if (!set) {
//如果set为false取消任何现有的闹钟
alarmManager.cancel(pendingIntent);
} else {
@ -745,7 +756,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mEditTextList.removeViewAt(index);//移除指定索引处的编辑框视图
NoteEditText edit = null;
if(index == 0) { //如果删除的是第一个编辑框
if (index == 0) { //如果删除的是第一个编辑框
edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(
R.id.et_edit_text);
} else {//否则,获取欠一个编辑框
@ -764,7 +775,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
/**
* Should not happen, check for debug
*/
if(index > mEditTextList.getChildCount()) {
if (index > mEditTextList.getChildCount()) {
Log.e(TAG, "Index out of mEditTextList boundrary, should not happen");
}
//创建新的列表项视图,然后将其添加到列表中的指定位置
@ -786,7 +797,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
String[] items = text.split("\n");//按换行符拆分文本成多个项
int index = 0;
for (String item : items) {
if(!TextUtils.isEmpty(item)) { //跳过空项
if (!TextUtils.isEmpty(item)) { //跳过空项
mEditTextList.addView(getListItem(item, index));//添加列表项
index++;
}
@ -862,7 +873,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return;
}
//根据文本是否存在来设置复选框的可见性
if(hasText) {
if (hasText) {
mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.VISIBLE);
} else {
mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE);
@ -1000,4 +1011,19 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show();
}
final ImageButton add_img_btn = (ImageButton) findViewById(R.id.add_img_btn);
add_img_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
log.d(TAG, "onClick: click add image button");
Intent loadImage = new Intent(Intent.ACTION_GET_CONTENT);
loadImage.addCategory(Intent.CATEGORY_OPENABLE);
loadImage.setType("image/*");
startActivityForResult(loadImage, PHOTO_REQUESt);
}
});
}

@ -0,0 +1,29 @@
package net.micode.notes.ui;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import net.micode.notes.R;
public class SplashActivity extends AppCompatActivity {
Handler mHandler=new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //加载启动界面
setContentView(R.layout.activity_splash); //加载启动
// 当计时结束时,跳转至 NotesListActivity
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent();
intent.setClass(SplashActivity.this, LoginActivity.class);
startActivity(intent);
finish(); //销毁欢迎页面
}
}, 2000); // 2 秒后跳转}

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="旧密码:"/>
<EditText
android:id="@+id/old_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新密码:"/>
<EditText
android:id="@+id/new_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:"/>
<EditText
android:id="@+id/ack_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/Acknowledged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入密码:"/>
<EditText
android:id="@+id/thepassword"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/Dt_Acknowledged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height='wrap_content'
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:"/>
<EditText
android:id="@+id/lgn_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新设置密码:"/>
<EditText
android:id="@+id/password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:" />
<EditText
android:id="@+id/password_ack"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/acknowledge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="0099cc"
tools:context=".ui.SplashActivity">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<TextView android:id="@+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#33b5e5"
android:keepScreenOn="true"
android:textStyle="bold"
android:textSize="50sp"
android:gravity="center"
android:text="@string/dummy_content" />
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id = "@+id/fullscreen_content_controls"
style = "?metaButtonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button android:id="@+id/dummy_button"
style= "?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text = "@string/dummy_button" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash"
android:gravity="top"
android:keepScreenOn="true"
android:text="@string/dummy_content"
android:textSize="50sp"
android:textStyle="bold"
/>
</FrameLayout>
</FrameLayout>

@ -237,6 +237,16 @@
</FrameLayout>
</LinearLayout>
<ImageButton
android:id = "@+id/add_img_btn"
android:layout_width="45dp"
android:layout_height="match_parent"
android:src="@android:drawable/ic_menu_gallery"/>
<LinearLayout
android:id="@+id/font_size_selector"
android:layout_width="fill_parent"

@ -0,0 +1,6 @@
<resources>
<declare-styleable name="FullscreenAttrs">
<attr name="fullscreenBackgroundColor" format="color" />
<attr name="fullscreenTextColor" format="color" />
</declare-styleable>
</resources>

@ -15,6 +15,16 @@
limitations under the License.
-->
<!--<resources>-->
<!-- <color name="user_query_highlight">#335b5b5b</color>-->
<!--</resources>-->
<resources>
<color name="user_query_highlight">#335b5b5b</color>
<color name="light_blue_600">#FFO39BE5</color>
<color name="light_blue_900">#FF01579B</color>
<color name="liqht_blue_A200">#FF40C4FF</color>
<color name="liqht_blue_A400">#FFOOBOFF</color>
<color name="black_overlay">#66000000</color>
</resources>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Newnote" parent="Theme.AppCompat.Light"/>
<style name="Theme.Newnote.Fullscreen" parent="Theme.Newnote">
<item name="android:actionBarStyle">@style/Widget.Theme.Newnote.ActionBar.Fullscreen</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
</style>
<style name="ThemeOverlay.Newnote.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
<item name="fullscreenTextColor">@color/light_blue_A200</item>
</style>
</resources>

@ -0,0 +1,6 @@
<resources>
<style name="ThemeOverlay.Newnote.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">@color/light_blue_900</item>
<item name="fullscreenTextColor">@color/light_blue_A400</item>
</style>
</resources>
Loading…
Cancel
Save