From e3f61221da37b3f0a1b09621e43e2e67ebb41c8d Mon Sep 17 00:00:00 2001 From: DwarfPorter Date: Sun, 5 May 2019 20:42:18 +0300 Subject: [PATCH 1/4] SendSms: send sms --- Android-1/Lesson-2/SendSms/.gitignore | 13 ++ .../Lesson-2/SendSms/.idea/encodings.xml | 4 + Android-1/Lesson-2/SendSms/.idea/gradle.xml | 15 ++ Android-1/Lesson-2/SendSms/.idea/misc.xml | 34 ++++ .../SendSms/.idea/runConfigurations.xml | 12 ++ Android-1/Lesson-2/SendSms/.idea/vcs.xml | 6 + Android-1/Lesson-2/SendSms/app/.gitignore | 1 + Android-1/Lesson-2/SendSms/app/build.gradle | 28 +++ .../Lesson-2/SendSms/app/proguard-rules.pro | 21 +++ .../sendsms/ExampleInstrumentedTest.java | 26 +++ .../SendSms/app/src/main/AndroidManifest.xml | 21 +++ .../ru/geekbrains/sendsms/MainActivity.java | 31 ++++ .../drawable-v24/ic_launcher_foreground.xml | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++ .../app/src/main/res/layout/activity_main.xml | 34 ++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 2963 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 4905 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2060 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2783 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4490 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 6895 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6387 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10413 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9128 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15132 bytes .../app/src/main/res/values/colors.xml | 6 + .../app/src/main/res/values/strings.xml | 4 + .../app/src/main/res/values/styles.xml | 11 ++ .../geekbrains/sendsms/ExampleUnitTest.java | 17 ++ Android-1/Lesson-2/SendSms/build.gradle | 27 +++ Android-1/Lesson-2/SendSms/gradle.properties | 15 ++ .../SendSms/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + Android-1/Lesson-2/SendSms/gradlew | 172 ++++++++++++++++++ Android-1/Lesson-2/SendSms/gradlew.bat | 84 +++++++++ Android-1/Lesson-2/SendSms/settings.gradle | 1 + 38 files changed, 803 insertions(+) create mode 100644 Android-1/Lesson-2/SendSms/.gitignore create mode 100644 Android-1/Lesson-2/SendSms/.idea/encodings.xml create mode 100644 Android-1/Lesson-2/SendSms/.idea/gradle.xml create mode 100644 Android-1/Lesson-2/SendSms/.idea/misc.xml create mode 100644 Android-1/Lesson-2/SendSms/.idea/runConfigurations.xml create mode 100644 Android-1/Lesson-2/SendSms/.idea/vcs.xml create mode 100644 Android-1/Lesson-2/SendSms/app/.gitignore create mode 100644 Android-1/Lesson-2/SendSms/app/build.gradle create mode 100644 Android-1/Lesson-2/SendSms/app/proguard-rules.pro create mode 100644 Android-1/Lesson-2/SendSms/app/src/androidTest/java/ru/geekbrains/sendsms/ExampleInstrumentedTest.java create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/AndroidManifest.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/java/ru/geekbrains/sendsms/MainActivity.java create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/layout/activity_main.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/values/colors.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/values/strings.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/main/res/values/styles.xml create mode 100644 Android-1/Lesson-2/SendSms/app/src/test/java/ru/geekbrains/sendsms/ExampleUnitTest.java create mode 100644 Android-1/Lesson-2/SendSms/build.gradle create mode 100644 Android-1/Lesson-2/SendSms/gradle.properties create mode 100644 Android-1/Lesson-2/SendSms/gradle/wrapper/gradle-wrapper.jar create mode 100644 Android-1/Lesson-2/SendSms/gradle/wrapper/gradle-wrapper.properties create mode 100644 Android-1/Lesson-2/SendSms/gradlew create mode 100644 Android-1/Lesson-2/SendSms/gradlew.bat create mode 100644 Android-1/Lesson-2/SendSms/settings.gradle diff --git a/Android-1/Lesson-2/SendSms/.gitignore b/Android-1/Lesson-2/SendSms/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/.gitignore @@ -0,0 +1,13 @@ +*.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 diff --git a/Android-1/Lesson-2/SendSms/.idea/encodings.xml b/Android-1/Lesson-2/SendSms/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Android-1/Lesson-2/SendSms/.idea/gradle.xml b/Android-1/Lesson-2/SendSms/.idea/gradle.xml new file mode 100644 index 0000000..2996d53 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/.idea/gradle.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/Android-1/Lesson-2/SendSms/.idea/misc.xml b/Android-1/Lesson-2/SendSms/.idea/misc.xml new file mode 100644 index 0000000..a6a242a --- /dev/null +++ b/Android-1/Lesson-2/SendSms/.idea/misc.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + Android + + + CorrectnessLintAndroid + + + LintAndroid + + + + + + + + + + + \ No newline at end of file diff --git a/Android-1/Lesson-2/SendSms/.idea/runConfigurations.xml b/Android-1/Lesson-2/SendSms/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Android-1/Lesson-2/SendSms/.idea/vcs.xml b/Android-1/Lesson-2/SendSms/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/Android-1/Lesson-2/SendSms/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Android-1/Lesson-2/SendSms/app/.gitignore b/Android-1/Lesson-2/SendSms/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/Android-1/Lesson-2/SendSms/app/build.gradle b/Android-1/Lesson-2/SendSms/app/build.gradle new file mode 100644 index 0000000..103f1a1 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "ru.geekbrains.sendsms" + minSdkVersion 24 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} diff --git a/Android-1/Lesson-2/SendSms/app/proguard-rules.pro b/Android-1/Lesson-2/SendSms/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/proguard-rules.pro @@ -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 diff --git a/Android-1/Lesson-2/SendSms/app/src/androidTest/java/ru/geekbrains/sendsms/ExampleInstrumentedTest.java b/Android-1/Lesson-2/SendSms/app/src/androidTest/java/ru/geekbrains/sendsms/ExampleInstrumentedTest.java new file mode 100644 index 0000000..66d1e88 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/src/androidTest/java/ru/geekbrains/sendsms/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package ru.geekbrains.sendsms; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.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 Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("ru.geekbrains.sendsms", appContext.getPackageName()); + } +} diff --git a/Android-1/Lesson-2/SendSms/app/src/main/AndroidManifest.xml b/Android-1/Lesson-2/SendSms/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..b0125bf --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android-1/Lesson-2/SendSms/app/src/main/java/ru/geekbrains/sendsms/MainActivity.java b/Android-1/Lesson-2/SendSms/app/src/main/java/ru/geekbrains/sendsms/MainActivity.java new file mode 100644 index 0000000..2e61699 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/src/main/java/ru/geekbrains/sendsms/MainActivity.java @@ -0,0 +1,31 @@ +package ru.geekbrains.sendsms; + +import android.content.Intent; +import android.net.Uri; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + final EditText text = findViewById(R.id.editText); + Button send = findViewById(R.id.button); + send.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String smsBody = text.getText().toString(); + Intent smsSend = new Intent(Intent.ACTION_SENDTO); + smsSend.setData(Uri.parse("smsto:")); + smsSend.putExtra("sms_body", smsBody); + startActivity(smsSend); + } + }); + } +} diff --git a/Android-1/Lesson-2/SendSms/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Android-1/Lesson-2/SendSms/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/Android-1/Lesson-2/SendSms/app/src/main/res/drawable/ic_launcher_background.xml b/Android-1/Lesson-2/SendSms/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Android-1/Lesson-2/SendSms/app/src/main/res/layout/activity_main.xml b/Android-1/Lesson-2/SendSms/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..a473621 --- /dev/null +++ b/Android-1/Lesson-2/SendSms/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + +