hsiao 7 jaren geleden
bovenliggende
commit
7ed59aa6e9
65 gewijzigde bestanden met toevoegingen van 1324 en 0 verwijderingen
  1. 9
    0
      .gitignore
  2. 19
    0
      .idea/gradle.xml
  3. 33
    0
      .idea/misc.xml
  4. 10
    0
      .idea/modules.xml
  5. 12
    0
      .idea/runConfigurations.xml
  6. 29
    0
      build.gradle
  7. 17
    0
      gradle.properties
  8. BIN
      gradle/wrapper/gradle-wrapper.jar
  9. 6
    0
      gradle/wrapper/gradle-wrapper.properties
  10. 160
    0
      gradlew
  11. 90
    0
      gradlew.bat
  12. 1
    0
      lesson01/.gitignore
  13. 32
    0
      lesson01/build.gradle
  14. 21
    0
      lesson01/proguard-rules.pro
  15. 26
    0
      lesson01/src/androidTest/java/io/hsiao/lesson01/ExampleInstrumentedTest.java
  16. 23
    0
      lesson01/src/main/AndroidManifest.xml
  17. 32
    0
      lesson01/src/main/java/io/hsiao/lesson01/FooActivity.java
  18. 84
    0
      lesson01/src/main/java/io/hsiao/lesson01/MainActivity.java
  19. 19
    0
      lesson01/src/main/java/io/hsiao/lesson01/service/LoginValidator.java
  20. 34
    0
      lesson01/src/main/res/drawable-v24/ic_launcher_foreground.xml
  21. 170
    0
      lesson01/src/main/res/drawable/ic_launcher_background.xml
  22. 14
    0
      lesson01/src/main/res/layout/activity_foo.xml
  23. 56
    0
      lesson01/src/main/res/layout/activity_main.xml
  24. 5
    0
      lesson01/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  25. 5
    0
      lesson01/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  26. BIN
      lesson01/src/main/res/mipmap-hdpi/ic_launcher.png
  27. BIN
      lesson01/src/main/res/mipmap-hdpi/ic_launcher_round.png
  28. BIN
      lesson01/src/main/res/mipmap-mdpi/ic_launcher.png
  29. BIN
      lesson01/src/main/res/mipmap-mdpi/ic_launcher_round.png
  30. BIN
      lesson01/src/main/res/mipmap-xhdpi/ic_launcher.png
  31. BIN
      lesson01/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  32. BIN
      lesson01/src/main/res/mipmap-xxhdpi/ic_launcher.png
  33. BIN
      lesson01/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  34. BIN
      lesson01/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  35. BIN
      lesson01/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  36. 4
    0
      lesson01/src/main/res/values/colors.xml
  37. 3
    0
      lesson01/src/main/res/values/strings.xml
  38. 8
    0
      lesson01/src/main/res/values/styles.xml
  39. 17
    0
      lesson01/src/test/java/io/hsiao/lesson01/ExampleUnitTest.java
  40. 1
    0
      lesson02/.gitignore
  41. 33
    0
      lesson02/build.gradle
  42. 21
    0
      lesson02/proguard-rules.pro
  43. 26
    0
      lesson02/src/androidTest/java/io/hsiao/lesson02/ExampleInstrumentedTest.java
  44. 21
    0
      lesson02/src/main/AndroidManifest.xml
  45. 13
    0
      lesson02/src/main/java/io/hsiao/lesson02/MainActivity.java
  46. 34
    0
      lesson02/src/main/res/drawable-v24/ic_launcher_foreground.xml
  47. 170
    0
      lesson02/src/main/res/drawable/ic_launcher_background.xml
  48. 18
    0
      lesson02/src/main/res/layout/activity_main.xml
  49. 5
    0
      lesson02/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  50. 5
    0
      lesson02/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  51. BIN
      lesson02/src/main/res/mipmap-hdpi/ic_launcher.png
  52. BIN
      lesson02/src/main/res/mipmap-hdpi/ic_launcher_round.png
  53. BIN
      lesson02/src/main/res/mipmap-mdpi/ic_launcher.png
  54. BIN
      lesson02/src/main/res/mipmap-mdpi/ic_launcher_round.png
  55. BIN
      lesson02/src/main/res/mipmap-xhdpi/ic_launcher.png
  56. BIN
      lesson02/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  57. BIN
      lesson02/src/main/res/mipmap-xxhdpi/ic_launcher.png
  58. BIN
      lesson02/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  59. BIN
      lesson02/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  60. BIN
      lesson02/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  61. 6
    0
      lesson02/src/main/res/values/colors.xml
  62. 3
    0
      lesson02/src/main/res/values/strings.xml
  63. 11
    0
      lesson02/src/main/res/values/styles.xml
  64. 17
    0
      lesson02/src/test/java/io/hsiao/lesson02/ExampleUnitTest.java
  65. 1
    0
      settings.gradle

+ 9
- 0
.gitignore Bestand weergeven

@@ -0,0 +1,9 @@
1
+*.iml
2
+.gradle
3
+/local.properties
4
+/.idea/workspace.xml
5
+/.idea/libraries
6
+.DS_Store
7
+/build
8
+/captures
9
+.externalNativeBuild

+ 19
- 0
.idea/gradle.xml Bestand weergeven

@@ -0,0 +1,19 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="GradleSettings">
4
+    <option name="linkedExternalProjectsSettings">
5
+      <GradleProjectSettings>
6
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
7
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
8
+        <option name="modules">
9
+          <set>
10
+            <option value="$PROJECT_DIR$" />
11
+            <option value="$PROJECT_DIR$/lesson01" />
12
+            <option value="$PROJECT_DIR$/lesson02" />
13
+          </set>
14
+        </option>
15
+        <option name="resolveModulePerSourceSet" value="false" />
16
+      </GradleProjectSettings>
17
+    </option>
18
+  </component>
19
+</project>

+ 33
- 0
.idea/misc.xml Bestand weergeven

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="NullableNotNullManager">
4
+    <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
5
+    <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
6
+    <option name="myNullables">
7
+      <value>
8
+        <list size="4">
9
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
10
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
11
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
12
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
13
+        </list>
14
+      </value>
15
+    </option>
16
+    <option name="myNotNulls">
17
+      <value>
18
+        <list size="4">
19
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
20
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
21
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
22
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
23
+        </list>
24
+      </value>
25
+    </option>
26
+  </component>
27
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
28
+    <output url="file://$PROJECT_DIR$/build/classes" />
29
+  </component>
30
+  <component name="ProjectType">
31
+    <option name="id" value="Android" />
32
+  </component>
33
+</project>

+ 10
- 0
.idea/modules.xml Bestand weergeven

@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/YouMap2.0.iml" filepath="$PROJECT_DIR$/YouMap2.0.iml" />
6
+      <module fileurl="file://$PROJECT_DIR$/lesson01/lesson01.iml" filepath="$PROJECT_DIR$/lesson01/lesson01.iml" />
7
+      <module fileurl="file://$PROJECT_DIR$/lesson02/lesson02.iml" filepath="$PROJECT_DIR$/lesson02/lesson02.iml" />
8
+    </modules>
9
+  </component>
10
+</project>

+ 12
- 0
.idea/runConfigurations.xml Bestand weergeven

@@ -0,0 +1,12 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="RunConfigurationProducerService">
4
+    <option name="ignoredProducers">
5
+      <set>
6
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
7
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
8
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
9
+      </set>
10
+    </option>
11
+  </component>
12
+</project>

+ 29
- 0
build.gradle Bestand weergeven

@@ -0,0 +1,29 @@
1
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+
3
+buildscript {
4
+    
5
+    repositories {
6
+        google()
7
+        //jcenter()
8
+        maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
9
+    }
10
+    dependencies {
11
+        classpath 'com.android.tools.build:gradle:3.0.1'
12
+        
13
+
14
+        // NOTE: Do not place your application dependencies here; they belong
15
+        // in the individual module build.gradle files
16
+    }
17
+}
18
+
19
+allprojects {
20
+    repositories {
21
+        google()
22
+        //jcenter()
23
+        maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
24
+    }
25
+}
26
+
27
+task clean(type: Delete) {
28
+    delete rootProject.buildDir
29
+}

+ 17
- 0
gradle.properties Bestand weergeven

@@ -0,0 +1,17 @@
1
+# Project-wide Gradle settings.
2
+
3
+# IDE (e.g. Android Studio) users:
4
+# Gradle settings configured through the IDE *will override*
5
+# any settings specified in this file.
6
+
7
+# For more details on how to configure your build environment visit
8
+# http://www.gradle.org/docs/current/userguide/build_environment.html
9
+
10
+# Specifies the JVM arguments used for the daemon process.
11
+# The setting is particularly useful for tweaking memory settings.
12
+org.gradle.jvmargs=-Xmx1536m
13
+
14
+# When configured, Gradle will run in incubating parallel mode.
15
+# This option should only be used with decoupled projects. More details, visit
16
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17
+# org.gradle.parallel=true

BIN
gradle/wrapper/gradle-wrapper.jar Bestand weergeven


+ 6
- 0
gradle/wrapper/gradle-wrapper.properties Bestand weergeven

@@ -0,0 +1,6 @@
1
+#Mon Jan 22 11:33:43 CST 2018
2
+distributionBase=GRADLE_USER_HOME
3
+distributionPath=wrapper/dists
4
+zipStoreBase=GRADLE_USER_HOME
5
+zipStorePath=wrapper/dists
6
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

+ 160
- 0
gradlew Bestand weergeven

@@ -0,0 +1,160 @@
1
+#!/usr/bin/env bash
2
+
3
+##############################################################################
4
+##
5
+##  Gradle start up script for UN*X
6
+##
7
+##############################################################################
8
+
9
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
+DEFAULT_JVM_OPTS=""
11
+
12
+APP_NAME="Gradle"
13
+APP_BASE_NAME=`basename "$0"`
14
+
15
+# Use the maximum available, or set MAX_FD != -1 to use that value.
16
+MAX_FD="maximum"
17
+
18
+warn ( ) {
19
+    echo "$*"
20
+}
21
+
22
+die ( ) {
23
+    echo
24
+    echo "$*"
25
+    echo
26
+    exit 1
27
+}
28
+
29
+# OS specific support (must be 'true' or 'false').
30
+cygwin=false
31
+msys=false
32
+darwin=false
33
+case "`uname`" in
34
+  CYGWIN* )
35
+    cygwin=true
36
+    ;;
37
+  Darwin* )
38
+    darwin=true
39
+    ;;
40
+  MINGW* )
41
+    msys=true
42
+    ;;
43
+esac
44
+
45
+# Attempt to set APP_HOME
46
+# Resolve links: $0 may be a link
47
+PRG="$0"
48
+# Need this for relative symlinks.
49
+while [ -h "$PRG" ] ; do
50
+    ls=`ls -ld "$PRG"`
51
+    link=`expr "$ls" : '.*-> \(.*\)$'`
52
+    if expr "$link" : '/.*' > /dev/null; then
53
+        PRG="$link"
54
+    else
55
+        PRG=`dirname "$PRG"`"/$link"
56
+    fi
57
+done
58
+SAVED="`pwd`"
59
+cd "`dirname \"$PRG\"`/" >/dev/null
60
+APP_HOME="`pwd -P`"
61
+cd "$SAVED" >/dev/null
62
+
63
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64
+
65
+# Determine the Java command to use to start the JVM.
66
+if [ -n "$JAVA_HOME" ] ; then
67
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68
+        # IBM's JDK on AIX uses strange locations for the executables
69
+        JAVACMD="$JAVA_HOME/jre/sh/java"
70
+    else
71
+        JAVACMD="$JAVA_HOME/bin/java"
72
+    fi
73
+    if [ ! -x "$JAVACMD" ] ; then
74
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75
+
76
+Please set the JAVA_HOME variable in your environment to match the
77
+location of your Java installation."
78
+    fi
79
+else
80
+    JAVACMD="java"
81
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82
+
83
+Please set the JAVA_HOME variable in your environment to match the
84
+location of your Java installation."
85
+fi
86
+
87
+# Increase the maximum file descriptors if we can.
88
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89
+    MAX_FD_LIMIT=`ulimit -H -n`
90
+    if [ $? -eq 0 ] ; then
91
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92
+            MAX_FD="$MAX_FD_LIMIT"
93
+        fi
94
+        ulimit -n $MAX_FD
95
+        if [ $? -ne 0 ] ; then
96
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
97
+        fi
98
+    else
99
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100
+    fi
101
+fi
102
+
103
+# For Darwin, add options to specify how the application appears in the dock
104
+if $darwin; then
105
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106
+fi
107
+
108
+# For Cygwin, switch paths to Windows format before running java
109
+if $cygwin ; then
110
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112
+    JAVACMD=`cygpath --unix "$JAVACMD"`
113
+
114
+    # We build the pattern for arguments to be converted via cygpath
115
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116
+    SEP=""
117
+    for dir in $ROOTDIRSRAW ; do
118
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
119
+        SEP="|"
120
+    done
121
+    OURCYGPATTERN="(^($ROOTDIRS))"
122
+    # Add a user-defined pattern to the cygpath arguments
123
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125
+    fi
126
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
127
+    i=0
128
+    for arg in "$@" ; do
129
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
131
+
132
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
133
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134
+        else
135
+            eval `echo args$i`="\"$arg\""
136
+        fi
137
+        i=$((i+1))
138
+    done
139
+    case $i in
140
+        (0) set -- ;;
141
+        (1) set -- "$args0" ;;
142
+        (2) set -- "$args0" "$args1" ;;
143
+        (3) set -- "$args0" "$args1" "$args2" ;;
144
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150
+    esac
151
+fi
152
+
153
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154
+function splitJvmOpts() {
155
+    JVM_OPTS=("$@")
156
+}
157
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159
+
160
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 90
- 0
gradlew.bat Bestand weergeven

@@ -0,0 +1,90 @@
1
+@if "%DEBUG%" == "" @echo off
2
+@rem ##########################################################################
3
+@rem
4
+@rem  Gradle startup script for Windows
5
+@rem
6
+@rem ##########################################################################
7
+
8
+@rem Set local scope for the variables with windows NT shell
9
+if "%OS%"=="Windows_NT" setlocal
10
+
11
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
+set DEFAULT_JVM_OPTS=
13
+
14
+set DIRNAME=%~dp0
15
+if "%DIRNAME%" == "" set DIRNAME=.
16
+set APP_BASE_NAME=%~n0
17
+set APP_HOME=%DIRNAME%
18
+
19
+@rem Find java.exe
20
+if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+set JAVA_EXE=java.exe
23
+%JAVA_EXE% -version >NUL 2>&1
24
+if "%ERRORLEVEL%" == "0" goto init
25
+
26
+echo.
27
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+echo.
29
+echo Please set the JAVA_HOME variable in your environment to match the
30
+echo location of your Java installation.
31
+
32
+goto fail
33
+
34
+:findJavaFromJavaHome
35
+set JAVA_HOME=%JAVA_HOME:"=%
36
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+if exist "%JAVA_EXE%" goto init
39
+
40
+echo.
41
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+echo.
43
+echo Please set the JAVA_HOME variable in your environment to match the
44
+echo location of your Java installation.
45
+
46
+goto fail
47
+
48
+:init
49
+@rem Get command-line arguments, handling Windowz variants
50
+
51
+if not "%OS%" == "Windows_NT" goto win9xME_args
52
+if "%@eval[2+2]" == "4" goto 4NT_args
53
+
54
+:win9xME_args
55
+@rem Slurp the command line arguments.
56
+set CMD_LINE_ARGS=
57
+set _SKIP=2
58
+
59
+:win9xME_args_slurp
60
+if "x%~1" == "x" goto execute
61
+
62
+set CMD_LINE_ARGS=%*
63
+goto execute
64
+
65
+:4NT_args
66
+@rem Get arguments from the 4NT Shell from JP Software
67
+set CMD_LINE_ARGS=%$
68
+
69
+:execute
70
+@rem Setup the command line
71
+
72
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
+
74
+@rem Execute Gradle
75
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
+
77
+:end
78
+@rem End local scope for the variables with windows NT shell
79
+if "%ERRORLEVEL%"=="0" goto mainEnd
80
+
81
+:fail
82
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+rem the _cmd.exe /c_ return code!
84
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
+exit /b 1
86
+
87
+:mainEnd
88
+if "%OS%"=="Windows_NT" endlocal
89
+
90
+:omega

+ 1
- 0
lesson01/.gitignore Bestand weergeven

@@ -0,0 +1 @@
1
+/build

+ 32
- 0
lesson01/build.gradle Bestand weergeven

@@ -0,0 +1,32 @@
1
+apply plugin: 'com.android.application'
2
+
3
+android {
4
+    compileSdkVersion 25
5
+    defaultConfig {
6
+        applicationId "io.hsiao.lesson01"
7
+        minSdkVersion 19
8
+        targetSdkVersion 25
9
+        versionCode 1
10
+        versionName "1.0"
11
+
12
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13
+
14
+    }
15
+    buildTypes {
16
+        release {
17
+            minifyEnabled false
18
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19
+        }
20
+    }
21
+    buildToolsVersion '26.0.2'
22
+    compileOptions {
23
+        sourceCompatibility JavaVersion.VERSION_1_8
24
+        targetCompatibility JavaVersion.VERSION_1_8
25
+    }
26
+}
27
+
28
+dependencies {
29
+    implementation fileTree(include: ['*.jar'], dir: 'libs')
30
+    implementation 'com.android.support:appcompat-v7:25.1.0'
31
+    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
32
+}

+ 21
- 0
lesson01/proguard-rules.pro Bestand weergeven

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

+ 26
- 0
lesson01/src/androidTest/java/io/hsiao/lesson01/ExampleInstrumentedTest.java Bestand weergeven

@@ -0,0 +1,26 @@
1
+package io.hsiao.lesson01;
2
+
3
+import android.content.Context;
4
+import android.support.test.InstrumentationRegistry;
5
+import android.support.test.runner.AndroidJUnit4;
6
+
7
+import org.junit.Test;
8
+import org.junit.runner.RunWith;
9
+
10
+import static org.junit.Assert.*;
11
+
12
+/**
13
+ * Instrumented test, which will execute on an Android device.
14
+ *
15
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16
+ */
17
+@RunWith(AndroidJUnit4.class)
18
+public class ExampleInstrumentedTest {
19
+    @Test
20
+    public void useAppContext() throws Exception {
21
+        // Context of the app under test.
22
+        Context appContext = InstrumentationRegistry.getTargetContext();
23
+
24
+        assertEquals("io.hsiao.lesson01", appContext.getPackageName());
25
+    }
26
+}

+ 23
- 0
lesson01/src/main/AndroidManifest.xml Bestand weergeven

@@ -0,0 +1,23 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="io.hsiao.lesson01">
4
+
5
+    <application
6
+        android:allowBackup="true"
7
+        android:icon="@mipmap/ic_launcher"
8
+        android:label="@string/app_name"
9
+        android:roundIcon="@mipmap/ic_launcher_round"
10
+        android:theme="@style/AppTheme"
11
+        android:supportsRtl="true">
12
+        <activity android:name=".MainActivity">
13
+            <intent-filter>
14
+                <action android:name="android.intent.action.MAIN" />
15
+
16
+                <category android:name="android.intent.category.LAUNCHER" />
17
+            </intent-filter>
18
+        </activity>
19
+        <activity android:name=".FooActivity" android:theme="@style/AppTheme">
20
+        </activity>
21
+    </application>
22
+
23
+</manifest>

+ 32
- 0
lesson01/src/main/java/io/hsiao/lesson01/FooActivity.java Bestand weergeven

@@ -0,0 +1,32 @@
1
+package io.hsiao.lesson01;
2
+
3
+import android.app.Activity;
4
+import android.content.Intent;
5
+import android.os.Bundle;
6
+import android.util.Log;
7
+import android.widget.TextView;
8
+import android.widget.Toast;
9
+
10
+public class FooActivity extends Activity {
11
+
12
+    private final String TAG="youmap_app";
13
+
14
+    @Override
15
+    protected void onCreate(Bundle savedInstanceState) {
16
+        super.onCreate(savedInstanceState);
17
+        setContentView(R.layout.activity_foo);
18
+
19
+        //获取UI控件
20
+        TextView txt = (TextView) this.findViewById(R.id.foo_text);
21
+
22
+        //获取activity的 Intent对象
23
+        Intent intent = this.getIntent();
24
+        //拿到上一个Activity传过来的数据。
25
+        String username = intent.getStringExtra("username");
26
+        //把用户名显示到txt控件上
27
+        txt.setText(username);
28
+
29
+        Log.i(TAG,username);
30
+        Toast.makeText(this.getApplication(),username,Toast.LENGTH_SHORT).show();
31
+    }
32
+}

+ 84
- 0
lesson01/src/main/java/io/hsiao/lesson01/MainActivity.java Bestand weergeven

@@ -0,0 +1,84 @@
1
+package io.hsiao.lesson01;
2
+
3
+import android.content.Intent;
4
+import android.graphics.Color;
5
+import android.os.Bundle;
6
+import android.support.v7.app.AppCompatActivity;
7
+import android.util.Log;
8
+import android.view.View;
9
+import android.widget.Button;
10
+import android.widget.EditText;
11
+import android.widget.Toast;
12
+
13
+import io.hsiao.lesson01.service.LoginValidator;
14
+
15
+/**
16
+ * 一个Activity,需要继承Activity或者Activity的子类即可。这里使用兼容的AppCompatActivity
17
+ */
18
+public class MainActivity extends AppCompatActivity {
19
+    //定义一个登陆按钮
20
+    private Button btnLogin;
21
+    //定义一个用户名输入框
22
+    private EditText txtUserName;
23
+    //定义一个密码输入框
24
+    private EditText txtPasswd;
25
+    //登陆验证业务模块
26
+    private LoginValidator loginValidator;
27
+    //日志标签
28
+    private final String TAG = "lesson01";
29
+
30
+    /**
31
+     * 重新onCreate方法,当Activity启动时候被调用一次。用于初始化布局和数据。
32
+     *
33
+     * @param savedInstanceState
34
+     */
35
+    @Override
36
+    protected void onCreate(Bundle savedInstanceState) {
37
+        super.onCreate(savedInstanceState);
38
+
39
+        //设置Activity的布局
40
+        this.setContentView(R.layout.activity_main);
41
+        //初始化登陆验证模块
42
+        this.loginValidator = new LoginValidator();
43
+        //获取UI控件
44
+        this.txtUserName = (EditText) this.findViewById(R.id.main_login_txtUsername);
45
+        this.txtPasswd = (EditText) this.findViewById(R.id.main_login_txtPasswd);
46
+        this.btnLogin = (Button) this.findViewById(R.id.main_login_btnLogin);
47
+        //给按钮添加click事件
48
+        this.btnLogin.setOnClickListener(new View.OnClickListener() {
49
+            @Override
50
+            public void onClick(View v) {
51
+                Log.i(TAG, "password: " + txtPasswd.getText().toString());
52
+                Log.i(TAG, "userName: " + txtUserName.getText().toString());
53
+
54
+                try {
55
+                    //调用登陆模块验证登陆
56
+                    loginValidator.verifyLogin(txtUserName.getEditableText().toString(), txtPasswd.getEditableText().toString());
57
+                    //登陆成功之后跳转到了一个Activity,并通过Intent对象把用户名传过去。
58
+                    Intent intent = new Intent(MainActivity.this, FooActivity.class);
59
+                    intent.putExtra("username", txtUserName.getText().toString());
60
+                    startActivity(intent);
61
+                    //弹出提示信息
62
+                    notifyToast("登录成功");
63
+                } catch (Exception ex) {
64
+                    Log.e(TAG, ex.getMessage());
65
+                    //登陆失败,把输入框清空
66
+                    txtPasswd.setText("");
67
+                    //把密码框背景变红
68
+                    txtPasswd.setBackgroundColor(Color.RED);
69
+                    txtUserName.setText("");
70
+                    notifyToast("登录失败: " + ex.getMessage());
71
+                }
72
+
73
+            }
74
+        });
75
+
76
+        Log.i(TAG, "activity启动成功。");
77
+
78
+    }
79
+
80
+    private void notifyToast(String msg) {
81
+        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
82
+    }
83
+
84
+}

+ 19
- 0
lesson01/src/main/java/io/hsiao/lesson01/service/LoginValidator.java Bestand weergeven

@@ -0,0 +1,19 @@
1
+package io.hsiao.lesson01.service;
2
+
3
+/**
4
+ * Created by hsiao on 2018/1/21.
5
+ */
6
+
7
+public class LoginValidator {
8
+
9
+    public void verifyLogin(String  userName,String passwd) throws Exception{
10
+        if(userName ==null || passwd == null || "".equals(userName)|| "".equals(passwd)){
11
+            throw new Exception("帐号或密码为空");
12
+        }
13
+
14
+        if(!userName.startsWith("admin")){
15
+            throw new Exception("登录失败");
16
+        }
17
+    }
18
+
19
+}

+ 34
- 0
lesson01/src/main/res/drawable-v24/ic_launcher_foreground.xml
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 170
- 0
lesson01/src/main/res/drawable/ic_launcher_background.xml Bestand weergeven

@@ -0,0 +1,170 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:width="108dp"
4
+    android:height="108dp"
5
+    android:viewportHeight="108"
6
+    android:viewportWidth="108">
7
+    <path
8
+        android:fillColor="#26A69A"
9
+        android:pathData="M0,0h108v108h-108z" />
10
+    <path
11
+        android:fillColor="#00000000"
12
+        android:pathData="M9,0L9,108"
13
+        android:strokeColor="#33FFFFFF"
14
+        android:strokeWidth="0.8" />
15
+    <path
16
+        android:fillColor="#00000000"
17
+        android:pathData="M19,0L19,108"
18
+        android:strokeColor="#33FFFFFF"
19
+        android:strokeWidth="0.8" />
20
+    <path
21
+        android:fillColor="#00000000"
22
+        android:pathData="M29,0L29,108"
23
+        android:strokeColor="#33FFFFFF"
24
+        android:strokeWidth="0.8" />
25
+    <path
26
+        android:fillColor="#00000000"
27
+        android:pathData="M39,0L39,108"
28
+        android:strokeColor="#33FFFFFF"
29
+        android:strokeWidth="0.8" />
30
+    <path
31
+        android:fillColor="#00000000"
32
+        android:pathData="M49,0L49,108"
33
+        android:strokeColor="#33FFFFFF"
34
+        android:strokeWidth="0.8" />
35
+    <path
36
+        android:fillColor="#00000000"
37
+        android:pathData="M59,0L59,108"
38
+        android:strokeColor="#33FFFFFF"
39
+        android:strokeWidth="0.8" />
40
+    <path
41
+        android:fillColor="#00000000"
42
+        android:pathData="M69,0L69,108"
43
+        android:strokeColor="#33FFFFFF"
44
+        android:strokeWidth="0.8" />
45
+    <path
46
+        android:fillColor="#00000000"
47
+        android:pathData="M79,0L79,108"
48
+        android:strokeColor="#33FFFFFF"
49
+        android:strokeWidth="0.8" />
50
+    <path
51
+        android:fillColor="#00000000"
52
+        android:pathData="M89,0L89,108"
53
+        android:strokeColor="#33FFFFFF"
54
+        android:strokeWidth="0.8" />
55
+    <path
56
+        android:fillColor="#00000000"
57
+        android:pathData="M99,0L99,108"
58
+        android:strokeColor="#33FFFFFF"
59
+        android:strokeWidth="0.8" />
60
+    <path
61
+        android:fillColor="#00000000"
62
+        android:pathData="M0,9L108,9"
63
+        android:strokeColor="#33FFFFFF"
64
+        android:strokeWidth="0.8" />
65
+    <path
66
+        android:fillColor="#00000000"
67
+        android:pathData="M0,19L108,19"
68
+        android:strokeColor="#33FFFFFF"
69
+        android:strokeWidth="0.8" />
70
+    <path
71
+        android:fillColor="#00000000"
72
+        android:pathData="M0,29L108,29"
73
+        android:strokeColor="#33FFFFFF"
74
+        android:strokeWidth="0.8" />
75
+    <path
76
+        android:fillColor="#00000000"
77
+        android:pathData="M0,39L108,39"
78
+        android:strokeColor="#33FFFFFF"
79
+        android:strokeWidth="0.8" />
80
+    <path
81
+        android:fillColor="#00000000"
82
+        android:pathData="M0,49L108,49"
83
+        android:strokeColor="#33FFFFFF"
84
+        android:strokeWidth="0.8" />
85
+    <path
86
+        android:fillColor="#00000000"
87
+        android:pathData="M0,59L108,59"
88
+        android:strokeColor="#33FFFFFF"
89
+        android:strokeWidth="0.8" />
90
+    <path
91
+        android:fillColor="#00000000"
92
+        android:pathData="M0,69L108,69"
93
+        android:strokeColor="#33FFFFFF"
94
+        android:strokeWidth="0.8" />
95
+    <path
96
+        android:fillColor="#00000000"
97
+        android:pathData="M0,79L108,79"
98
+        android:strokeColor="#33FFFFFF"
99
+        android:strokeWidth="0.8" />
100
+    <path
101
+        android:fillColor="#00000000"
102
+        android:pathData="M0,89L108,89"
103
+        android:strokeColor="#33FFFFFF"
104
+        android:strokeWidth="0.8" />
105
+    <path
106
+        android:fillColor="#00000000"
107
+        android:pathData="M0,99L108,99"
108
+        android:strokeColor="#33FFFFFF"
109
+        android:strokeWidth="0.8" />
110
+    <path
111
+        android:fillColor="#00000000"
112
+        android:pathData="M19,29L89,29"
113
+        android:strokeColor="#33FFFFFF"
114
+        android:strokeWidth="0.8" />
115
+    <path
116
+        android:fillColor="#00000000"
117
+        android:pathData="M19,39L89,39"
118
+        android:strokeColor="#33FFFFFF"
119
+        android:strokeWidth="0.8" />
120
+    <path
121
+        android:fillColor="#00000000"
122
+        android:pathData="M19,49L89,49"
123
+        android:strokeColor="#33FFFFFF"
124
+        android:strokeWidth="0.8" />
125
+    <path
126
+        android:fillColor="#00000000"
127
+        android:pathData="M19,59L89,59"
128
+        android:strokeColor="#33FFFFFF"
129
+        android:strokeWidth="0.8" />
130
+    <path
131
+        android:fillColor="#00000000"
132
+        android:pathData="M19,69L89,69"
133
+        android:strokeColor="#33FFFFFF"
134
+        android:strokeWidth="0.8" />
135
+    <path
136
+        android:fillColor="#00000000"
137
+        android:pathData="M19,79L89,79"
138
+        android:strokeColor="#33FFFFFF"
139
+        android:strokeWidth="0.8" />
140
+    <path
141
+        android:fillColor="#00000000"
142
+        android:pathData="M29,19L29,89"
143
+        android:strokeColor="#33FFFFFF"
144
+        android:strokeWidth="0.8" />
145
+    <path
146
+        android:fillColor="#00000000"
147
+        android:pathData="M39,19L39,89"
148
+        android:strokeColor="#33FFFFFF"
149
+        android:strokeWidth="0.8" />
150
+    <path
151
+        android:fillColor="#00000000"
152
+        android:pathData="M49,19L49,89"
153
+        android:strokeColor="#33FFFFFF"
154
+        android:strokeWidth="0.8" />
155
+    <path
156
+        android:fillColor="#00000000"
157
+        android:pathData="M59,19L59,89"
158
+        android:strokeColor="#33FFFFFF"
159
+        android:strokeWidth="0.8" />
160
+    <path
161
+        android:fillColor="#00000000"
162
+        android:pathData="M69,19L69,89"
163
+        android:strokeColor="#33FFFFFF"
164
+        android:strokeWidth="0.8" />
165
+    <path
166
+        android:fillColor="#00000000"
167
+        android:pathData="M79,19L79,89"
168
+        android:strokeColor="#33FFFFFF"
169
+        android:strokeWidth="0.8" />
170
+</vector>

+ 14
- 0
lesson01/src/main/res/layout/activity_foo.xml Bestand weergeven

@@ -0,0 +1,14 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto"
4
+    xmlns:tools="http://schemas.android.com/tools"
5
+    android:layout_width="match_parent"
6
+    android:layout_height="match_parent"
7
+    tools:context="io.hsiao.lesson01.FooActivity">
8
+
9
+    <TextView
10
+        android:id="@+id/foo_text"
11
+        android:layout_width="wrap_content"
12
+        android:layout_height="wrap_content"
13
+        android:text="" />
14
+</android.support.constraint.ConstraintLayout>

+ 56
- 0
lesson01/src/main/res/layout/activity_main.xml Bestand weergeven

@@ -0,0 +1,56 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:orientation="vertical"
6
+    android:weightSum="10">
7
+
8
+    <LinearLayout
9
+        android:layout_width="match_parent"
10
+        android:layout_height="wrap_content"
11
+        android:layout_weight="1"
12
+        android:orientation="horizontal">
13
+
14
+        <TextView
15
+            android:id="@+id/textView2"
16
+            android:layout_width="wrap_content"
17
+            android:layout_height="wrap_content"
18
+            android:text="输入您的姓名" />
19
+
20
+        <EditText
21
+            android:id="@+id/main_login_txtUsername"
22
+            android:layout_width="wrap_content"
23
+            android:layout_height="wrap_content"
24
+            android:layout_weight="1"
25
+            android:ems="10"
26
+            android:inputType="textPersonName" />
27
+    </LinearLayout>
28
+
29
+    <LinearLayout
30
+        android:layout_width="match_parent"
31
+        android:layout_height="wrap_content"
32
+        android:layout_weight="1"
33
+        android:orientation="horizontal">
34
+
35
+        <TextView
36
+            android:layout_width="wrap_content"
37
+            android:layout_height="wrap_content"
38
+            android:layout_weight="1"
39
+            android:text="密码" />
40
+
41
+        <EditText
42
+            android:id="@+id/main_login_txtPasswd"
43
+            android:layout_width="wrap_content"
44
+            android:layout_height="wrap_content"
45
+            android:layout_weight="1"
46
+            android:ems="10"
47
+            android:inputType="textPersonName" />
48
+    </LinearLayout>
49
+
50
+    <Button
51
+        android:id="@+id/main_login_btnLogin"
52
+        android:layout_width="match_parent"
53
+        android:layout_height="wrap_content"
54
+        android:text="登   录" />
55
+
56
+</LinearLayout>

+ 5
- 0
lesson01/src/main/res/mipmap-anydpi-v26/ic_launcher.xml Bestand weergeven

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <background android:drawable="@drawable/ic_launcher_background" />
4
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
5
+</adaptive-icon>

+ 5
- 0
lesson01/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml Bestand weergeven

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <background android:drawable="@drawable/ic_launcher_background" />
4
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
5
+</adaptive-icon>

BIN
lesson01/src/main/res/mipmap-hdpi/ic_launcher.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-hdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-mdpi/ic_launcher.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-mdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-xhdpi/ic_launcher.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-xhdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-xxhdpi/ic_launcher.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-xxxhdpi/ic_launcher.png Bestand weergeven


BIN
lesson01/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Bestand weergeven


+ 4
- 0
lesson01/src/main/res/values/colors.xml Bestand weergeven

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<resources>
3
+    <color name="colorMainBtn" >#da2929</color>
4
+</resources>

+ 3
- 0
lesson01/src/main/res/values/strings.xml Bestand weergeven

@@ -0,0 +1,3 @@
1
+<resources>
2
+    <string name="app_name">lesson01</string>
3
+</resources>

+ 8
- 0
lesson01/src/main/res/values/styles.xml Bestand weergeven

@@ -0,0 +1,8 @@
1
+<resources>
2
+
3
+    <!-- Base application theme. -->
4
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5
+
6
+    </style>
7
+
8
+</resources>

+ 17
- 0
lesson01/src/test/java/io/hsiao/lesson01/ExampleUnitTest.java Bestand weergeven

@@ -0,0 +1,17 @@
1
+package io.hsiao.lesson01;
2
+
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.*;
6
+
7
+/**
8
+ * Example local unit test, which will execute on the development machine (host).
9
+ *
10
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11
+ */
12
+public class ExampleUnitTest {
13
+    @Test
14
+    public void addition_isCorrect() throws Exception {
15
+        assertEquals(4, 2 + 2);
16
+    }
17
+}

+ 1
- 0
lesson02/.gitignore Bestand weergeven

@@ -0,0 +1 @@
1
+/build

+ 33
- 0
lesson02/build.gradle Bestand weergeven

@@ -0,0 +1,33 @@
1
+apply plugin: 'com.android.application'
2
+
3
+android {
4
+    compileSdkVersion 25
5
+
6
+
7
+
8
+    defaultConfig {
9
+        applicationId "io.hsiao.lesson02"
10
+        minSdkVersion 19
11
+        targetSdkVersion 26
12
+        versionCode 1
13
+        versionName "1.0"
14
+
15
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16
+
17
+    }
18
+
19
+    buildTypes {
20
+        release {
21
+            minifyEnabled false
22
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23
+        }
24
+    }
25
+
26
+}
27
+
28
+dependencies {
29
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
30
+
31
+    implementation 'com.android.support:appcompat-v7:25.1.0'
32
+    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
33
+}

+ 21
- 0
lesson02/proguard-rules.pro Bestand weergeven

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

+ 26
- 0
lesson02/src/androidTest/java/io/hsiao/lesson02/ExampleInstrumentedTest.java Bestand weergeven

@@ -0,0 +1,26 @@
1
+package io.hsiao.lesson02;
2
+
3
+import android.content.Context;
4
+import android.support.test.InstrumentationRegistry;
5
+import android.support.test.runner.AndroidJUnit4;
6
+
7
+import org.junit.Test;
8
+import org.junit.runner.RunWith;
9
+
10
+import static org.junit.Assert.*;
11
+
12
+/**
13
+ * Instrumented test, which will execute on an Android device.
14
+ *
15
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16
+ */
17
+@RunWith(AndroidJUnit4.class)
18
+public class ExampleInstrumentedTest {
19
+    @Test
20
+    public void useAppContext() throws Exception {
21
+        // Context of the app under test.
22
+        Context appContext = InstrumentationRegistry.getTargetContext();
23
+
24
+        assertEquals("io.hsiao.lesson02", appContext.getPackageName());
25
+    }
26
+}

+ 21
- 0
lesson02/src/main/AndroidManifest.xml Bestand weergeven

@@ -0,0 +1,21 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="io.hsiao.lesson02">
4
+
5
+    <application
6
+        android:allowBackup="true"
7
+        android:icon="@mipmap/ic_launcher"
8
+        android:label="@string/app_name"
9
+        android:roundIcon="@mipmap/ic_launcher_round"
10
+        android:supportsRtl="true"
11
+        android:theme="@style/AppTheme">
12
+        <activity android:name=".MainActivity">
13
+            <intent-filter>
14
+                <action android:name="android.intent.action.MAIN" />
15
+
16
+                <category android:name="android.intent.category.LAUNCHER" />
17
+            </intent-filter>
18
+        </activity>
19
+    </application>
20
+
21
+</manifest>

+ 13
- 0
lesson02/src/main/java/io/hsiao/lesson02/MainActivity.java Bestand weergeven

@@ -0,0 +1,13 @@
1
+package io.hsiao.lesson02;
2
+
3
+import android.support.v7.app.AppCompatActivity;
4
+import android.os.Bundle;
5
+
6
+public class MainActivity extends AppCompatActivity {
7
+
8
+    @Override
9
+    protected void onCreate(Bundle savedInstanceState) {
10
+        super.onCreate(savedInstanceState);
11
+        setContentView(R.layout.activity_main);
12
+    }
13
+}

+ 34
- 0
lesson02/src/main/res/drawable-v24/ic_launcher_foreground.xml
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 170
- 0
lesson02/src/main/res/drawable/ic_launcher_background.xml Bestand weergeven

@@ -0,0 +1,170 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:width="108dp"
4
+    android:height="108dp"
5
+    android:viewportHeight="108"
6
+    android:viewportWidth="108">
7
+    <path
8
+        android:fillColor="#26A69A"
9
+        android:pathData="M0,0h108v108h-108z" />
10
+    <path
11
+        android:fillColor="#00000000"
12
+        android:pathData="M9,0L9,108"
13
+        android:strokeColor="#33FFFFFF"
14
+        android:strokeWidth="0.8" />
15
+    <path
16
+        android:fillColor="#00000000"
17
+        android:pathData="M19,0L19,108"
18
+        android:strokeColor="#33FFFFFF"
19
+        android:strokeWidth="0.8" />
20
+    <path
21
+        android:fillColor="#00000000"
22
+        android:pathData="M29,0L29,108"
23
+        android:strokeColor="#33FFFFFF"
24
+        android:strokeWidth="0.8" />
25
+    <path
26
+        android:fillColor="#00000000"
27
+        android:pathData="M39,0L39,108"
28
+        android:strokeColor="#33FFFFFF"
29
+        android:strokeWidth="0.8" />
30
+    <path
31
+        android:fillColor="#00000000"
32
+        android:pathData="M49,0L49,108"
33
+        android:strokeColor="#33FFFFFF"
34
+        android:strokeWidth="0.8" />
35
+    <path
36
+        android:fillColor="#00000000"
37
+        android:pathData="M59,0L59,108"
38
+        android:strokeColor="#33FFFFFF"
39
+        android:strokeWidth="0.8" />
40
+    <path
41
+        android:fillColor="#00000000"
42
+        android:pathData="M69,0L69,108"
43
+        android:strokeColor="#33FFFFFF"
44
+        android:strokeWidth="0.8" />
45
+    <path
46
+        android:fillColor="#00000000"
47
+        android:pathData="M79,0L79,108"
48
+        android:strokeColor="#33FFFFFF"
49
+        android:strokeWidth="0.8" />
50
+    <path
51
+        android:fillColor="#00000000"
52
+        android:pathData="M89,0L89,108"
53
+        android:strokeColor="#33FFFFFF"
54
+        android:strokeWidth="0.8" />
55
+    <path
56
+        android:fillColor="#00000000"
57
+        android:pathData="M99,0L99,108"
58
+        android:strokeColor="#33FFFFFF"
59
+        android:strokeWidth="0.8" />
60
+    <path
61
+        android:fillColor="#00000000"
62
+        android:pathData="M0,9L108,9"
63
+        android:strokeColor="#33FFFFFF"
64
+        android:strokeWidth="0.8" />
65
+    <path
66
+        android:fillColor="#00000000"
67
+        android:pathData="M0,19L108,19"
68
+        android:strokeColor="#33FFFFFF"
69
+        android:strokeWidth="0.8" />
70
+    <path
71
+        android:fillColor="#00000000"
72
+        android:pathData="M0,29L108,29"
73
+        android:strokeColor="#33FFFFFF"
74
+        android:strokeWidth="0.8" />
75
+    <path
76
+        android:fillColor="#00000000"
77
+        android:pathData="M0,39L108,39"
78
+        android:strokeColor="#33FFFFFF"
79
+        android:strokeWidth="0.8" />
80
+    <path
81
+        android:fillColor="#00000000"
82
+        android:pathData="M0,49L108,49"
83
+        android:strokeColor="#33FFFFFF"
84
+        android:strokeWidth="0.8" />
85
+    <path
86
+        android:fillColor="#00000000"
87
+        android:pathData="M0,59L108,59"
88
+        android:strokeColor="#33FFFFFF"
89
+        android:strokeWidth="0.8" />
90
+    <path
91
+        android:fillColor="#00000000"
92
+        android:pathData="M0,69L108,69"
93
+        android:strokeColor="#33FFFFFF"
94
+        android:strokeWidth="0.8" />
95
+    <path
96
+        android:fillColor="#00000000"
97
+        android:pathData="M0,79L108,79"
98
+        android:strokeColor="#33FFFFFF"
99
+        android:strokeWidth="0.8" />
100
+    <path
101
+        android:fillColor="#00000000"
102
+        android:pathData="M0,89L108,89"
103
+        android:strokeColor="#33FFFFFF"
104
+        android:strokeWidth="0.8" />
105
+    <path
106
+        android:fillColor="#00000000"
107
+        android:pathData="M0,99L108,99"
108
+        android:strokeColor="#33FFFFFF"
109
+        android:strokeWidth="0.8" />
110
+    <path
111
+        android:fillColor="#00000000"
112
+        android:pathData="M19,29L89,29"
113
+        android:strokeColor="#33FFFFFF"
114
+        android:strokeWidth="0.8" />
115
+    <path
116
+        android:fillColor="#00000000"
117
+        android:pathData="M19,39L89,39"
118
+        android:strokeColor="#33FFFFFF"
119
+        android:strokeWidth="0.8" />
120
+    <path
121
+        android:fillColor="#00000000"
122
+        android:pathData="M19,49L89,49"
123
+        android:strokeColor="#33FFFFFF"
124
+        android:strokeWidth="0.8" />
125
+    <path
126
+        android:fillColor="#00000000"
127
+        android:pathData="M19,59L89,59"
128
+        android:strokeColor="#33FFFFFF"
129
+        android:strokeWidth="0.8" />
130
+    <path
131
+        android:fillColor="#00000000"
132
+        android:pathData="M19,69L89,69"
133
+        android:strokeColor="#33FFFFFF"
134
+        android:strokeWidth="0.8" />
135
+    <path
136
+        android:fillColor="#00000000"
137
+        android:pathData="M19,79L89,79"
138
+        android:strokeColor="#33FFFFFF"
139
+        android:strokeWidth="0.8" />
140
+    <path
141
+        android:fillColor="#00000000"
142
+        android:pathData="M29,19L29,89"
143
+        android:strokeColor="#33FFFFFF"
144
+        android:strokeWidth="0.8" />
145
+    <path
146
+        android:fillColor="#00000000"
147
+        android:pathData="M39,19L39,89"
148
+        android:strokeColor="#33FFFFFF"
149
+        android:strokeWidth="0.8" />
150
+    <path
151
+        android:fillColor="#00000000"
152
+        android:pathData="M49,19L49,89"
153
+        android:strokeColor="#33FFFFFF"
154
+        android:strokeWidth="0.8" />
155
+    <path
156
+        android:fillColor="#00000000"
157
+        android:pathData="M59,19L59,89"
158
+        android:strokeColor="#33FFFFFF"
159
+        android:strokeWidth="0.8" />
160
+    <path
161
+        android:fillColor="#00000000"
162
+        android:pathData="M69,19L69,89"
163
+        android:strokeColor="#33FFFFFF"
164
+        android:strokeWidth="0.8" />
165
+    <path
166
+        android:fillColor="#00000000"
167
+        android:pathData="M79,19L79,89"
168
+        android:strokeColor="#33FFFFFF"
169
+        android:strokeWidth="0.8" />
170
+</vector>

+ 18
- 0
lesson02/src/main/res/layout/activity_main.xml Bestand weergeven

@@ -0,0 +1,18 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto"
4
+    xmlns:tools="http://schemas.android.com/tools"
5
+    android:layout_width="match_parent"
6
+    android:layout_height="match_parent"
7
+    tools:context="io.hsiao.lesson02.MainActivity">
8
+
9
+    <TextView
10
+        android:layout_width="wrap_content"
11
+        android:layout_height="wrap_content"
12
+        android:text="Hello World!"
13
+        app:layout_constraintBottom_toBottomOf="parent"
14
+        app:layout_constraintLeft_toLeftOf="parent"
15
+        app:layout_constraintRight_toRightOf="parent"
16
+        app:layout_constraintTop_toTopOf="parent" />
17
+
18
+</android.support.constraint.ConstraintLayout>

+ 5
- 0
lesson02/src/main/res/mipmap-anydpi-v26/ic_launcher.xml Bestand weergeven

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <background android:drawable="@drawable/ic_launcher_background" />
4
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
5
+</adaptive-icon>

+ 5
- 0
lesson02/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml Bestand weergeven

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <background android:drawable="@drawable/ic_launcher_background" />
4
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
5
+</adaptive-icon>

BIN
lesson02/src/main/res/mipmap-hdpi/ic_launcher.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-hdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-mdpi/ic_launcher.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-mdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-xhdpi/ic_launcher.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-xhdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-xxhdpi/ic_launcher.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-xxxhdpi/ic_launcher.png Bestand weergeven


BIN
lesson02/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Bestand weergeven


+ 6
- 0
lesson02/src/main/res/values/colors.xml Bestand weergeven

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<resources>
3
+    <color name="colorPrimary">#3F51B5</color>
4
+    <color name="colorPrimaryDark">#303F9F</color>
5
+    <color name="colorAccent">#FF4081</color>
6
+</resources>

+ 3
- 0
lesson02/src/main/res/values/strings.xml Bestand weergeven

@@ -0,0 +1,3 @@
1
+<resources>
2
+    <string name="app_name">lesson02</string>
3
+</resources>

+ 11
- 0
lesson02/src/main/res/values/styles.xml Bestand weergeven

@@ -0,0 +1,11 @@
1
+<resources>
2
+
3
+    <!-- Base application theme. -->
4
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5
+        <!-- Customize your theme here. -->
6
+        <item name="colorPrimary">@color/colorPrimary</item>
7
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8
+        <item name="colorAccent">@color/colorAccent</item>
9
+    </style>
10
+
11
+</resources>

+ 17
- 0
lesson02/src/test/java/io/hsiao/lesson02/ExampleUnitTest.java Bestand weergeven

@@ -0,0 +1,17 @@
1
+package io.hsiao.lesson02;
2
+
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.*;
6
+
7
+/**
8
+ * Example local unit test, which will execute on the development machine (host).
9
+ *
10
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11
+ */
12
+public class ExampleUnitTest {
13
+    @Test
14
+    public void addition_isCorrect() throws Exception {
15
+        assertEquals(4, 2 + 2);
16
+    }
17
+}

+ 1
- 0
settings.gradle Bestand weergeven

@@ -0,0 +1 @@
1
+include ':lesson01', ':lesson02'

Laden…
Annuleren
Opslaan