diff --git a/app/build.gradle b/app/build.gradle index 68fa06993699572b267a7de0265a61d52c808a3d..8b7cbbc2c87fbbeac7e7d50891108a7d230ce8c3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 18 - buildToolsVersion "21.1.2" + compileSdkVersion 26 + buildToolsVersion "26.0.1" defaultConfig { applicationId "course.labs.activitylab" - minSdkVersion 14 - targetSdkVersion 19 + minSdkVersion 21 + targetSdkVersion 26 testApplicationId "course.labs.activitylab.tests" - testInstrumentationRunner "android.test.InstrumentationTestRunner" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -22,5 +22,6 @@ android { } dependencies { - androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1' + androidTestCompile 'com.android.support.test:rules:0.4.1' + androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.6.0' } diff --git a/app/libs/robotium-solo-5.3.1.jar b/app/libs/robotium-solo-5.3.1.jar deleted file mode 100644 index d7f816c4c2bbc8d55b827b821fe13c8d55be4d08..0000000000000000000000000000000000000000 Binary files a/app/libs/robotium-solo-5.3.1.jar and /dev/null differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1c8a58e7a1c317c1a4cb08e78f45046a64e331bd..46d261ccee95fbae62ed8b4ebfe8e78dd308e0be 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,13 +4,9 @@ android:versionCode="1" android:versionName="1.0" > - <uses-sdk - android:minSdkVersion="14" - android:targetSdkVersion="19" /> - <application android:allowBackup="true" - android:icon="@drawable/ic_launcher" + android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity diff --git a/app/src/main/java/course/labs/activitylab/ActivityOne.java b/app/src/main/java/course/labs/activitylab/ActivityOne.java index 9e0eb5657e8fb23622ae0fe5ac03308156c0c7b9..ab12eb781148686522ed6dd8784222dbe9022a91 100644 --- a/app/src/main/java/course/labs/activitylab/ActivityOne.java +++ b/app/src/main/java/course/labs/activitylab/ActivityOne.java @@ -11,108 +11,179 @@ import android.widget.TextView; public class ActivityOne extends Activity { - // Use these as keys when you're saving state between reconfigurations - private static final String RESTART_KEY = "restart"; - private static final String RESUME_KEY = "resume"; - private static final String START_KEY = "start"; - private static final String CREATE_KEY = "create"; + private static final String RESTART_KEY = "restart"; + private static final String RESUME_KEY = "resume"; + private static final String START_KEY = "start"; + private static final String CREATE_KEY = "create"; - // String for LogCat documentation - private final static String TAG = "Lab-ActivityOne"; + // String for LogCat documentation + private final static String TAG = "Lab-ActivityOne"; - // Lifecycle counters + // Lifecycle counters - // TODO: - // Create variables named - // mCreate, mRestart, mStart and mResume - // to count calls to onCreate(), onRestart(), onStart() and - // onResume(). These variables should not be defined as static. + // TODO: + // Create counter variables for onCreate(), onRestart(), onStart() and + // onResume() + // You will need to increment these variables' values when their + // corresponding lifecycle methods get called - // You will need to increment these variables' values when their - // corresponding lifecycle methods get called. + private int mCreate = 0; + private int mRestart = 0; + private int mStart = 0; + private int mResume = 0; - // TODO: Create variables for each of the TextViews - // named mTvCreate, mTvRestart, mTvStart, mTvResume. - // for displaying the current count of each counter variable + // TODO: Create variables for each of the TextViews + private TextView mTvCreate; + private TextView mTvRestart; + private TextView mTvStart; + private TextView mTvResume; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_one); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_one); - // TODO: Assign the appropriate TextViews to the TextView variables - // Hint: Access the TextView by calling Activity's findViewById() - // textView1 = (TextView) findViewById(R.id.textView1); + // TODO: Assign the appropriate TextViews to the TextView variables + // Hint: Access the TextView by calling Activity's findViewById() + // textView1 = (TextView) findViewById(R.id.textView1); - Button launchActivityTwoButton = (Button) findViewById(R.id.bLaunchActivityTwo); - launchActivityTwoButton.setOnClickListener(new OnClickListener() { + mTvCreate = findViewById(R.id.create); + mTvRestart = findViewById(R.id.restart); + mTvStart = findViewById(R.id.start); + mTvResume = findViewById(R.id.resume); - @Override - public void onClick(View v) { - // TODO: - // Launch Activity Two - // Hint: use Context's startActivity() method + Button launchActivityTwoButton = findViewById(R.id.bLaunchActivityTwo); + launchActivityTwoButton.setOnClickListener(new OnClickListener() { - // Create an intent stating which Activity you would like to - // start - Intent intent = null; + @Override + public void onClick(View v) { + // TODO: + // Launch Activity Two + // Hint: use Context's startActivity() method - // Launch the Activity using the intent + // Create an intent stating which Activity you would like to start + Intent intent = new Intent(ActivityOne.this, ActivityTwo.class); - } - }); + // Launch the Activity using the intent + startActivity(intent); - // Emit LogCat message using the Log.i method + } + }); - } + // Has previous state been saved? + if (savedInstanceState != null) { + // TODO: + // Restore value of counters from saved state + // Only need 4 lines of code, one for every count variable + mCreate = savedInstanceState.getInt(CREATE_KEY); + mStart = savedInstanceState.getInt(START_KEY); + mResume = savedInstanceState.getInt(RESUME_KEY); + mRestart = savedInstanceState.getInt(RESTART_KEY); - @Override - public void onStart() { - super.onStart(); + } - // Emit LogCat message using the Log.i method - } + // Emit LogCat message + Log.i(TAG, "Entered the onCreate() method"); - @Override - public void onResume() { + // TODO: + // Update the appropriate count variable + // Update the user interface via the displayCounts() method + mCreate++; + displayCounts(); + + } + + // Lifecycle callback overrides + + @Override + public void onStart() { + super.onStart(); + + // Emit LogCat message + Log.i(TAG, "Entered the onStart() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface + mStart++; + displayCounts(); + } + + @Override + public void onResume() { super.onResume(); - // Emit LogCat message using the Log.i method - } - @Override - public void onPause() { + // Emit LogCat message + Log.i(TAG, "Entered the onResume() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface + mResume++; + displayCounts(); + } + + @Override + public void onPause() { super.onPause(); - // Emit LogCat message using the Log.i method - } - @Override - public void onStop() { + // Emit LogCat message + Log.i(TAG, "Entered the onPause() method"); + } + + @Override + public void onStop() { super.onStop(); - // Emit LogCat message using the Log.i method - } - @Override - public void onRestart() { + // Emit LogCat message + Log.i(TAG, "Entered the onStop() method"); + } + + @Override + public void onRestart() { super.onRestart(); - // Emit LogCat message using the Log.i method - } + // Emit LogCat message + Log.i(TAG, "Entered the onRestart() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface - @Override - public void onDestroy() { + mRestart++; + displayCounts(); + } + + @Override + public void onDestroy() { super.onDestroy(); - // Emit LogCat message using the Log.i method - } - @Override - public void onSaveInstanceState(Bundle savedInstanceState) { + // Emit LogCat message + Log.i(TAG, "Entered the onDestroy() method"); + } + + @Override + public void onSaveInstanceState(Bundle savedInstanceState) { + // TODO: + // Save state information with a collection of key-value pairs + // 4 lines of code, one for every count variable + + savedInstanceState.putInt(CREATE_KEY, mCreate); + savedInstanceState.putInt(START_KEY, mStart); + savedInstanceState.putInt(RESUME_KEY, mResume); + savedInstanceState.putInt(RESTART_KEY, mRestart); - } + } + // Updates the displayed counters + private void displayCounts() { - public void displayCounts() { + mTvCreate.setText("onCreate() calls: " + mCreate); + mTvStart.setText("onStart() calls: " + mStart); + mTvResume.setText("onResume() calls: " + mResume); + mTvRestart.setText("onRestart() calls: " + mRestart); - } + } } diff --git a/app/src/main/java/course/labs/activitylab/ActivityTwo.java b/app/src/main/java/course/labs/activitylab/ActivityTwo.java index 742dc35b3b666fca1078a2e0351ffdb3fdc69b7c..c982fd133109a645892ec60490f64539903b0542 100644 --- a/app/src/main/java/course/labs/activitylab/ActivityTwo.java +++ b/app/src/main/java/course/labs/activitylab/ActivityTwo.java @@ -10,129 +10,178 @@ import android.widget.TextView; public class ActivityTwo extends Activity { - // Use these as keys when you're saving state between reconfigurations - private static final String RESTART_KEY = "restart"; - private static final String RESUME_KEY = "resume"; - private static final String START_KEY = "start"; - private static final String CREATE_KEY = "create"; - - // String for LogCat documentation - private final static String TAG = "Lab-ActivityTwo"; - - // Lifecycle counters - - // TODO: - // Create variables named - // mCreate, mRestart, mStart and mResume - // to count calls to onCreate(), onRestart(), onStart() and - // onResume(). These variables should not be defined as static. - - // You will need to increment these variables' values when their - // corresponding lifecycle methods get called. - - - - - // TODO: Create variables for each of the TextViews - // named mTvCreate, mTvRestart, mTvStart, mTvResume. - // for displaying the current count of each counter variable - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_two); - - // TODO: Assign the appropriate TextViews to the TextView variables - // Hint: Access the TextView by calling Activity's findViewById() - // textView1 = (TextView) findViewById(R.id.textView1); - - - - - - - Button closeButton = (Button) findViewById(R.id.bClose); - closeButton.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - - // TODO: - // This function closes Activity Two - // Hint: use Context's finish() method - - - - } - }); - - // Has previous state been saved? - if (savedInstanceState != null) { - - // TODO: - // Restore value of counters from saved state - // Only need 4 lines of code, one for every count variable - - - - - - - } - - // Emit LogCat message using the Log.i method - } - - - - @Override - public void onStart() { - super.onStart(); - // Emit LogCat message using the Log.i method - } - - @Override - public void onResume() { - super.onResume(); - // Emit LogCat message using the Log.i method - - } - - @Override - public void onPause() { - super.onPause(); - // Emit LogCat message using the Log.i method - - } - - @Override - public void onStop() { - super.onStop(); - // Emit LogCat message using the Log.i method - } - - @Override - public void onRestart() { - super.onRestart(); - // Emit LogCat message using the Log.i method - } + private static final String RESTART_KEY = "restart"; + private static final String RESUME_KEY = "resume"; + private static final String START_KEY = "start"; + private static final String CREATE_KEY = "create"; - @Override - public void onDestroy() { - super.onDestroy(); - // Emit LogCat message using the Log.i method - } - - @Override - public void onSaveInstanceState(Bundle savedInstanceState) { + // String for LogCat documentation + private final static String TAG = "Lab-ActivityTwo"; - - } + // Lifecycle counters + // TODO: + // Create counter variables for onCreate(), onRestart(), onStart() and + // onResume() + // You will need to increment these variables' values when their + // corresponding lifecycle methods get called - // specified above - public void displayCounts() { + private int mCreate = 0; + private int mRestart = 0; + private int mStart = 0; + private int mResume = 0; - - } + // TODO: Create variables for each of the TextViews + private TextView mTvCreate; + private TextView mTvRestart; + private TextView mTvStart; + private TextView mTvResume; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_two); + + // TODO: Assign the appropriate TextViews to the TextView variables + // Hint: Access the TextView by calling Activity's findViewById() + // textView1 = (TextView) findViewById(R.id.textView1); + + mTvCreate = findViewById(R.id.create); + mTvRestart = findViewById(R.id.restart); + mTvStart = findViewById(R.id.start); + mTvResume = findViewById(R.id.resume); + + Button closeButton = findViewById(R.id.bClose); + closeButton.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + + // TODO: + // This function closes Activity Two + // Hint: use Context's finish() method + + finish(); + + } + }); + + // Has previous state been saved? + if (savedInstanceState != null) { + + // TODO: + // Restore value of counters from saved state + // Only need 4 lines of code, one for every count variable + + mCreate = savedInstanceState.getInt(CREATE_KEY); + mStart = savedInstanceState.getInt(START_KEY); + mResume = savedInstanceState.getInt(RESUME_KEY); + mRestart = savedInstanceState.getInt(RESTART_KEY); + + } + + // Emit LogCat message + + Log.i(TAG, "Entered the onCreate() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface via the displayCounts() method + + mCreate++; + displayCounts(); + + } + + // Lifecycle callback methods overrides + + @Override + public void onStart() { + super.onStart(); + + // Emit LogCat message + Log.i(TAG, "Entered the onStart() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface + mStart++; + displayCounts(); + } + + @Override + public void onResume() { + super.onResume(); + + // Emit LogCat message + Log.i(TAG, "Entered the onResume() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface + mResume++; + displayCounts(); + } + + @Override + public void onPause() { + super.onPause(); + + // Emit LogCat message + Log.i(TAG, "Entered the onPause() method"); + } + + @Override + public void onStop() { + super.onStop(); + + // Emit LogCat message + Log.i(TAG, "Entered the onStop() method"); + } + + @Override + public void onRestart() { + super.onRestart(); + + // Emit LogCat message + Log.i(TAG, "Entered the onRestart() method"); + + // TODO: + // Update the appropriate count variable + // Update the user interface + mRestart++; + displayCounts(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + + // Emit LogCat message + Log.i(TAG, "Entered the onDestroy() method"); + } + + @Override + public void onSaveInstanceState(Bundle savedInstanceState) { + + // TODO: + // Save counter state information with a collection of key-value pairs + // 4 lines of code, one for every count variable + + savedInstanceState.putInt(CREATE_KEY, mCreate); + savedInstanceState.putInt(START_KEY, mStart); + savedInstanceState.putInt(RESUME_KEY, mResume); + savedInstanceState.putInt(RESTART_KEY, mRestart); + + } + + // Updates the displayed counters + private void displayCounts() { + + mTvCreate.setText("onCreate() calls: " + mCreate); + mTvStart.setText("onStart() calls: " + mStart); + mTvResume.setText("onResume() calls: " + mResume); + mTvRestart.setText("onRestart() calls: " + mRestart); + + } } diff --git a/app/src/main/res/layout/activity_one.xml b/app/src/main/res/layout/activity_one.xml index a9fa450b39204a1629ee380d7e294982b846004a..a9c1cf78e745c623d17c6a40fb1f18ebd7f9a1b0 100644 --- a/app/src/main/res/layout/activity_one.xml +++ b/app/src/main/res/layout/activity_one.xml @@ -1,8 +1,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" > + android:orientation="vertical"> <TextView android:id="@+id/create" android:layout_width="wrap_content" diff --git a/app/src/main/res/layout/activity_two.xml b/app/src/main/res/layout/activity_two.xml index a9542de2a72162d321bb99adfb85b6989377671f..fe23337df67ad62e3174280711c749a01319e897 100644 --- a/app/src/main/res/layout/activity_two.xml +++ b/app/src/main/res/layout/activity_two.xml @@ -1,8 +1,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" > + android:orientation="vertical"> <TextView android:id="@+id/create" android:layout_width="wrap_content" diff --git a/app/src/main/res/drawable-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/drawable-hdpi/ic_launcher.png rename to app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/app/src/main/res/drawable-ldpi/ic_launcher.png b/app/src/main/res/mipmap-ldpi/ic_launcher.png similarity index 100% rename from app/src/main/res/drawable-ldpi/ic_launcher.png rename to app/src/main/res/mipmap-ldpi/ic_launcher.png diff --git a/app/src/main/res/drawable-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/drawable-mdpi/ic_launcher.png rename to app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/app/src/main/res/drawable-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/drawable-xhdpi/ic_launcher.png rename to app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/app/src/main/res/values-v11/styles.xml b/app/src/main/res/values-v11/styles.xml deleted file mode 100644 index 541752f6edf47a27cad70a23c00cc17aa4c84c08..0000000000000000000000000000000000000000 --- a/app/src/main/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ -<resources> - - <!-- - Base application theme for API 11+. This theme completely replaces - AppBaseTheme from res/values/styles.xml on API 11+ devices. - --> - <style name="AppBaseTheme" parent="android:Theme.Holo.Light"> - <!-- API 11 theme customizations can go here. --> - </style> - -</resources> \ No newline at end of file diff --git a/app/src/main/res/values-v14/styles.xml b/app/src/main/res/values-v14/styles.xml deleted file mode 100644 index f20e01501dfde7d1f4cc9c29f85169ce57bc5846..0000000000000000000000000000000000000000 --- a/app/src/main/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ -<resources> - - <!-- - Base application theme for API 14+. This theme completely replaces - AppBaseTheme from BOTH res/values/styles.xml and - res/values-v11/styles.xml on API 14+ devices. - --> - <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> - <!-- API 14 theme customizations can go here. --> - </style> - -</resources> \ No newline at end of file diff --git a/build.gradle b/build.gradle index 88d246d44a63a396e634c6ea68f88d57e9489e98..a1960892d522b2dccede1f54ff1b4b451b0b68b6 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:3.0.0-beta4' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c71e760dc93830dd3411fe50d6f5c86bf0a8f4d..34e12dbb69b48046629a076f2e471be9c8caa1f6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Fri Sep 08 12:02:35 EDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip