diff --git a/app/build.gradle b/app/build.gradle index f674ee7c..e47e0df8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 27 defaultConfig { applicationId "com.example.android.emojify" minSdkVersion 15 - targetSdkVersion 25 + targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -24,6 +23,8 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) + + compile 'com.android.support:design:25.2.0' compile 'com.android.support:appcompat-v7:25.2.0' compile 'com.google.android.gms:play-services-vision:10.2.0' diff --git a/app/src/main/java/com/example/android/emojify/MainActivity.java b/app/src/main/java/com/example/android/emojify/MainActivity.java index be311a78..58da462f 100644 --- a/app/src/main/java/com/example/android/emojify/MainActivity.java +++ b/app/src/main/java/com/example/android/emojify/MainActivity.java @@ -42,7 +42,12 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -import timber.log.Timber; + + +public class MainActivity extends AppCompatActivity { + + // (2): Replace all View declarations with Butterknife annotations + public class MainActivity extends AppCompatActivity { @@ -52,14 +57,25 @@ public class MainActivity extends AppCompatActivity { private static final String FILE_PROVIDER_AUTHORITY = "com.example.android.fileprovider"; - @BindView(R.id.image_view) ImageView mImageView; - @BindView(R.id.emojify_button) Button mEmojifyButton; - @BindView(R.id.share_button) FloatingActionButton mShareFab; - @BindView(R.id.save_button) FloatingActionButton mSaveFab; - @BindView(R.id.clear_button) FloatingActionButton mClearFab; + @BindView(R.id.image_view) + ImageView mImageView; + + @BindView(R.id.emojify_button) + Button mEmojifyButton; + + @BindView(R.id.share_button) + FloatingActionButton mShareFab; + + @BindView(R.id.save_button) + FloatingActionButton mSaveFab; + + @BindView(R.id.clear_button) + FloatingActionButton mClearFab; + + @BindView(R.id.title_text_view) + TextView mTitleTextView; - @BindView(R.id.title_text_view) TextView mTitleTextView; private String mTempPhotoPath; @@ -71,11 +87,12 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - // Bind the views ButterKnife.bind(this); + // (3): Replace the findViewById calls with the Butterknife data binding + // Bind the views + + - // Set up Timber - Timber.plant(new Timber.DebugTree()); } /** @@ -100,7 +117,7 @@ public void emojifyMe() { @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, - @NonNull int[] grantResults) { + @NonNull int[] grantResults) { // Called when you request permission to read and write to external storage switch (requestCode) { case REQUEST_STORAGE_PERMISSION: { @@ -193,6 +210,9 @@ private void processAndSetImage() { } + + // (4): Replace OnClick methods with Butterknife annotations for OnClicks + /** * OnClick method for the save button. */ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index b9e7065b..7dd91192 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -14,6 +14,7 @@ limitations under the License.--> +