master
bsywa 2 years ago
parent 21c4aa2814
commit cdcb118932

@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

@ -0,0 +1,514 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DBNavigator.Project.DataEditorManager">
<record-view-column-sorting-type value="BY_INDEX" />
<value-preview-text-wrapping value="true" />
<value-preview-pinned value="false" />
</component>
<component name="DBNavigator.Project.DatabaseBrowserManager">
<autoscroll-to-editor value="false" />
<autoscroll-from-editor value="true" />
<show-object-properties value="true" />
<loaded-nodes />
</component>
<component name="DBNavigator.Project.DatabaseConsoleManager">
<connection id="634c05ec-5725-4682-9c1f-f355c89055a7">
<console name="Connection" type="STANDARD" schema="mysql" session="Main" />
</connection>
</component>
<component name="DBNavigator.Project.DatabaseEditorStateManager">
<last-used-providers />
</component>
<component name="DBNavigator.Project.DatabaseFileManager">
<open-files />
</component>
<component name="DBNavigator.Project.ObjectQuickFilterManager">
<last-used-operator value="EQUAL" />
<filters />
</component>
<component name="DBNavigator.Project.Settings">
<connections>
<connection id="634c05ec-5725-4682-9c1f-f355c89055a7" active="true" signed="true">
<database>
<name value="Connection" />
<description value="" />
<database-type value="MYSQL" />
<config-type value="BASIC" />
<database-version value="9999.0" />
<driver-source value="BUILTIN" />
<driver-library value="" />
<driver value="" />
<url-type value="DATABASE" />
<host value="localhost" />
<port value="3306" />
<database value="mysql" />
<type value="USER_PASSWORD" />
<user value="" />
<deprecated-pwd value="" />
</database>
<properties>
<auto-commit value="false" />
</properties>
<ssh-settings>
<active value="false" />
<proxy-host value="" />
<proxy-port value="22" />
<proxy-user value="" />
<deprecated-proxy-pwd value="" />
<auth-type value="PASSWORD" />
<key-file value="" />
<key-passphrase value="" />
</ssh-settings>
<ssl-settings>
<active value="false" />
<certificate-authority-file value="" />
<client-certificate-file value="" />
<client-key-file value="" />
</ssl-settings>
<details>
<charset value="UTF-8" />
<session-management value="true" />
<ddl-file-binding value="true" />
<database-logging value="true" />
<connect-automatically value="true" />
<restore-workspace value="true" />
<restore-workspace-deep value="false" />
<environment-type value="default" />
<connectivity-timeout value="10" />
<idle-time-to-disconnect value="30" />
<idle-time-to-disconnect-pool value="5" />
<credential-expiry-time value="10" />
<max-connection-pool-size value="7" />
<alternative-statement-delimiter value="" />
</details>
<object-filters hide-empty-schemas="false" hide-pseudo-columns="false">
<object-type-filter>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="true" />
<object-type name="ROLE" enabled="true" />
<object-type name="PRIVILEGE" enabled="true" />
<object-type name="CHARSET" enabled="true" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED_VIEW" enabled="true" />
<object-type name="NESTED_TABLE" enabled="true" />
<object-type name="COLUMN" enabled="true" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET_TRIGGER" enabled="true" />
<object-type name="DATABASE_TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="true" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
<object-type name="ARGUMENT" enabled="true" />
<object-type name="DIMENSION" enabled="true" />
<object-type name="CLUSTER" enabled="true" />
<object-type name="DBLINK" enabled="true" />
</object-type-filter>
<object-name-filters />
</object-filters>
</connection>
</connections>
<browser-settings>
<general>
<display-mode value="TABBED" />
<navigation-history-size value="100" />
<show-object-details value="false" />
</general>
<filters>
<object-type-filter>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="true" />
<object-type name="ROLE" enabled="true" />
<object-type name="PRIVILEGE" enabled="true" />
<object-type name="CHARSET" enabled="true" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED_VIEW" enabled="true" />
<object-type name="NESTED_TABLE" enabled="true" />
<object-type name="COLUMN" enabled="true" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET_TRIGGER" enabled="true" />
<object-type name="DATABASE_TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="true" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
<object-type name="ARGUMENT" enabled="true" />
<object-type name="DIMENSION" enabled="true" />
<object-type name="CLUSTER" enabled="true" />
<object-type name="DBLINK" enabled="true" />
</object-type-filter>
</filters>
<sorting>
<object-type name="COLUMN" sorting-type="NAME" />
<object-type name="FUNCTION" sorting-type="NAME" />
<object-type name="PROCEDURE" sorting-type="NAME" />
<object-type name="ARGUMENT" sorting-type="POSITION" />
<object-type name="TYPE ATTRIBUTE" sorting-type="POSITION" />
</sorting>
<default-editors>
<object-type name="VIEW" editor-type="SELECTION" />
<object-type name="PACKAGE" editor-type="SELECTION" />
<object-type name="TYPE" editor-type="SELECTION" />
</default-editors>
</browser-settings>
<navigation-settings>
<lookup-filters>
<lookup-objects>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="false" />
<object-type name="ROLE" enabled="false" />
<object-type name="PRIVILEGE" enabled="false" />
<object-type name="CHARSET" enabled="false" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED VIEW" enabled="true" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET TRIGGER" enabled="true" />
<object-type name="DATABASE TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="false" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="DIMENSION" enabled="false" />
<object-type name="CLUSTER" enabled="false" />
<object-type name="DBLINK" enabled="true" />
</lookup-objects>
<force-database-load value="false" />
<prompt-connection-selection value="true" />
<prompt-schema-selection value="true" />
</lookup-filters>
</navigation-settings>
<dataset-grid-settings>
<general>
<enable-zooming value="true" />
<enable-column-tooltip value="true" />
</general>
<sorting>
<nulls-first value="true" />
<max-sorting-columns value="4" />
</sorting>
<audit-columns>
<column-names value="" />
<visible value="true" />
<editable value="false" />
</audit-columns>
</dataset-grid-settings>
<dataset-editor-settings>
<text-editor-popup>
<active value="false" />
<active-if-empty value="false" />
<data-length-threshold value="100" />
<popup-delay value="1000" />
</text-editor-popup>
<values-actions-popup>
<show-popup-button value="true" />
<element-count-threshold value="1000" />
<data-length-threshold value="250" />
</values-actions-popup>
<general>
<fetch-block-size value="100" />
<fetch-timeout value="30" />
<trim-whitespaces value="true" />
<convert-empty-strings-to-null value="true" />
<select-content-on-cell-edit value="true" />
<large-value-preview-active value="true" />
</general>
<filters>
<prompt-filter-dialog value="true" />
<default-filter-type value="BASIC" />
</filters>
<qualified-text-editor text-length-threshold="300">
<content-types>
<content-type name="Text" enabled="true" />
<content-type name="Properties" enabled="true" />
<content-type name="XML" enabled="true" />
<content-type name="DTD" enabled="true" />
<content-type name="HTML" enabled="true" />
<content-type name="XHTML" enabled="true" />
<content-type name="Java" enabled="true" />
<content-type name="SQL" enabled="true" />
<content-type name="PL/SQL" enabled="true" />
<content-type name="JSON" enabled="true" />
<content-type name="JSON5" enabled="true" />
<content-type name="Groovy" enabled="true" />
<content-type name="AIDL" enabled="true" />
<content-type name="YAML" enabled="true" />
<content-type name="Manifest" enabled="true" />
</content-types>
</qualified-text-editor>
<record-navigation>
<navigation-target value="VIEWER" />
</record-navigation>
</dataset-editor-settings>
<code-editor-settings>
<general>
<show-object-navigation-gutter value="false" />
<show-spec-declaration-navigation-gutter value="true" />
<enable-spellchecking value="true" />
<enable-reference-spellchecking value="false" />
</general>
<confirmations>
<save-changes value="false" />
<revert-changes value="true" />
</confirmations>
</code-editor-settings>
<code-completion-settings>
<filters>
<basic-filter>
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
<filter-element type="RESERVED_WORD" id="function" selected="true" />
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
<filter-element type="OBJECT" id="schema" selected="true" />
<filter-element type="OBJECT" id="role" selected="true" />
<filter-element type="OBJECT" id="user" selected="true" />
<filter-element type="OBJECT" id="privilege" selected="true" />
<user-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="false" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</user-schema>
<public-schema>
<filter-element type="OBJECT" id="table" selected="false" />
<filter-element type="OBJECT" id="view" selected="false" />
<filter-element type="OBJECT" id="materialized view" selected="false" />
<filter-element type="OBJECT" id="index" selected="false" />
<filter-element type="OBJECT" id="constraint" selected="false" />
<filter-element type="OBJECT" id="trigger" selected="false" />
<filter-element type="OBJECT" id="synonym" selected="false" />
<filter-element type="OBJECT" id="sequence" selected="false" />
<filter-element type="OBJECT" id="procedure" selected="false" />
<filter-element type="OBJECT" id="function" selected="false" />
<filter-element type="OBJECT" id="package" selected="false" />
<filter-element type="OBJECT" id="type" selected="false" />
<filter-element type="OBJECT" id="dimension" selected="false" />
<filter-element type="OBJECT" id="cluster" selected="false" />
<filter-element type="OBJECT" id="dblink" selected="false" />
</public-schema>
<any-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</any-schema>
</basic-filter>
<extended-filter>
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
<filter-element type="RESERVED_WORD" id="function" selected="true" />
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
<filter-element type="OBJECT" id="schema" selected="true" />
<filter-element type="OBJECT" id="user" selected="true" />
<filter-element type="OBJECT" id="role" selected="true" />
<filter-element type="OBJECT" id="privilege" selected="true" />
<user-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</user-schema>
<public-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</public-schema>
<any-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</any-schema>
</extended-filter>
</filters>
<sorting enabled="true">
<sorting-element type="RESERVED_WORD" id="keyword" />
<sorting-element type="RESERVED_WORD" id="datatype" />
<sorting-element type="OBJECT" id="column" />
<sorting-element type="OBJECT" id="table" />
<sorting-element type="OBJECT" id="view" />
<sorting-element type="OBJECT" id="materialized view" />
<sorting-element type="OBJECT" id="index" />
<sorting-element type="OBJECT" id="constraint" />
<sorting-element type="OBJECT" id="trigger" />
<sorting-element type="OBJECT" id="synonym" />
<sorting-element type="OBJECT" id="sequence" />
<sorting-element type="OBJECT" id="procedure" />
<sorting-element type="OBJECT" id="function" />
<sorting-element type="OBJECT" id="package" />
<sorting-element type="OBJECT" id="type" />
<sorting-element type="OBJECT" id="dimension" />
<sorting-element type="OBJECT" id="cluster" />
<sorting-element type="OBJECT" id="dblink" />
<sorting-element type="OBJECT" id="schema" />
<sorting-element type="OBJECT" id="role" />
<sorting-element type="OBJECT" id="user" />
<sorting-element type="RESERVED_WORD" id="function" />
<sorting-element type="RESERVED_WORD" id="parameter" />
</sorting>
<format>
<enforce-code-style-case value="true" />
</format>
</code-completion-settings>
<execution-engine-settings>
<statement-execution>
<fetch-block-size value="100" />
<execution-timeout value="20" />
<debug-execution-timeout value="600" />
<focus-result value="false" />
<prompt-execution value="false" />
</statement-execution>
<script-execution>
<command-line-interfaces />
<execution-timeout value="300" />
</script-execution>
<method-execution>
<execution-timeout value="30" />
<debug-execution-timeout value="600" />
<parameter-history-size value="10" />
</method-execution>
</execution-engine-settings>
<operation-settings>
<transactions>
<uncommitted-changes>
<on-project-close value="ASK" />
<on-disconnect value="ASK" />
<on-autocommit-toggle value="ASK" />
</uncommitted-changes>
<multiple-uncommitted-changes>
<on-commit value="ASK" />
<on-rollback value="ASK" />
</multiple-uncommitted-changes>
</transactions>
<session-browser>
<disconnect-session value="ASK" />
<kill-session value="ASK" />
<reload-on-filter-change value="false" />
</session-browser>
<compiler>
<compile-type value="KEEP" />
<compile-dependencies value="ASK" />
<always-show-controls value="false" />
</compiler>
<debugger>
<debugger-type value="ASK" />
<use-generic-runners value="true" />
</debugger>
</operation-settings>
<ddl-file-settings>
<extensions>
<mapping file-type-id="VIEW" extensions="vw" />
<mapping file-type-id="TRIGGER" extensions="trg" />
<mapping file-type-id="PROCEDURE" extensions="prc" />
<mapping file-type-id="FUNCTION" extensions="fnc" />
<mapping file-type-id="PACKAGE" extensions="pkg" />
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
<mapping file-type-id="TYPE" extensions="tpe" />
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
</extensions>
<general>
<lookup-ddl-files value="true" />
<create-ddl-files value="false" />
<synchronize-ddl-files value="true" />
<use-qualified-names value="false" />
<make-scripts-rerunnable value="true" />
</general>
</ddl-file-settings>
<general-settings>
<regional-settings>
<date-format value="MEDIUM" />
<number-format value="UNGROUPED" />
<locale value="SYSTEM_DEFAULT" />
<use-custom-formats value="false" />
</regional-settings>
<environment>
<environment-types>
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
</environment-types>
<visibility-settings>
<connection-tabs value="true" />
<dialog-headers value="true" />
<object-editor-tabs value="true" />
<script-editor-tabs value="false" />
<execution-result-tabs value="true" />
</visibility-settings>
</environment>
</general-settings>
</component>
</project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\86130\.android\avd\Pixel_4_API_30.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-05-25T16:48:11.783527200Z" />
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1 @@
/build

@ -0,0 +1,50 @@
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.sparrownotes"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// ButterKnife requires Java 8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
//
implementation 'com.jakewharton:butterknife:10.2.1'
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//
implementation 'de.hdodenhof:circleimageview:3.1.0'
//
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Glide
implementation 'com.github.bumptech.glide:glide:3.7.0'
}

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

@ -0,0 +1,26 @@
package com.example.sparrownotes;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.sparrownotes", appContext.getPackageName());
}
}

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sparrownotes">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/icon_sparrow"
android:label="@string/app_name"
android:roundIcon="@drawable/icon_sparrow"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".FindPwdActivity" />
<activity android:name=".RegisterActivity" />
<activity
android:name=".HomeActivity"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -0,0 +1,180 @@
package com.example.sparrownotes;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import java.util.List;
import java.util.regex.Matcher;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
*
*/
public class FindPwdActivity extends AppCompatActivity {
@BindView(R.id.btn_confirm_find)
Button btnConfirmFind;
@BindView(R.id.btn_reset_find)
Button btnResetFind;
@BindView(R.id.edit_confirm_pwd_find)
EditText editConfirmPwdFind;
@BindView(R.id.edit_password_find)
EditText editPasswordFind;
@BindView(R.id.edit_email_find)
EditText editEmailFind;
@BindView(R.id.check_hide_pwd_find)
CheckBox checkHidePwdFind;
@BindView(R.id.check_hide_pwd_find2)
CheckBox checkHidePwdFind2;
private static final String TAG = "FindPwdActivity";
private UserDao userDao;
private String textPassword;
private String textConfirmPwd;
private String textEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_pwd);
ButterKnife.bind(this);
userDao = new UserDao(this);
}
@OnClick({R.id.btn_confirm_find, R.id.btn_reset_find, R.id.check_hide_pwd_find, R.id.check_hide_pwd_find2})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_confirm_find:
// 检查非空
if (isNotEmpty()) {
// 获得用户输入
getEditText();
// 检查邮箱格式
if (checkEmail()) {
// 检查两次输入的密码是否一致
if (comparePwd()) {
// 更新密码
if (updatePwdFromDB()) {
// 跳转登录界面
Intent intent = new Intent(FindPwdActivity.this, MainActivity.class);
startActivity(intent);
FindPwdActivity.this.finish();
}
} else {
Toast.makeText(this, "两次输入的密码不一致", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "邮箱格式错误", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "邮箱或密码不能为空", Toast.LENGTH_SHORT).show();
}
break;
case R.id.btn_reset_find:
// 清空输入
editPasswordFind.setText("");
editConfirmPwdFind.setText("");
editEmailFind.setText("");
break;
case R.id.check_hide_pwd_find:
if (checkHidePwdFind.isChecked()) {
// 将密码显示出来
editPasswordFind.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
// 隐藏密码
editPasswordFind.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
// 将光标移动到文本最后
editPasswordFind.setSelection(editPasswordFind.getText().toString().length());
break;
case R.id.check_hide_pwd_find2:
if (checkHidePwdFind2.isChecked()) {
// 将密码显示出来
editConfirmPwdFind.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
// 隐藏密码
editConfirmPwdFind.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
// 将光标移动到文本最后
editConfirmPwdFind.setSelection(editConfirmPwdFind.getText().toString().length());
break;
default:
break;
}
}
/**
*
*
* @return
*/
public boolean isNotEmpty() {
return !"".equals(editPasswordFind.getText().toString()) &&
!"".equals(editConfirmPwdFind.getText().toString()) &&
!"".equals(editEmailFind.getText().toString());
}
/**
*
*/
public void getEditText() {
textPassword = editPasswordFind.getText().toString();
textConfirmPwd = editConfirmPwdFind.getText().toString();
textEmail = editEmailFind.getText().toString();
Log.d(TAG, "getEditText: " + textEmail);
}
/**
*
*
* @return
*/
public boolean checkEmail() {
Matcher emailMatcher = Constant.EMAIL_PATTERN.matcher(textEmail);
return emailMatcher.matches();
}
/**
*
*
* @return
*/
public boolean comparePwd() {
return textPassword.equals(textConfirmPwd);
}
/**
*
*
* @return
*/
public boolean updatePwdFromDB() {
List<UserBean> userBeans = userDao.queryForWhat("email", textEmail);
if (userBeans.size() != 0) {
UserBean user = userBeans.get(0);
user.setPassword(textPassword);
userDao.update(user);
return true;
} else {
Toast.makeText(this, "邮箱错误", Toast.LENGTH_SHORT).show();
return false;
}
}
}

@ -0,0 +1,280 @@
package com.example.sparrownotes;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.fragment.AddFragment;
import com.example.sparrownotes.fragment.AllFragment;
import com.example.sparrownotes.fragment.TopFragment;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.DialogUtil;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import com.google.android.material.navigation.NavigationView;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
/**
*
*/
public class HomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.btn_top)
RadioButton btnTop;
@BindView(R.id.btn_add)
RadioButton btnAdd;
@BindView(R.id.btn_all)
RadioButton btnAll;
@BindView(R.id.dock_radio_group)
RadioGroup dockRadioGroup;
@BindView(R.id.drawer_layout)
DrawerLayout drawerLayout;
@BindView(R.id.nav_view)
NavigationView navView;
private static final String TAG = "HomeActivity";
ActionBar actionBar;
Fragment fragment;
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
SharedPreferenceUtil spu;
private UserDao userDao;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
ButterKnife.bind(this);
userDao = new UserDao(this);
spu = SharedPreferenceUtil.getInstance(this);
initView();
}
/**
*
*/
public void initView() {
// 工具栏
toolbar.setTitle(R.string.app_name);
setTitleCenter(toolbar);
setSupportActionBar(toolbar);
actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.icon_setting);
}
// 抽屉
ViewGroup.LayoutParams params = navView.getLayoutParams();
params.width = getResources().getDisplayMetrics().widthPixels / 2;
navView.setLayoutParams(params);
navView.setNavigationItemSelectedListener(this);
// 抽屉中的header
View headerView = navView.getHeaderView(0);
TextView textUserName = headerView.findViewById(R.id.header_user_name);
TextView textEmail = headerView.findViewById(R.id.header_email);
textUserName.setText(spu.getString(Constant.USER_NAME));
textEmail.setText(getEmail());
// 默认加载置顶Fragment
fragment = new TopFragment();
transaction.replace(R.id.view_pager, fragment, Constant.TOP_TAG);
transaction.commit();
}
/**
* Fragment
*
* @param view
* @param isChanged
*/
@OnCheckedChanged({R.id.btn_add, R.id.btn_all, R.id.btn_top})
public void onCheckedChanged(CompoundButton view, boolean isChanged) {
transaction = manager.beginTransaction();
switch (view.getId()) {
case R.id.btn_top:
if (isChanged) {
fragment = new TopFragment();
transaction.replace(R.id.view_pager, fragment, Constant.TOP_TAG);
transaction.commit();
Constant.PAGE_STATE = "top";
}
break;
case R.id.btn_add:
if (isChanged) {
fragment = new AddFragment();
transaction.replace(R.id.view_pager, fragment, Constant.ADD_TAG);
transaction.commit();
}
break;
case R.id.btn_all:
if (isChanged) {
fragment = new AllFragment();
transaction.replace(R.id.view_pager, fragment, Constant.LIST_TAG);
transaction.commit();
Constant.PAGE_STATE = "all";
}
break;
default:
break;
}
}
/**
*
*
* @return
*/
public String getEmail() {
List<UserBean> userBeans = userDao
.queryByUserNameAndPassword(spu.getString(Constant.USER_NAME), spu.getString(Constant.PASSWORD));
return userBeans.get(0).getEmail();
}
/**
*
*
* @param item
* @return
*/
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
drawerLayout.closeDrawers();
switch (item.getItemId()) {
case R.id.nav_change_pwd:
DialogUtil.editInfoDialog(this, spu.getInt(Constant.USER_ID));
break;
case R.id.nav_dismiss:
DialogUtil.dismissDialog(this, spu.getInt(Constant.USER_ID));
break;
case R.id.nav_exit:
spu.putBoolean(Constant.AUTO_LOGIN, false);
Intent intent = new Intent(HomeActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
default:
break;
}
return true;
}
/**
* ToolBarmenu
*
* @param menu
* @return
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_menu, menu);
setIconsVisible(menu, true);
return true;
}
/**
* ToolBar
*
*
* @param item
* @return
*/
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.search_title:
DialogUtil.searchTitleDialog(this);
break;
case R.id.search_content:
DialogUtil.searchContentDialog(this);
break;
case R.id.search_category:
DialogUtil.searchCategoryDialog(this);
break;
case android.R.id.home:
drawerLayout.openDrawer(GravityCompat.START);
break;
default:
break;
}
return true;
}
/**
* ToolBar
*
* @param toolbar
*/
public void setTitleCenter(Toolbar toolbar) {
String title = "title";
final CharSequence originalTitle = toolbar.getTitle();
toolbar.setTitle(title);
for (int i = 0; i < toolbar.getChildCount(); i++) {
View view = toolbar.getChildAt(i);
if (view instanceof TextView) {
TextView textView = (TextView) view;
if (title.equals(textView.getText())) {
textView.setGravity(Gravity.CENTER);
Toolbar.LayoutParams params = new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT, Toolbar.LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER;
textView.setLayoutParams(params);
}
}
toolbar.setTitle(originalTitle);
}
}
/**
* menu
*
* @param menu
* @param flag
*/
private void setIconsVisible(Menu menu, boolean flag) {
// 判断menu是否为空
if (menu != null) {
try {
// 如果不为空,就反射拿到menu的setOptionalIconsVisible方法
Method method = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
// 暴力访问该方法
method.setAccessible(true);
// 调用该方法显示icon
method.invoke(menu, flag);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,205 @@
package com.example.sparrownotes;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
*
*/
public class MainActivity extends AppCompatActivity {
@BindView(R.id.img_icon)
ImageView imgIcon;
@BindView(R.id.check_auto_login)
CheckBox checkAutoLogin;
@BindView(R.id.check_remember_pwd)
CheckBox checkRememberPwd;
@BindView(R.id.text_forget_pwd)
TextView textForgetPwd;
@BindView(R.id.btn_login)
Button btnLogin;
@BindView(R.id.edit_username)
EditText editUsername;
@BindView(R.id.edit_password)
EditText editPassword;
@BindView(R.id.text_register)
TextView textRegister;
@BindView(R.id.check_hide_pwd)
CheckBox checkHidePwd;
private static final String TAG = "MainActivity";
private UserDao userDao;
private String textUserName;
private String textPassword;
private static boolean REMEMBER_PWD = false;
private static boolean AUTO_LOGIN = false;
SharedPreferenceUtil spu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
userDao = new UserDao(this);
spu = SharedPreferenceUtil.getInstance(this);
}
@Override
protected void onStart() {
super.onStart();
Intent intent = getIntent();
// 如果注册过
if (intent.getBooleanExtra(Constant.HAS_REGISTERED, false)) {
intent.removeExtra(Constant.HAS_REGISTERED);
editUsername.setText(spu.getString(Constant.USER_NAME));
editPassword.setText(spu.getString(Constant.PASSWORD));
} else {
// 如果勾选记住密码
if (spu.getBoolean(Constant.REMEMBER_PWD)) {
checkRememberPwd.setChecked(true);
editUsername.setText(spu.getString(Constant.USER_NAME));
editPassword.setText(spu.getString(Constant.PASSWORD));
} else {
editUsername.setText("");
editPassword.setText("");
}
// 如果勾选自动登录
if (spu.getBoolean(Constant.AUTO_LOGIN)) {
checkAutoLogin.setChecked(true);
Intent intentLogin = new Intent(MainActivity.this, HomeActivity.class);
startActivity(intentLogin);
}
}
}
@OnClick({R.id.check_auto_login, R.id.check_remember_pwd, R.id.btn_login, R.id.text_forget_pwd, R.id.text_register, R.id.check_hide_pwd})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.check_auto_login:
// 勾选自动登录时自动勾选记住密码
if (checkAutoLogin.isChecked()) {
checkRememberPwd.setChecked(true);
AUTO_LOGIN = true;
REMEMBER_PWD = true;
} else {
AUTO_LOGIN = false;
}
break;
case R.id.check_remember_pwd:
// 勾掉记住密码时自动勾掉自动登录
if (!checkRememberPwd.isChecked()) {
checkAutoLogin.setChecked(false);
AUTO_LOGIN = false;
REMEMBER_PWD = false;
} else {
REMEMBER_PWD = true;
}
break;
case R.id.btn_login:
// 检查非空
if (isNotEmpty()) {
// 获得用户输入
getEditText();
// 检查用户名密码
if (checkUser()) {
// 存入sp 用于接下来页面的显示
spu.putBoolean(Constant.REMEMBER_PWD, REMEMBER_PWD);
spu.putBoolean(Constant.AUTO_LOGIN, AUTO_LOGIN);
spu.putString(Constant.USER_NAME, textUserName);
spu.putString(Constant.PASSWORD, textPassword);
spu.putInt(Constant.USER_ID, getUserID());
Intent intentLogin = new Intent(MainActivity.this, HomeActivity.class);
startActivity(intentLogin);
finish();
} else {
Toast.makeText(this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "用户名或密码不能为空", Toast.LENGTH_SHORT).show();
}
break;
case R.id.text_forget_pwd:
// 忘记密码
Intent intentFind = new Intent(MainActivity.this, FindPwdActivity.class);
startActivity(intentFind);
break;
case R.id.text_register:
// 注册
Intent intentRegister = new Intent(MainActivity.this, RegisterActivity.class);
startActivity(intentRegister);
break;
case R.id.check_hide_pwd:
if (checkHidePwd.isChecked()) {
// 将密码显示出来
editPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
// 隐藏密码
editPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
// 将光标移动到文本最后
editPassword.setSelection(editPassword.getText().toString().length());
break;
default:
break;
}
}
/**
*
*
* @return
*/
public boolean isNotEmpty() {
return !"".equals(editUsername.getText().toString()) &&
!"".equals(editPassword.getText().toString());
}
/**
*
*/
public void getEditText() {
textUserName = editUsername.getText().toString();
textPassword = editPassword.getText().toString();
}
/**
*
*/
public boolean checkUser() {
List<UserBean> userBeans = userDao.queryByUserNameAndPassword(textUserName, textPassword);
return userBeans.size() != 0;
}
/**
* ID
*
* @return
*/
public int getUserID() {
List<UserBean> userBeans = userDao.queryByUserNameAndPassword(textUserName, textPassword);
return userBeans.get(0).getUserID();
}
}

@ -0,0 +1,203 @@
package com.example.sparrownotes;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import java.util.List;
import java.util.regex.Matcher;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
*
*/
public class RegisterActivity extends AppCompatActivity {
@BindView(R.id.btn_register)
Button btnRegister;
@BindView(R.id.btn_reset)
Button btnReset;
@BindView(R.id.check_hide_pwd_reg)
CheckBox checkHidePwdReg;
@BindView(R.id.check_hide_pwd_reg2)
CheckBox checkHidePwdReg2;
@BindView(R.id.edit_username_reg)
EditText editUsernameReg;
@BindView(R.id.edit_confirm_pwd_reg)
EditText editConfirmPwdReg;
@BindView(R.id.edit_email_reg)
EditText editEmailReg;
@BindView(R.id.edit_password_reg)
EditText editPasswordReg;
SharedPreferenceUtil spu;
private static final String TAG = "RegisterActivity";
private UserDao userDao;
private String textUserName;
private String textPassword;
private String textConfirmPwd;
private String textEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ButterKnife.bind(this);
userDao = new UserDao(this);
spu = SharedPreferenceUtil.getInstance(this);
}
@OnClick({R.id.btn_register, R.id.btn_reset, R.id.check_hide_pwd_reg, R.id.check_hide_pwd_reg2})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_register:
// 检验非空
if (isNotEmpty()) {
// 获得用户输入
getEditText();
// 检验密码
if (comparePwd()) {
// 检查邮箱格式
if (checkEmail()) {
// 检查邮箱是否可用
if (checkOnlyEmail()) {
insertUserIntoDB();
queryAll();
Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
intent.putExtra(Constant.HAS_REGISTERED, true);
startActivity(intent);
finish();
} else {
Toast.makeText(this, "邮箱已经被使用", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "邮箱格式错误", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "两次输入的密码不一致", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "用户名或密码不能为空", Toast.LENGTH_SHORT).show();
}
break;
case R.id.btn_reset:
editUsernameReg.setText("");
editPasswordReg.setText("");
editConfirmPwdReg.setText("");
editEmailReg.setText("");
break;
case R.id.check_hide_pwd_reg:
if (checkHidePwdReg.isChecked()) {
// 将密码显示出来
editPasswordReg.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
// 隐藏密码
editPasswordReg.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
// 将光标移动到文本最后
editPasswordReg.setSelection(editPasswordReg.getText().toString().length());
break;
case R.id.check_hide_pwd_reg2:
if (checkHidePwdReg2.isChecked()) {
// 将密码显示出来
editConfirmPwdReg.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
// 隐藏密码
editConfirmPwdReg.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
// 将光标移动到文本最后
editConfirmPwdReg.setSelection(editConfirmPwdReg.getText().toString().length());
break;
default:
break;
}
}
/**
*
*
* @return
*/
public boolean isNotEmpty() {
return !"".equals(editUsernameReg.getText().toString()) &&
!"".equals(editPasswordReg.getText().toString()) &&
!"".equals(editConfirmPwdReg.getText().toString());
}
/**
*
*/
public void getEditText() {
textUserName = editUsernameReg.getText().toString();
textPassword = editPasswordReg.getText().toString();
textConfirmPwd = editConfirmPwdReg.getText().toString();
textEmail = editEmailReg.getText().toString();
}
/**
*
*
* @return
*/
public boolean checkOnlyEmail() {
List<UserBean> userBeans = userDao.queryForWhat("email", textEmail);
return userBeans.size() == 0;
}
/**
*
*
* @return
*/
public boolean comparePwd() {
return textPassword.equals(textConfirmPwd);
}
/**
*
*
* @return
*/
public boolean checkEmail() {
Matcher emailMatcher = Constant.EMAIL_PATTERN.matcher(textEmail);
return emailMatcher.matches();
}
/**
*
*/
public void insertUserIntoDB() {
UserBean userBean = new UserBean(textUserName, textPassword, textEmail);
userDao.insert(userBean);
// 同时存到SP中
spu.putString(Constant.USER_NAME, textUserName);
spu.putString(Constant.PASSWORD, textPassword);
}
/**
*
*/
public void queryAll() {
List<UserBean> userBeans = userDao.queryAll();
for (int i = 0; i < userBeans.size(); i++) {
Log.d(TAG, "queryAll: " + userBeans.get(i).toString());
}
}
}

@ -0,0 +1,136 @@
package com.example.sparrownotes.bean;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
/**
*
* noteID ID
* title
* content
* category
* time
* imgResource (int)
* isTop
*/
@DatabaseTable(tableName = "tb_note")
public class NoteBean {
@DatabaseField(generatedId = true, columnName = "note_id")
private int noteID;
@DatabaseField(columnName = "user_id")
private int userID;
@DatabaseField(defaultValue = "无标题")
private String title;
@DatabaseField(defaultValue = "空")
private String content;
@DatabaseField(defaultValue = "未分类")
private String category;
@DatabaseField(defaultValue = "未知")
private String time;
@DatabaseField(columnName = "img_resource")
private int imgResource;
@DatabaseField(defaultValue = "0", columnName = "is_top")
private String isTop;
public NoteBean() {
}
public NoteBean(int userID, String title, String content, String category, String time) {
this.userID = userID;
this.title = title;
this.content = content;
this.category = category;
this.time = time;
}
public NoteBean(int userID, String title, String content, String category, String time, int imgResource) {
this.userID = userID;
this.title = title;
this.content = content;
this.category = category;
this.time = time;
this.imgResource = imgResource;
}
@Override
public String toString() {
return "NoteBean{" +
"noteID=" + noteID +
"userID=" + userID +
", title='" + title + '\'' +
", content='" + content + '\'' +
", category='" + category + '\'' +
", time='" + time + '\'' +
", imgResource='" + imgResource + '\'' +
", isTop='" + isTop + '\'' +
'}';
}
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
public String getTop() {
return isTop;
}
public void setTop(String isTop) {
this.isTop = isTop;
}
public int getNoteID() {
return noteID;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public int getImgResource() {
return imgResource;
}
public void setImgResource(int imgResource) {
this.imgResource = imgResource;
}
}

@ -0,0 +1,74 @@
package com.example.sparrownotes.bean;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
/**
*
* userID ID
* userName
* password
* email
*/
@DatabaseTable(tableName = "tb_user")
public class UserBean {
@DatabaseField(generatedId = true, columnName = "user_id")
private int userID;
@DatabaseField(columnName = "user_name")
private String userName;
@DatabaseField
private String password;
@DatabaseField
private String email;
public UserBean() {
}
public UserBean(String userName, String password, String email) {
this.userName = userName;
this.password = password;
this.email = email;
}
@Override
public String toString() {
return "UserBean{" +
"userID=" + userID +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", email='" + email + '\'' +
'}';
}
public int getUserID() {
return userID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

@ -0,0 +1,44 @@
package com.example.sparrownotes.bean.adapter;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
import java.util.List;
/**
* ViewPager
*/
public class MyPagerAdapter extends PagerAdapter {
private List<View> views;
public MyPagerAdapter(List<View> views) {
this.views = views;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
View view = views.get(position);
container.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView(views.get(position));
}
@Override
public int getCount() {
return views.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
}

@ -0,0 +1,221 @@
package com.example.sparrownotes.bean.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.view.menu.MenuPopupHelper;
import androidx.appcompat.widget.PopupMenu;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.example.sparrownotes.R;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.DialogUtil;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import java.lang.reflect.Field;
import java.util.List;
/**
* RecyclerView
*/
public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.ViewHolder> {
private List<NoteBean> notesList;
private Context context;
private NoteDao noteDao;
SharedPreferenceUtil spu;
static class ViewHolder extends RecyclerView.ViewHolder {
View noteView;
View itemLayout;
ImageView itemCateImage;
ImageView itemMenu;
TextView itemTitle;
TextView itemId;
TextView itemContent;
TextView itemTime;
TextView itemCategory;
public ViewHolder(@NonNull View itemView) {
super(itemView);
noteView = itemView;
itemId = itemView.findViewById(R.id.item_id);
itemTitle = itemView.findViewById(R.id.item_title);
itemContent = itemView.findViewById(R.id.item_content);
itemCategory = itemView.findViewById(R.id.item_category);
itemTime = itemView.findViewById(R.id.item_time);
itemMenu = itemView.findViewById(R.id.item_menu);
itemLayout = itemView.findViewById(R.id.item_layout);
itemCateImage = itemView.findViewById(R.id.item_cate_img);
}
}
public NoteAdapter(List<NoteBean> notesList, Context context) {
this.notesList = notesList;
this.context = context;
noteDao = new NoteDao(context);
spu = SharedPreferenceUtil.getInstance(context);
}
@SuppressLint("RestrictedApi")
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.note_item, parent, false);
final ViewHolder holder = new ViewHolder(view);
holder.itemMenu.setOnClickListener(v -> {
// 根据页面显示不同的菜单
if ("all".equals(Constant.PAGE_STATE)) {
PopupMenu popupMenu = new PopupMenu(v.getContext(), v, Gravity.RIGHT);
popupMenu.getMenuInflater().inflate(R.menu.item_menu_all, popupMenu.getMenu());
// 弹出式菜单的菜单项点击事件
popupMenu.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
case R.id.delete_all:
// 删除
removeData(holder.getAdapterPosition());
Toast.makeText(v.getContext(), "删除成功", Toast.LENGTH_SHORT).show();
break;
case R.id.top_all:
//置顶
setTop(holder.getAdapterPosition());
Toast.makeText(v.getContext(), "已置顶", Toast.LENGTH_SHORT).show();
break;
case R.id.edit_all:
//编辑
DialogUtil.editNoteDialog(context, notesList.get(holder.getAdapterPosition()).getNoteID());
break;
default:
break;
}
return false;
});
setIconsVisible(popupMenu, true);
popupMenu.show();
} else {
PopupMenu popupMenu = new PopupMenu(v.getContext(), v, Gravity.RIGHT);
popupMenu.getMenuInflater().inflate(R.menu.item_menu_top, popupMenu.getMenu());
// 弹出式菜单的菜单项点击事件
popupMenu.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
case R.id.delete_top:
// 删除
removeData(holder.getAdapterPosition());
Toast.makeText(v.getContext(), "删除成功", Toast.LENGTH_SHORT).show();
break;
case R.id.top_top:
// 取消置顶
notSetTop(holder.getAdapterPosition());
Toast.makeText(v.getContext(), "取消置顶", Toast.LENGTH_SHORT).show();
break;
case R.id.edit_top:
// 编辑
DialogUtil.editNoteDialog(context, notesList.get(holder.getAdapterPosition()).getNoteID());
break;
default:
break;
}
return false;
});
// 使弹出菜单的图标可见
setIconsVisible(popupMenu, true);
popupMenu.show();
}
});
return holder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
NoteBean noteItem = notesList.get(position);
holder.itemId.setText(String.valueOf(noteItem.getNoteID()));
holder.itemTitle.setText(noteItem.getTitle());
holder.itemContent.setText(noteItem.getContent());
holder.itemCategory.setText(noteItem.getCategory());
holder.itemTime.setText(noteItem.getTime());
int imgResource = noteItem.getImgResource();
/*
* Glide
* tomcaturl, tomcat
*
*
*/
Glide.with(context).load(imgResource).into(holder.itemCateImage);
}
@Override
public int getItemCount() {
return notesList.size();
}
/**
*
*
* @param position
*/
public void removeData(int position) {
// 从数据库删除
noteDao.delete(notesList.get(position).getNoteID());
// 从List中删除
notesList.remove(position);
notifyItemRemoved(position);
}
/**
* ()
*
* @param position
*/
public void setTop(int position) {
NoteBean noteItem = noteDao.queryById(notesList.get(position).getNoteID(), spu.getInt(Constant.USER_ID));
noteItem.setTop("1");
noteDao.update(noteItem);
notifyDataSetChanged();
}
/**
* ()
*
* @param position
*/
public void notSetTop(int position) {
NoteBean noteItem = noteDao.queryById(notesList.get(position).getNoteID(), spu.getInt(Constant.USER_ID));
noteItem.setTop("0");
noteDao.update(noteItem);
notesList.remove(position);
notifyDataSetChanged();
}
/**
* menu
*
* @param popupMenu
* @param flag
*/
@SuppressLint("RestrictedApi")
private void setIconsVisible(PopupMenu popupMenu, boolean flag) {
//判断menu是否为空
if (popupMenu != null) {
try {
Field field = popupMenu.getClass().getDeclaredField("mPopup");
field.setAccessible(true);
MenuPopupHelper mHelper = (MenuPopupHelper) field.get(popupMenu);
mHelper.setForceShowIcon(flag);
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,210 @@
package com.example.sparrownotes.dao;
import android.content.Context;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.util.DBHelper;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;
/**
*
*
* @author Horsen
*/
public class NoteDao {
private Dao<NoteBean, Integer> dao;
public NoteDao(Context context) {
try {
this.dao = DBHelper.getInstance(context).getDao(NoteBean.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param data
*/
public void create(NoteBean data) {
try {
dao.createOrUpdate(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param datas
*/
public void createList(List<NoteBean> datas) {
try {
dao.create(datas);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* note
* create:
* createIfNotExists:
* createOrUpdate:id
*
* @param data
*/
public void insert(NoteBean data) {
try {
dao.createIfNotExists(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* id
*
* @param id
*/
public void delete(int id) {
try {
dao.deleteById(id);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param data
*/
public void delete(NoteBean data) {
try {
dao.delete(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param datas
*/
public void deleteList(List<NoteBean> datas) {
try {
dao.delete(datas);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*/
public void deleteAll() {
try {
dao.delete(dao.queryForAll());
} catch (Exception e) {
}
}
/**
*
*
* @param data
*/
public void update(NoteBean data) {
try {
dao.update(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @return
*/
public List<NoteBean> queryAll(int userID) {
List<NoteBean> notes = null;
try {
notes = dao.queryBuilder()
.orderBy("note_id", false)
.where().eq("user_id", userID)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return notes;
}
/**
* ID
*
* @param id
* @return
*/
public NoteBean queryById(int id, int userID) {
NoteBean note = null;
try {
note = dao.queryBuilder()
.where().eq("note_id", id)
.and().eq("user_id", userID)
.queryForFirst();
} catch (SQLException e) {
e.printStackTrace();
}
return note;
}
/**
*
*
* @param columnName
* @param data
* @return
*/
public List<NoteBean> queryForWhat(String columnName, String data, int userID) {
List<NoteBean> notes = null;
try {
notes = dao.queryBuilder()
.orderBy("note_id", false)
.where().eq(columnName, data)
.and().eq("user_id", userID)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return notes;
}
/**
*
*
* @param columnName
* @param data
* @return
*/
public List<NoteBean> queryLikeWhat(String columnName, String data, int userID) {
List<NoteBean> notes = null;
try {
notes = dao.queryBuilder()
.orderBy("note_id", false)
.where().like(columnName, "%" + data + "%")
.and().eq("user_id", userID)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return notes;
}
}

@ -0,0 +1,200 @@
package com.example.sparrownotes.dao;
import android.content.Context;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.util.DBHelper;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;
/**
*
*
* @author Horsen
*/
public class UserDao {
private Dao<UserBean, Integer> dao;
public UserDao(Context context) {
try {
this.dao = DBHelper.getInstance(context).getDao(UserBean.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param data
*/
public void create(UserBean data) {
try {
dao.createOrUpdate(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param datas
*/
public void createList(List<UserBean> datas) {
try {
dao.create(datas);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* user
* create:
* createIfNotExists:
* createOrUpdate:id
*
* @param data
*/
public void insert(UserBean data) {
try {
dao.createIfNotExists(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* id
*
* @param id
*/
public void delete(int id) {
try {
dao.deleteById(id);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param data
*/
public void delete(UserBean data) {
try {
dao.delete(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @param datas
*/
public void deleteList(List<UserBean> datas) {
try {
dao.delete(datas);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*/
public void deleteAll() {
try {
dao.delete(dao.queryForAll());
} catch (Exception e) {
}
}
/**
*
*
* @param data
*/
public void update(UserBean data) {
try {
dao.update(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
* @return
*/
public List<UserBean> queryAll() {
List<UserBean> users = null;
try {
users = dao.queryForAll();
} catch (SQLException e) {
e.printStackTrace();
}
return users;
}
/**
* ID
*
* @param id
* @return
*/
public UserBean queryById(int id) {
UserBean user = null;
try {
user = dao.queryForId(id);
} catch (SQLException e) {
e.printStackTrace();
}
return user;
}
/**
*
*
* @param columnName
* @param data
* @return
*/
public List<UserBean> queryForWhat(String columnName, String data) {
List<UserBean> users = null;
try {
users = dao.queryForEq(columnName, data);
} catch (SQLException e) {
e.printStackTrace();
}
return users;
}
/**
*
*
* @param userName
* @param password
* @return
*/
public List<UserBean> queryByUserNameAndPassword(String userName, String password) {
List<UserBean> users = null;
try {
users = dao.queryBuilder()
.orderBy("user_id", true)
.where().eq("user_name", userName)
.and().eq("password", password)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return users;
}
}

@ -0,0 +1,322 @@
package com.example.sparrownotes.fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.sparrownotes.R;
import com.example.sparrownotes.bean.adapter.MyPagerAdapter;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.NoScrollViewPager;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
/**
* note
*/
public class AddFragment extends Fragment {
@BindView(R.id.view_pager_add)
NoScrollViewPager viewPager;
@BindView(R.id.text_reset)
TextView textReset;
@BindView(R.id.text_save)
TextView textSave;
@BindView(R.id.img_account)
ImageView imgAccount;
@BindView(R.id.img_date)
ImageView imgDate;
@BindView(R.id.img_link)
ImageView imgLink;
@BindView(R.id.img_bill)
ImageView imgBill;
@BindView(R.id.img_location)
ImageView imgLocation;
@BindView(R.id.img_mood)
ImageView imgMood;
@BindView(R.id.img_note)
ImageView imgNote;
@BindView(R.id.img_question)
ImageView imgQuestion;
TextView[] textViews = new TextView[5];
String title = "", content = "";
int imgResource;
View[] views = new View[8];
int index = 0;
private Unbinder unbinder;
private String category = "";
private static final String TAG = "AddFragment";
private List<View> viewList = new ArrayList<>();
private NoteDao noteDao;
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(getActivity());
public AddFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add, container, false);
// 返回一个Unbinder值进行解绑注意这里的this不能使用getActivity()
unbinder = ButterKnife.bind(this, view);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
noteDao = new NoteDao(getActivity());
initView();
// 置顶默认类型
category = getString(R.string.note);
}
public void initView() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
// 创建不同的添加页面
for (int i = 0; i < Constant.LAYOUTS.length; i++) {
views[i] = inflater.inflate(Constant.LAYOUTS[i], null);
viewList.add(views[i]);
}
MyPagerAdapter adapter = new MyPagerAdapter(viewList);
viewPager.setOffscreenPageLimit(viewList.size());
viewPager.setAdapter(adapter);
}
/**
*
*/
public void insertNoteIntoDB(String category) {
getTitleAndContents(category);
NoteBean noteBean = new NoteBean(spu.getInt(Constant.USER_ID),title, content, category, "创建于 " + getToday(), imgResource);
noteDao.insert(noteBean);
}
/**
* , ViewPager
*
* @param view
*/
@OnClick({R.id.text_reset, R.id.text_save, R.id.img_account, R.id.img_date, R.id.img_link, R.id.img_bill, R.id.img_location, R.id.img_mood, R.id.img_note, R.id.img_question})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.text_reset:
// 清空输入
clearTitleAndContents(category);
break;
case R.id.text_save:
// 保存输入
insertNoteIntoDB(category);
clearTitleAndContents(category);
Toast.makeText(getContext(), "添加成功", Toast.LENGTH_SHORT).show();
break;
case R.id.img_note:
category = getString(R.string.note);
index = 0;
break;
case R.id.img_link:
category = getString(R.string.link);
index = 1;
break;
case R.id.img_location:
category = getString(R.string.location);
index = 2;
break;
case R.id.img_bill:
category = getString(R.string.bill);
index = 3;
break;
case R.id.img_date:
category = getString(R.string.date);
index = 4;
break;
case R.id.img_mood:
category = getString(R.string.mood);
index = 5;
break;
case R.id.img_account:
category = getString(R.string.account);
index = 6;
break;
case R.id.img_question:
category = getString(R.string.question);
index = 7;
break;
default:
break;
}
viewPager.setCurrentItem(index);
}
/**
*
*
* @return
*/
public String getToday() {
// 日期格式
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
//获取当前时间
Date date = new Date(System.currentTimeMillis());
return simpleDateFormat.format(date);
}
/**
*
*
* @param today
* @param someday
* @return
*/
public String getDayDistance(String today, String someday) {
try {
SimpleDateFormat todayFormat = new SimpleDateFormat("yyyy.MM.dd");
SimpleDateFormat somedayFormat = new SimpleDateFormat("yyyy年MM月dd日");
long todayTime = todayFormat.parse(today).getTime();
long somedayTime = somedayFormat.parse(someday).getTime();
Log.d(TAG, "getDayDistance: " + todayTime);
Log.d(TAG, "getDayDistance: " + somedayTime);
// 获得毫秒差 除以 1000*3600*24 得到天数差
long distance = (todayTime - somedayTime) / (1000 * 3600 * 24);
// 根据正负判断日期在前还是在后
if (distance >= 0) {
return "\n距今已经 " + distance + " 天";
}
return "\n距今还有 " + (somedayTime - todayTime) / (1000 * 3600 * 24) + " 天";
} catch (ParseException e) {
e.printStackTrace();
}
return "这个日期...不对吧";
}
/**
* onDestroyView
*/
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/**
*
*
* @param category
*/
public void getTitleAndContents(String category) {
textViews[0] = views[index].findViewById(R.id.title);
title = textViews[0].getText().toString().trim();
switch (category) {
case "便签":
case "链接":
case "位置":
case "心情":
textViews[1] = views[index].findViewById(R.id.content_1);
content = textViews[1].getText().toString().trim();
break;
case "消费":
textViews[1] = views[index].findViewById(R.id.year);
textViews[2] = views[index].findViewById(R.id.month);
textViews[3] = views[index].findViewById(R.id.day);
textViews[4] = views[index].findViewById(R.id.content_2);
content = "时间:" + textViews[1].getText().toString().trim() + "年"
+ textViews[2].getText().toString().trim() + "月"
+ textViews[3].getText().toString().trim() + "日"
+ "\n消费" + textViews[4].getText().toString().trim() + "元";
break;
case "日子":
textViews[1] = views[index].findViewById(R.id.year);
textViews[2] = views[index].findViewById(R.id.month);
textViews[3] = views[index].findViewById(R.id.day);
String date = textViews[1].getText().toString().trim() + "年"
+ textViews[2].getText().toString().trim() + "月"
+ textViews[3].getText().toString().trim() + "日";
content = date + getDayDistance(getToday(), date);
break;
case "账户":
textViews[1] = views[index].findViewById(R.id.content_1);
textViews[2] = views[index].findViewById(R.id.content_2);
content = "账户:" + textViews[1].getText().toString().trim()
+ "\n密码" + textViews[2].getText().toString().trim();
break;
case "三省":
textViews[1] = views[index].findViewById(R.id.content_1);
textViews[2] = views[index].findViewById(R.id.content_2);
title = "学习否:" + textViews[0].getText().toString().trim();
content = "学几时:" + textViews[1].getText().toString().trim()
+ "\n学之何" + textViews[2].getText().toString().trim();
break;
default:
break;
}
imgResource = Constant.IMG_RESOURCES[index];
}
/**
*
*
* @param category
*/
public void clearTitleAndContents(String category) {
textViews[0] = views[index].findViewById(R.id.title);
title = textViews[0].getText().toString().trim();
switch (category) {
case "便签":
case "链接":
case "位置":
case "心情":
textViews[1] = views[index].findViewById(R.id.content_1);
for (int i = 0; i < 2; i++) {
textViews[i].setText("");
}
break;
case "消费":
textViews[1] = views[index].findViewById(R.id.year);
textViews[2] = views[index].findViewById(R.id.month);
textViews[3] = views[index].findViewById(R.id.day);
textViews[4] = views[index].findViewById(R.id.content_2);
for (int i = 0; i < 5; i++) {
textViews[i].setText("");
}
break;
case "日子":
textViews[1] = views[index].findViewById(R.id.year);
textViews[2] = views[index].findViewById(R.id.month);
textViews[3] = views[index].findViewById(R.id.day);
for (int i = 0; i < 4; i++) {
textViews[i].setText("");
}
break;
case "账户":
case "三省":
textViews[1] = views[index].findViewById(R.id.content_1);
textViews[2] = views[index].findViewById(R.id.content_2);
for (int i = 0; i < 3; i++) {
textViews[i].setText("");
}
break;
default:
break;
}
}
}

@ -0,0 +1,115 @@
package com.example.sparrownotes.fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.example.sparrownotes.R;
import com.example.sparrownotes.bean.adapter.NoteAdapter;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import java.util.ArrayList;
import java.util.List;
/**
* note
*/
public class AllFragment extends Fragment {
RecyclerView recyclerView;
SwipeRefreshLayout swipeRefresh;
NoteAdapter adapter;
private List<NoteBean> notesList = new ArrayList<>();
private NoteDao noteDao;
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(getActivity());
public AllFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_all, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
noteDao = new NoteDao(getActivity());
initData();
initView();
}
/**
*
*/
@SuppressLint("ResourceAsColor")
public void initView() {
// 下拉刷新组件
swipeRefresh = getActivity().findViewById(R.id.swipe_refresh_all);
swipeRefresh.setColorSchemeColors(R.color.colorPrimary);
swipeRefresh.setOnRefreshListener(this::refreshNotes);
// 替代ListView
recyclerView = getActivity().findViewById(R.id.recycler_view_all);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
adapter = new NoteAdapter(notesList, getActivity());
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
/**
*
*/
public void initData() {
List<NoteBean> noteBeams = noteDao.queryAll(spu.getInt(Constant.USER_ID));
notesList.addAll(noteBeams);
}
/**
*
*/
public void updateData() {
notesList.clear();
// 获得sp中的查询条件 更新数据源
String column = spu.getString(Constant.SEARCH_FOR_WHAT);
String value = spu.getString(Constant.SEARCH_VALUE);
if (column != "" && value != "") {
List<NoteBean> noteBeans = noteDao.queryLikeWhat(column, value,spu.getInt(Constant.USER_ID));
notesList.addAll(noteBeans);
// 用后即删
spu.removeKey(Constant.SEARCH_FOR_WHAT);
spu.removeKey(Constant.SEARCH_VALUE);
} else {
initData();
}
adapter.notifyDataSetChanged();
}
/**
*
*/
public void refreshNotes() {
new Thread(() -> {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
getActivity().runOnUiThread(() -> {
updateData();
swipeRefresh.setRefreshing(false);
});
}).start();
}
}

@ -0,0 +1,162 @@
package com.example.sparrownotes.fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.example.sparrownotes.R;
import com.example.sparrownotes.bean.adapter.NoteAdapter;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.dao.*;
import com.example.sparrownotes.util.Constant;
import com.example.sparrownotes.util.SharedPreferenceUtil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* note
*/
public class TopFragment extends Fragment {
RecyclerView recyclerView;
SwipeRefreshLayout swipeRefresh;
NoteAdapter adapter;
TextView textTime, textGreeting;
private List<NoteBean> notesList = new ArrayList<>();
private static final String TAG = "TopFragment";
private NoteDao noteDao;
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(getActivity());
public TopFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_top, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
noteDao = new NoteDao(getActivity());
initData();
initView();
updateData();
}
@Override
public void onResume() {
super.onResume();
// 发送消息 更新时间
handler.sendEmptyMessage(Constant.UPDATE_TIME);
}
@Override
public void onPause() {
super.onPause();
// 停止更新时间
handler.removeCallbacksAndMessages(null);
}
/**
*
*/
@SuppressLint("ResourceAsColor")
public void initView() {
// 下拉刷新组件
swipeRefresh = getActivity().findViewById(R.id.swipe_refresh_top);
swipeRefresh.setColorSchemeColors(R.color.colorPrimary);
swipeRefresh.setOnRefreshListener(this::refreshNotes);
// 代替ListView
recyclerView = getActivity().findViewById(R.id.recycler_view_top);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
adapter = new NoteAdapter(notesList, getActivity());
recyclerView.setAdapter(adapter);
textTime = getActivity().findViewById(R.id.text_time);
textGreeting = getActivity().findViewById(R.id.text_greeting);
}
/**
*
*/
public void initData() {
List<NoteBean> noteBeans = noteDao.queryForWhat("is_top", "1", spu.getInt(Constant.USER_ID));
notesList.addAll(noteBeans);
}
/**
* ()
*/
public void updateData() {
notesList.clear();
initData();
adapter.notifyDataSetChanged();
}
/**
*
*/
public void refreshNotes() {
new Thread(() -> {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
getActivity().runOnUiThread(() -> {
updateData();
swipeRefresh.setRefreshing(false);
});
}).start();
}
/**
*
*
* @return
*/
public String getToday() {
// 日期格式
SimpleDateFormat weekFormat = new SimpleDateFormat("EEEE");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
//获取当前时间
Date dateTime = new Date(System.currentTimeMillis());
String week = weekFormat.format(dateTime);
String date = dateFormat.format(dateTime);
String time = timeFormat.format(dateTime);
return week + "\n" + date + "\n" + time;
}
/**
* 线线
*
*/
@SuppressLint("HandlerLeak")
private Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
if (msg.what == Constant.UPDATE_TIME) {
textTime.setText(getToday());
sendEmptyMessageDelayed(Constant.UPDATE_TIME, 1000);
}
}
};
}

@ -0,0 +1,41 @@
package com.example.sparrownotes.util;
import com.example.sparrownotes.R;
import java.util.regex.Pattern;
public class Constant {
// 数据库名和版本号
public static final String DB_NAME = "sparrow.db";
public static final int DB_VERSION = 1;
// 用来判断邮箱格式的正则表达式
public static final String EMAIL_REGEX = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
public static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX);
// 用来存储用户登录操作的键
public static final String HAS_REGISTERED = "has_registered";
public static final String REMEMBER_PWD = "remember_pwd";
public static final String AUTO_LOGIN = "auto_login";
public static final String USER_NAME = "user_name";
public static final String PASSWORD = "password";
public static final String USER_ID = "userId";
// 用来标记fragment的键
public static final String TOP_TAG = "top";
public static final String ADD_TAG = "add";
public static final String LIST_TAG = "list";
// 标记当前显示的页面
public static String PAGE_STATE = "top";
// 用来更新时间的消息
public static final int UPDATE_TIME = 1;
// 网络地址前后缀
public static final String PREFIX_URL = "http://192.168.0.110:8080/sparrow_notes/cate_";
public static final String SUFFIX_URL = ".png";
// 存储查找条件的键
public static final String SEARCH_FOR_WHAT = "what";
public static final String SEARCH_VALUE = "value";
// 不同的添加布局 图片地址 图片资源(int)
public static final int[] LAYOUTS = {R.layout.add_note, R.layout.add_link, R.layout.add_location, R.layout.add_bill,
R.layout.add_date, R.layout.add_mood, R.layout.add_account, R.layout.add_question};
public static final String[] IMG_URLS = {"note", "link", "location", "bill", "date", "mood", "account", "question"};
public static final int[] IMG_RESOURCES = {R.drawable.cate_note, R.drawable.cate_link, R.drawable.cate_location,
R.drawable.cate_bill, R.drawable.cate_date, R.drawable.cate_mood, R.drawable.cate_account, R.drawable.cate_question};
}

@ -0,0 +1,109 @@
package com.example.sparrownotes.util;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.ArrayMap;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.util.Constant;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import java.sql.SQLException;
/**
*
*/
@SuppressWarnings("AlibabaRemoveCommentedCode")
public class DBHelper extends OrmLiteSqliteOpenHelper {
/**
* 线, , 线
* AppDaoMap
*/
private static DBHelper dbHelper = null;
private ArrayMap<String, Dao> daos = new ArrayMap<>();
public static synchronized DBHelper getInstance(Context context) {
if (dbHelper == null) {
synchronized (DBHelper.class) {
if (dbHelper == null) {
dbHelper = new DBHelper(context);
}
}
}
return dbHelper;
}
private DBHelper(Context context) {
super(context, Constant.DB_NAME, null, Constant.DB_VERSION);
}
/**
*
*
* @param sqLiteDatabase
* @param connectionSource
*/
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, UserBean.class);
TableUtils.createTable(connectionSource, NoteBean.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*
*
* @param sqLiteDatabase
* @param connectionSource
* @param i
* @param i1
*/
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource, int i, int i1) {
try {
TableUtils.dropTable(connectionSource, UserBean.class, false);
TableUtils.dropTable(connectionSource, NoteBean.class, false);
onCreate(sqLiteDatabase, connectionSource);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* DaoDao, daos, daos
*/
@Override
public synchronized Dao getDao(Class clazz) throws SQLException {
Dao dao = null;
String className = clazz.getSimpleName();
if (daos.containsKey(className)) {
dao = daos.get(className);
}
if (dao == null) {
dao = super.getDao(clazz);
daos.put(className, dao);
}
return dao;
}
/**
*
*/
@Override
public void close() {
super.close();
for (String key : daos.keySet()) {
Dao dao = daos.get(key);
dao = null;
}
}
}

@ -0,0 +1,228 @@
package com.example.sparrownotes.util;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.sparrownotes.MainActivity;
import com.example.sparrownotes.R;
import com.example.sparrownotes.bean.NoteBean;
import com.example.sparrownotes.bean.UserBean;
import com.example.sparrownotes.dao.*;
/**
*
*
*/
public class DialogUtil {
/**
*
*
* @param context
*/
public static void searchTitleDialog(Context context) {
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(context);
// 获得布局管理器
LayoutInflater inflater = LayoutInflater.from(context);
// 将布局转换成View
View view = inflater.inflate(R.layout.search_title_dialog, null);
final EditText editText = view.findViewById(R.id.edit);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("按标题查找")
.setView(view)
.setIcon(R.drawable.search_icon_title)
.setPositiveButton("确定", (dialog, which) -> {
// 搜索条件传入sp
spu.putString(Constant.SEARCH_FOR_WHAT, "title");
spu.putString(Constant.SEARCH_VALUE, editText.getText().toString());
// 提醒用户下拉刷新
Toast.makeText(context, "下拉刷新", Toast.LENGTH_SHORT).show();
})
.setNegativeButton("取消", (dialog, which) -> {
});
builder.create().show();
}
/**
*
*
* @param context
*/
public static void searchContentDialog(Context context) {
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(context);
// 获得布局管理器
LayoutInflater inflater = LayoutInflater.from(context);
// 将布局转换成View
View view = inflater.inflate(R.layout.search_content_dialog, null);
final EditText editText = view.findViewById(R.id.edit);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("按内容查找")
.setView(view)
.setIcon(R.drawable.search_icon_content)
.setPositiveButton("确定", (dialog, which) -> {
// 搜索条件传入sp
spu.putString(Constant.SEARCH_FOR_WHAT, "content");
spu.putString(Constant.SEARCH_VALUE, editText.getText().toString());
// 提醒用户下拉刷新
Toast.makeText(context, "下拉刷新", Toast.LENGTH_SHORT).show();
})
.setNegativeButton("取消", (dialog, which) -> {
});
builder.create().show();
}
/**
*
*
* @param context
*/
public static void searchCategoryDialog(final Context context) {
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(context);
final String[] categories = new String[]{"便签", "链接", "位置", "消费", "日子", "心情", "账户", "三省"};
final String[] category = new String[1];
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("按分类查找")
.setIcon(R.drawable.search_icon_category)
.setSingleChoiceItems(categories, 0, (dialog, which) -> category[0] = categories[which])
.setPositiveButton("确认", (dialog, which) -> {
// 搜索条件传入sp
spu.putString(Constant.SEARCH_FOR_WHAT, "category");
spu.putString(Constant.SEARCH_VALUE, category[0]);
// 提醒用户下拉刷新
Toast.makeText(context, "下拉刷新", Toast.LENGTH_SHORT).show();
})
.setNegativeButton("取消", null)
.show();
}
/**
* note
*
* @param context
*/
public static void editNoteDialog(final Context context, int noteID) {
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(context);
NoteDao noteDao = new NoteDao(context);
NoteBean noteItem = noteDao.queryById(noteID, spu.getInt(Constant.USER_ID));
// 获得布局管理器
LayoutInflater inflater = LayoutInflater.from(context);
// 将布局转换成View
View view = inflater.inflate(R.layout.edit_note_dialog, null);
final EditText editTile, editContent;
editTile = view.findViewById(R.id.edit_title);
editContent = view.findViewById(R.id.edit_content);
// 将原本的值显示出来
editTile.setText(noteItem.getTitle());
editContent.setText(noteItem.getContent());
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("编辑")
.setView(view)
.setIcon(R.drawable.icon_edit)
.setPositiveButton("确认", (dialog, which) -> {
// 将用户输入存入数据库
noteItem.setTitle(editTile.getText().toString().trim());
noteItem.setContent(editContent.getText().toString().trim());
noteDao.update(noteItem);
// 提醒用户下拉刷新
Toast.makeText(context, "下拉刷新", Toast.LENGTH_SHORT).show();
})
.setNegativeButton("取消", null)
.show();
}
/**
*
*
* @param context
*/
public static void editInfoDialog(final Context context, int userID) {
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(context);
UserDao userDao = new UserDao(context);
UserBean userItem = userDao.queryById(userID);
// 获得布局管理器
LayoutInflater inflater = LayoutInflater.from(context);
// 将布局转换成View
View view = inflater.inflate(R.layout.edit_info_dialog, null);
final EditText editUsername, editPassword, editEmail;
editUsername = view.findViewById(R.id.edit_username_info);
editPassword = view.findViewById(R.id.edit_password_info);
editEmail = view.findViewById(R.id.edit_email_info);
// 将原本的值显示出来
editUsername.setText(userItem.getUserName());
editPassword.setText(userItem.getPassword());
editEmail.setText(userItem.getEmail());
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("修改信息")
.setView(view)
.setIcon(R.drawable.icon_gear)
.setPositiveButton("确认", (dialog, which) -> {
// 将用户输入存入数据库
userItem.setUserName(editUsername.getText().toString().trim());
userItem.setPassword(editPassword.getText().toString().trim());
userItem.setEmail(editEmail.getText().toString().trim());
userDao.update(userItem);
// 跳转回登录页面并且清除勾选
spu.putBoolean(Constant.AUTO_LOGIN, false);
spu.putBoolean(Constant.REMEMBER_PWD, false);
Intent intent = new Intent(context, MainActivity.class);
context.startActivity(intent);
})
.setNegativeButton("取消", null)
.show();
}
/**
*
*
*
* @param context
*/
public static void editGreetingDialog(final Context context) {
// 获得布局管理器
LayoutInflater inflater = LayoutInflater.from(context);
// 将布局转换成View
View view = inflater.inflate(R.layout.edit_greeting_dialog, null);
final EditText editText;
final TextView textView;
editText = view.findViewById(R.id.edit);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("修改问候语")
.setView(view)
.setIcon(R.drawable.icon_smile)
.setPositiveButton("确认", (dialog, which) -> {
editText.getText().toString();
})
.setNegativeButton("取消", null)
.show();
}
/**
*
*
* @param context
*/
public static void dismissDialog(final Context context, int userID) {
SharedPreferenceUtil spu = SharedPreferenceUtil.getInstance(context);
UserDao userDao = new UserDao(context);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("提示")
.setMessage("是否要注销账户")
.setIcon(R.drawable.icon_warning)
.setPositiveButton("确认", (dialog, which) -> {
userDao.delete(userID);
// 跳转回登录页面并且清除勾选
spu.putBoolean(Constant.AUTO_LOGIN, false);
spu.putBoolean(Constant.REMEMBER_PWD, false);
Intent intent = new Intent(context, MainActivity.class);
context.startActivity(intent);
})
.setNegativeButton("取消", null)
.show();
}
}

@ -0,0 +1,39 @@
package com.example.sparrownotes.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
/**
* ViewPager
*/
public class NoScrollViewPager extends ViewPager {
/**
* truefalse
*/
private boolean isPagingEnabled = false;
public NoScrollViewPager(Context context) {
super(context);
}
public NoScrollViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return this.isPagingEnabled && super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return this.isPagingEnabled && super.onInterceptTouchEvent(event);
}
public void setPagerEnabled(boolean enabled) {
this.isPagingEnabled = enabled;
}
}

@ -0,0 +1,161 @@
package com.example.sparrownotes.util;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
/**
*
*/
public class SharedPreferenceUtil {
/**
*
*/
private static final String NAME = "sparrow_share";
private Context context;
private SharedPreferences.Editor editor;
private SharedPreferences share;
private static SharedPreferenceUtil sharedPreferenceUtil;
/**
* SharedPreferences
*
* @param context
*/
@SuppressLint("CommitPrefEdits")
private SharedPreferenceUtil(Context context) {
this.context = context;
if (context != null) {
share = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
editor = share.edit();
}
}
public static SharedPreferenceUtil getInstance(Context con) {
if (sharedPreferenceUtil == null) {
sharedPreferenceUtil = new SharedPreferenceUtil(con);
}
return sharedPreferenceUtil;
}
/**
* String
*
* @param key
* @param value
*/
public void putString(String key, String value) {
if (null == value) {
value = "";
}
editor.putString(key, value);
editor.apply();
}
/**
* int
*
* @param key
* @param value
* @return
*/
public void putInt(String key, int value) {
editor.putInt(key, value);
editor.apply();
}
/**
* Float
*
* @param key
* @param value
*/
public void putFloat(String key, float value) {
editor.putFloat(key, value);
editor.apply();
}
/**
* boolean
*
* @param key
* @param value
*/
public void putBoolean(String key, boolean value) {
editor.putBoolean(key, value);
editor.apply();
}
/**
* Long
*
* @param key
* @param value
*/
public void putLong(String key, long value) {
editor.putLong(key, value);
editor.apply();
}
/**
* String
*
* @param key
*/
public String getString(String key) {
return share.getString(key, "");
}
/**
* int
*
* @param key
* @return int
*/
public int getInt(String key) {
return share.getInt(key, 0);
}
/**
* Float
*
* @param key
* @return float
*/
public float getFloat(String key) {
return share.getFloat(key, 0.00f);
}
/**
* Long
*
* @param key
* @return long
*/
public long getLong(String key) {
return share.getLong(key, 0);
}
/**
* boolean
*
* @param key
* @return boolean
*/
public boolean getBoolean(String key) {
return share.getBoolean(key, false);
}
/**
*
*
* @param key
*/
public void removeKey(String key) {
editor.remove(key);
editor.apply();
}
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@string/duration_time"
android:fromXDelta="0"
android:toXDelta="-100%p" />
</set>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@string/duration_time"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@string/duration_time"
android:fromXDelta="-100.0%p"
android:toXDelta="0.0" />
</set>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@string/duration_time"
android:fromXDelta="0.0"
android:toXDelta="100.0%p" />
</set>

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圆角的半径 -->
<corners android:radius="10dp"/>
<!-- 填充颜色 -->
<solid android:color="@color/button_light_black"/>
</shape>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 正常状态 -->
<item android:drawable="@drawable/btn_cancel_normal" android:state_pressed="false"/>
<!-- 按下状态 -->
<item android:drawable="@drawable/btn_login_pressed" android:state_pressed="true"/>
</selector>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圆角的半径 -->
<corners android:radius="10dp"/>
<!-- 填充颜色 -->
<solid android:color="@color/button_black"/>
</shape>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圆角的半径 -->
<corners android:radius="10dp"/>
<!-- 填充颜色 -->
<solid android:color="@color/button_grey"/>
</shape>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 正常状态 -->
<item android:drawable="@drawable/btn_login_normal" android:state_pressed="false"/>
<!-- 按下状态 -->
<item android:drawable="@drawable/btn_login_pressed" android:state_pressed="true"/>
</selector>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 正常状态 -->
<item android:drawable="@drawable/eye_closed" android:state_checked="false"/>
<!-- 选中状态 -->
<item android:drawable="@drawable/eye_open" android:state_checked="true"/>
</selector>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dock_add_fill" android:state_checked="true" />
<item android:drawable="@drawable/dock_add_line" android:state_checked="false" />
</selector>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dock_list_fill" android:state_checked="true" />
<item android:drawable="@drawable/dock_list_line" android:state_checked="false" />
</selector>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dock_top_fill" android:state_checked="true" />
<item android:drawable="@drawable/dock_top_line" android:state_checked="false" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save