diff --git a/Notesmaster/README.md b/Notesmaster/README.md new file mode 100644 index 0000000..b3bbdb2 --- /dev/null +++ b/Notesmaster/README.md @@ -0,0 +1,2 @@ +# MayWeSeeYouAgian + diff --git a/Notesmaster/app/build.gradle b/Notesmaster/app/build.gradle new file mode 100644 index 0000000..7438e65 --- /dev/null +++ b/Notesmaster/app/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 33 + buildToolsVersion "33.0.2" + + defaultConfig { + applicationId "net.micode.notes" + minSdkVersion 33 + //noinspection ExpiredTargetSdkVersion + targetSdkVersion 33 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + + } + + dependencies { + implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.2.1' + implementation group: 'androidx.appcompat', name: 'appcompat', version: '1.6.0' + implementation 'com.google.android.material:material:1.7.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'com.android.support:support-annotations:28.0.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' + } + + packagingOptions { + exclude 'META-INF/*' + } +} + diff --git a/Notesmaster/app/src/main/java/net/micode/notes/tool/FingerprintDialogFragment.java b/Notesmaster/app/src/main/java/net/micode/notes/tool/FingerprintDialogFragment.java new file mode 100644 index 0000000..1429829 --- /dev/null +++ b/Notesmaster/app/src/main/java/net/micode/notes/tool/FingerprintDialogFragment.java @@ -0,0 +1,135 @@ +package net.micode.notes.tool; + +import android.annotation.TargetApi; +import android.app.DialogFragment; +import android.content.Context; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Bundle; +import android.os.CancellationSignal; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import net.micode.notes.R; +import net.micode.notes.ui.NotesListActivity; + +import javax.crypto.Cipher; + +@TargetApi(23) +public class FingerprintDialogFragment extends DialogFragment { + + private FingerprintManager fingerprintManager; + + private CancellationSignal mCancellationSignal; + + private Cipher mCipher; + + private NotesListActivity mActivity; + + private TextView errorMsg; + + /** + * 标识是否是用户主动取消的认证。 + */ + private boolean isSelfCancelled; + + public void setCipher(Cipher cipher) { + mCipher = cipher; + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + mActivity = (NotesListActivity) getActivity(); + } + + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + fingerprintManager = getContext().getSystemService(FingerprintManager.class); + setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog); + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.fingerprint_dialog, container, false); + errorMsg = v.findViewById(R.id.error_msg); + TextView cancel = v.findViewById(R.id.cancel); + cancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + stopListening(); + } + }); + return v; + } + + @Override + public void onResume() { + super.onResume(); + // 开始指纹认证监听 + startListening(mCipher); + } + + @Override + public void onPause() { + super.onPause(); + // 停止指纹认证监听 + stopListening(); + } + + //监听认证成功与失败 + private void startListening(Cipher cipher) { + isSelfCancelled = false; + mCancellationSignal = new CancellationSignal(); + fingerprintManager.authenticate(new FingerprintManager.CryptoObject(cipher), mCancellationSignal, 0, new FingerprintManager.AuthenticationCallback() { + @Override + public void onAuthenticationError(int errorCode, CharSequence errString) { + if (!isSelfCancelled) { + errorMsg.setText(errString); + if (errorCode == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT) { + Toast.makeText(mActivity, errString, Toast.LENGTH_SHORT).show(); + dismiss(); + } + } + mActivity.onStopAuthenticated(); + } + + @Override + public void onAuthenticationHelp(int helpCode, CharSequence helpString) { + errorMsg.setText(helpString); + } + + @Override + public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { + Toast.makeText(mActivity, "指纹认证成功", Toast.LENGTH_SHORT).show(); + mActivity.onAuthenticated(); + dismiss(); +// mActivity.onAuthenticated();//认证成功后就可以写成功后的代码逻辑 + } + + @Override + public void onAuthenticationFailed() { + errorMsg.setText("指纹认证失败,请再试一次"); + } + }, null); + } + + private void stopListening() { + if (mCancellationSignal != null) { + mCancellationSignal.cancel(); + mCancellationSignal = null; + isSelfCancelled = true; + } + mActivity.onStopAuthenticated(); + } + +} diff --git a/Notesmaster/app/src/main/java/net/micode/notes/ui/VoiceNoteActivity.java b/Notesmaster/app/src/main/java/net/micode/notes/ui/VoiceNoteActivity.java new file mode 100644 index 0000000..1662f29 --- /dev/null +++ b/Notesmaster/app/src/main/java/net/micode/notes/ui/VoiceNoteActivity.java @@ -0,0 +1,47 @@ +package net.micode.notes.ui; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.speech.RecognizerIntent; +import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Locale; + +public class VoiceNoteActivity extends Activity { + private static final int REQUEST_CODE_SPEECH_INPUT = 1000; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + startVoiceRecognition(); + } + + private void startVoiceRecognition() { + Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak now..."); + try { + startActivityForResult(intent, REQUEST_CODE_SPEECH_INPUT); + } catch (Exception e) { + Toast.makeText(this, "Speech recognition is not supported on this device.", Toast.LENGTH_SHORT).show(); + finish(); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == REQUEST_CODE_SPEECH_INPUT && resultCode == RESULT_OK && data != null) { + ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); + if (result != null && !result.isEmpty()) { + Intent intent = new Intent(); + intent.putExtra("recognizedText", result.get(0)); + setResult(RESULT_OK, intent); + } + } + finish(); + } +} diff --git a/Notesmaster/app/src/main/res/drawable-hdpi/add_node.png b/Notesmaster/app/src/main/res/drawable-hdpi/add_node.png new file mode 100644 index 0000000..f122cfb Binary files /dev/null and b/Notesmaster/app/src/main/res/drawable-hdpi/add_node.png differ diff --git a/Notesmaster/app/src/main/res/drawable-hdpi/listtest.png b/Notesmaster/app/src/main/res/drawable-hdpi/listtest.png new file mode 100644 index 0000000..edd692a Binary files /dev/null and b/Notesmaster/app/src/main/res/drawable-hdpi/listtest.png differ diff --git a/Notesmaster/app/src/main/res/drawable-hdpi/lock.png b/Notesmaster/app/src/main/res/drawable-hdpi/lock.png new file mode 100644 index 0000000..900f4c7 Binary files /dev/null and b/Notesmaster/app/src/main/res/drawable-hdpi/lock.png differ diff --git a/Notesmaster/app/src/main/res/drawable-hdpi/note_bk.png b/Notesmaster/app/src/main/res/drawable-hdpi/note_bk.png new file mode 100644 index 0000000..61cf055 Binary files /dev/null and b/Notesmaster/app/src/main/res/drawable-hdpi/note_bk.png differ diff --git a/Notesmaster/app/src/main/res/drawable-hdpi/unlock.png b/Notesmaster/app/src/main/res/drawable-hdpi/unlock.png new file mode 100644 index 0000000..d4eb1a1 Binary files /dev/null and b/Notesmaster/app/src/main/res/drawable-hdpi/unlock.png differ diff --git a/Notesmaster/app/src/main/res/drawable/ic_fp_40px.png b/Notesmaster/app/src/main/res/drawable/ic_fp_40px.png new file mode 100644 index 0000000..122f442 Binary files /dev/null and b/Notesmaster/app/src/main/res/drawable/ic_fp_40px.png differ diff --git a/Notesmaster/app/src/main/res/layout/activity_voice_note.xml b/Notesmaster/app/src/main/res/layout/activity_voice_note.xml new file mode 100644 index 0000000..45d6670 --- /dev/null +++ b/Notesmaster/app/src/main/res/layout/activity_voice_note.xml @@ -0,0 +1,20 @@ + + + + + +