diff --git a/app/src/main/java/com/example/android/sunshine/app/FetchWeatherTask.java b/FetchWeatherTask.java similarity index 100% rename from app/src/main/java/com/example/android/sunshine/app/FetchWeatherTask.java rename to FetchWeatherTask.java diff --git a/LICENSE b/LICENSE deleted file mode 100644 index c02ca2f7a..000000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2014 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/TestFetchWeatherTask.java b/TestFetchWeatherTask.java similarity index 100% rename from app/src/androidTest/java/com/example/android/sunshine/app/TestFetchWeatherTask.java rename to TestFetchWeatherTask.java diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestProvider.java b/TestProvider.java similarity index 100% rename from app/src/androidTest/java/com/example/android/sunshine/app/data/TestProvider.java rename to TestProvider.java diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestUriMatcher.java b/TestUriMatcher.java similarity index 100% rename from app/src/androidTest/java/com/example/android/sunshine/app/data/TestUriMatcher.java rename to TestUriMatcher.java diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java b/TestWeatherContract.java similarity index 100% rename from app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java rename to TestWeatherContract.java diff --git a/app/src/main/java/com/example/android/sunshine/app/data/WeatherProvider.java b/WeatherProvider.java similarity index 100% rename from app/src/main/java/com/example/android/sunshine/app/data/WeatherProvider.java rename to WeatherProvider.java diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d1c..000000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 19167f951..000000000 --- a/app/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" - - defaultConfig { - applicationId "com.example.android.sunshine.app" - minSdkVersion 10 - targetSdkVersion 21 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:21.0.2' -} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index eba3bbfce..000000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/lyla/Library/Android/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# 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 *; -#} diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/FullTestSuite.java b/app/src/androidTest/java/com/example/android/sunshine/app/FullTestSuite.java deleted file mode 100644 index 0c037a1a2..000000000 --- a/app/src/androidTest/java/com/example/android/sunshine/app/FullTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app; - -import android.test.suitebuilder.TestSuiteBuilder; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class FullTestSuite extends TestSuite { - public static Test suite() { - return new TestSuiteBuilder(FullTestSuite.class) - .includeAllPackagesUnderHere().build(); - } - - public FullTestSuite() { - super(); - } -} diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestDb.java b/app/src/androidTest/java/com/example/android/sunshine/app/data/TestDb.java deleted file mode 100644 index c1cd6510d..000000000 --- a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestDb.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app.data; - -import android.content.ContentValues; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.test.AndroidTestCase; - -import java.util.HashSet; - -public class TestDb extends AndroidTestCase { - - public static final String LOG_TAG = TestDb.class.getSimpleName(); - - // Since we want each test to start with a clean slate - void deleteTheDatabase() { - mContext.deleteDatabase(WeatherDbHelper.DATABASE_NAME); - } - - /* - This function gets called before each test is executed to delete the database. This makes - sure that we always have a clean test. - */ - public void setUp() { - deleteTheDatabase(); - } - - /* - Students: Uncomment this test once you've written the code to create the Location - table. Note that you will have to have chosen the same column names that I did in - my solution for this test to compile, so if you haven't yet done that, this is - a good time to change your column names to match mine. - - Note that this only tests that the Location table has the correct columns, since we - give you the code for the weather table. This test does not look at the - */ - public void testCreateDb() throws Throwable { - // build a HashSet of all of the table names we wish to look for - // Note that there will be another table in the DB that stores the - // Android metadata (db version information) - final HashSet tableNameHashSet = new HashSet(); - tableNameHashSet.add(WeatherContract.LocationEntry.TABLE_NAME); - tableNameHashSet.add(WeatherContract.WeatherEntry.TABLE_NAME); - - mContext.deleteDatabase(WeatherDbHelper.DATABASE_NAME); - SQLiteDatabase db = new WeatherDbHelper( - this.mContext).getWritableDatabase(); - assertEquals(true, db.isOpen()); - - // have we created the tables we want? - Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null); - - assertTrue("Error: This means that the database has not been created correctly", - c.moveToFirst()); - - // verify that the tables have been created - do { - tableNameHashSet.remove(c.getString(0)); - } while( c.moveToNext() ); - - // if this fails, it means that your database doesn't contain both the location entry - // and weather entry tables - assertTrue("Error: Your database was created without both the location entry and weather entry tables", - tableNameHashSet.isEmpty()); - - // now, do our tables contain the correct columns? - c = db.rawQuery("PRAGMA table_info(" + WeatherContract.LocationEntry.TABLE_NAME + ")", - null); - - assertTrue("Error: This means that we were unable to query the database for table information.", - c.moveToFirst()); - - // Build a HashSet of all of the column names we want to look for - final HashSet locationColumnHashSet = new HashSet(); - locationColumnHashSet.add(WeatherContract.LocationEntry._ID); - locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_CITY_NAME); - locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_COORD_LAT); - locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_COORD_LONG); - locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING); - - int columnNameIndex = c.getColumnIndex("name"); - do { - String columnName = c.getString(columnNameIndex); - locationColumnHashSet.remove(columnName); - } while(c.moveToNext()); - - // if this fails, it means that your database doesn't contain all of the required location - // entry columns - assertTrue("Error: The database doesn't contain all of the required location entry columns", - locationColumnHashSet.isEmpty()); - db.close(); - } - - /* - Students: Here is where you will build code to test that we can insert and query the - location database. We've done a lot of work for you. You'll want to look in TestUtilities - where you can uncomment out the "createNorthPoleLocationValues" function. You can - also make use of the ValidateCurrentRecord function from within TestUtilities. - */ - public void testLocationTable() { - insertLocation(); - } - - /* - Students: Here is where you will build code to test that we can insert and query the - database. We've done a lot of work for you. You'll want to look in TestUtilities - where you can use the "createWeatherValues" function. You can - also make use of the validateCurrentRecord function from within TestUtilities. - */ - public void testWeatherTable() { - // First insert the location, and then use the locationRowId to insert - // the weather. Make sure to cover as many failure cases as you can. - - // Instead of rewriting all of the code we've already written in testLocationTable - // we can move this code to insertLocation and then call insertLocation from both - // tests. Why move it? We need the code to return the ID of the inserted location - // and our testLocationTable can only return void because it's a test. - - long locationRowId = insertLocation(); - - // Make sure we have a valid row ID. - assertFalse("Error: Location Not Inserted Correctly", locationRowId == -1L); - - // First step: Get reference to writable database - // If there's an error in those massive SQL table creation Strings, - // errors will be thrown here when you try to get a writable database. - WeatherDbHelper dbHelper = new WeatherDbHelper(mContext); - SQLiteDatabase db = dbHelper.getWritableDatabase(); - - // Second Step (Weather): Create weather values - ContentValues weatherValues = TestUtilities.createWeatherValues(locationRowId); - - // Third Step (Weather): Insert ContentValues into database and get a row ID back - long weatherRowId = db.insert(WeatherContract.WeatherEntry.TABLE_NAME, null, weatherValues); - assertTrue(weatherRowId != -1); - - // Fourth Step: Query the database and receive a Cursor back - // A cursor is your primary interface to the query results. - Cursor weatherCursor = db.query( - WeatherContract.WeatherEntry.TABLE_NAME, // Table to Query - null, // leaving "columns" null just returns all the columns. - null, // cols for "where" clause - null, // values for "where" clause - null, // columns to group by - null, // columns to filter by row groups - null // sort order - ); - - // Move the cursor to the first valid database row and check to see if we have any rows - assertTrue( "Error: No Records returned from location query", weatherCursor.moveToFirst() ); - - // Fifth Step: Validate the location Query - TestUtilities.validateCurrentRecord("testInsertReadDb weatherEntry failed to validate", - weatherCursor, weatherValues); - - // Move the cursor to demonstrate that there is only one record in the database - assertFalse( "Error: More than one record returned from weather query", - weatherCursor.moveToNext() ); - - // Sixth Step: Close cursor and database - weatherCursor.close(); - dbHelper.close(); - } - - - /* - Students: This is a helper method for the testWeatherTable quiz. You can move your - code from testLocationTable to here so that you can call this code from both - testWeatherTable and testLocationTable. - */ - public long insertLocation() { - // First step: Get reference to writable database - // If there's an error in those massive SQL table creation Strings, - // errors will be thrown here when you try to get a writable database. - WeatherDbHelper dbHelper = new WeatherDbHelper(mContext); - SQLiteDatabase db = dbHelper.getWritableDatabase(); - - // Second Step: Create ContentValues of what you want to insert - // (you can use the createNorthPoleLocationValues if you wish) - ContentValues testValues = TestUtilities.createNorthPoleLocationValues(); - - // Third Step: Insert ContentValues into database and get a row ID back - long locationRowId; - locationRowId = db.insert(WeatherContract.LocationEntry.TABLE_NAME, null, testValues); - - // Verify we got a row back. - assertTrue(locationRowId != -1); - - // Data's inserted. IN THEORY. Now pull some out to stare at it and verify it made - // the round trip. - - // Fourth Step: Query the database and receive a Cursor back - // A cursor is your primary interface to the query results. - Cursor cursor = db.query( - WeatherContract.LocationEntry.TABLE_NAME, // Table to Query - null, // all columns - null, // Columns for the "where" clause - null, // Values for the "where" clause - null, // columns to group by - null, // columns to filter by row groups - null // sort order - ); - - // Move the cursor to a valid database row and check to see if we got any records back - // from the query - assertTrue( "Error: No Records returned from location query", cursor.moveToFirst() ); - - // Fifth Step: Validate data in resulting Cursor with the original ContentValues - // (you can use the validateCurrentRecord function in TestUtilities to validate the - // query if you like) - TestUtilities.validateCurrentRecord("Error: Location Query Validation Failed", - cursor, testValues); - - // Move the cursor to demonstrate that there is only one record in the database - assertFalse( "Error: More than one record returned from location query", - cursor.moveToNext() ); - - // Sixth Step: Close Cursor and Database - cursor.close(); - db.close(); - return locationRowId; - } -} diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestUtilities.java b/app/src/androidTest/java/com/example/android/sunshine/app/data/TestUtilities.java deleted file mode 100644 index 593957231..000000000 --- a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestUtilities.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.example.android.sunshine.app.data; - -import android.content.ContentValues; -import android.content.Context; -import android.database.ContentObserver; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.net.Uri; -import android.os.Handler; -import android.os.HandlerThread; -import android.test.AndroidTestCase; - -import com.example.android.sunshine.app.utils.PollingCheck; - -import java.util.Map; -import java.util.Set; - -/* - Students: These are functions and some test data to make it easier to test your database and - Content Provider. Note that you'll want your WeatherContract class to exactly match the one - in our solution to use these as-given. - */ -public class TestUtilities extends AndroidTestCase { - static final String TEST_LOCATION = "99705"; - static final long TEST_DATE = 1419033600L; // December 20th, 2014 - - static void validateCursor(String error, Cursor valueCursor, ContentValues expectedValues) { - assertTrue("Empty cursor returned. " + error, valueCursor.moveToFirst()); - validateCurrentRecord(error, valueCursor, expectedValues); - valueCursor.close(); - } - - static void validateCurrentRecord(String error, Cursor valueCursor, ContentValues expectedValues) { - Set> valueSet = expectedValues.valueSet(); - for (Map.Entry entry : valueSet) { - String columnName = entry.getKey(); - int idx = valueCursor.getColumnIndex(columnName); - assertFalse("Column '" + columnName + "' not found. " + error, idx == -1); - String expectedValue = entry.getValue().toString(); - assertEquals("Value '" + entry.getValue().toString() + - "' did not match the expected value '" + - expectedValue + "'. " + error, expectedValue, valueCursor.getString(idx)); - } - } - - /* - Students: Use this to create some default weather values for your database tests. - */ - static ContentValues createWeatherValues(long locationRowId) { - ContentValues weatherValues = new ContentValues(); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_LOC_KEY, locationRowId); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_DATE, TEST_DATE); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_DEGREES, 1.1); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_HUMIDITY, 1.2); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_PRESSURE, 1.3); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_MAX_TEMP, 75); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_MIN_TEMP, 65); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_SHORT_DESC, "Asteroids"); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_WIND_SPEED, 5.5); - weatherValues.put(WeatherContract.WeatherEntry.COLUMN_WEATHER_ID, 321); - - return weatherValues; - } - - /* - Students: You can uncomment this helper function once you have finished creating the - LocationEntry part of the WeatherContract. - */ - static ContentValues createNorthPoleLocationValues() { - // Create a new map of values, where column names are the keys - ContentValues testValues = new ContentValues(); - testValues.put(WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING, TEST_LOCATION); - testValues.put(WeatherContract.LocationEntry.COLUMN_CITY_NAME, "North Pole"); - testValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LAT, 64.7488); - testValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LONG, -147.353); - - return testValues; - } - - /* - Students: You can uncomment this function once you have finished creating the - LocationEntry part of the WeatherContract as well as the WeatherDbHelper. - */ - static long insertNorthPoleLocationValues(Context context) { - // insert our test records into the database - WeatherDbHelper dbHelper = new WeatherDbHelper(context); - SQLiteDatabase db = dbHelper.getWritableDatabase(); - ContentValues testValues = TestUtilities.createNorthPoleLocationValues(); - - long locationRowId; - locationRowId = db.insert(WeatherContract.LocationEntry.TABLE_NAME, null, testValues); - - // Verify we got a row back. - assertTrue("Error: Failure to insert North Pole Location Values", locationRowId != -1); - - return locationRowId; - } - - /* - Students: The functions we provide inside of TestProvider use this utility class to test - the ContentObserver callbacks using the PollingCheck class that we grabbed from the Android - CTS tests. - - Note that this only tests that the onChange function is called; it does not test that the - correct Uri is returned. - */ - static class TestContentObserver extends ContentObserver { - final HandlerThread mHT; - boolean mContentChanged; - - static TestContentObserver getTestContentObserver() { - HandlerThread ht = new HandlerThread("ContentObserverThread"); - ht.start(); - return new TestContentObserver(ht); - } - - private TestContentObserver(HandlerThread ht) { - super(new Handler(ht.getLooper())); - mHT = ht; - } - - // On earlier versions of Android, this onChange method is called - @Override - public void onChange(boolean selfChange) { - onChange(selfChange, null); - } - - @Override - public void onChange(boolean selfChange, Uri uri) { - mContentChanged = true; - } - - public void waitForNotificationOrFail() { - // Note: The PollingCheck class is taken from the Android CTS (Compatibility Test Suite). - // It's useful to look at the Android CTS source for ideas on how to test your Android - // applications. The reason that PollingCheck works is that, by default, the JUnit - // testing framework is not running on the main Android application thread. - new PollingCheck(5000) { - @Override - protected boolean check() { - return mContentChanged; - } - }.run(); - mHT.quit(); - } - } - - static TestContentObserver getTestContentObserver() { - return TestContentObserver.getTestContentObserver(); - } -} diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/utils/PollingCheck.java b/app/src/androidTest/java/com/example/android/sunshine/app/utils/PollingCheck.java deleted file mode 100644 index 733d503d0..000000000 --- a/app/src/androidTest/java/com/example/android/sunshine/app/utils/PollingCheck.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Note: This file copied from the Android CTS Tests - */ -package com.example.android.sunshine.app.utils; - -import junit.framework.Assert; - -import java.util.concurrent.Callable; - -public abstract class PollingCheck { - private static final long TIME_SLICE = 50; - private long mTimeout = 3000; - - public PollingCheck() { - } - - public PollingCheck(long timeout) { - mTimeout = timeout; - } - - protected abstract boolean check(); - - public void run() { - if (check()) { - return; - } - - long timeout = mTimeout; - while (timeout > 0) { - try { - Thread.sleep(TIME_SLICE); - } catch (InterruptedException e) { - Assert.fail("unexpected InterruptedException"); - } - - if (check()) { - return; - } - - timeout -= TIME_SLICE; - } - - Assert.fail("unexpected timeout"); - } - - public static void check(CharSequence message, long timeout, Callable condition) - throws Exception { - while (timeout > 0) { - if (condition.call()) { - return; - } - - Thread.sleep(TIME_SLICE); - timeout -= TIME_SLICE; - } - - Assert.fail(message.toString()); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 99c059290..000000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/java/com/example/android/sunshine/app/DetailActivity.java b/app/src/main/java/com/example/android/sunshine/app/DetailActivity.java deleted file mode 100644 index 08b9116b2..000000000 --- a/app/src/main/java/com/example/android/sunshine/app/DetailActivity.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.android.sunshine.app; - -import android.support.v7.app.ActionBarActivity; -import android.content.Intent; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.widget.ShareActionProvider; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -public class DetailActivity extends ActionBarActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_detail); - if (savedInstanceState == null) { - getSupportFragmentManager().beginTransaction() - .add(R.id.container, new DetailFragment()) - .commit(); - } - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.detail, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - startActivity(new Intent(this, SettingsActivity.class)); - return true; - } - - return super.onOptionsItemSelected(item); - } - - /** - * A placeholder fragment containing a simple view. - */ - public static class DetailFragment extends Fragment { - - private static final String LOG_TAG = DetailFragment.class.getSimpleName(); - - private static final String FORECAST_SHARE_HASHTAG = " #SunshineApp"; - private String mForecastStr; - - public DetailFragment() { - setHasOptionsMenu(true); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View rootView = inflater.inflate(R.layout.fragment_detail, container, false); - - // The detail Activity called via intent. Inspect the intent for forecast data. - Intent intent = getActivity().getIntent(); - if (intent != null && intent.hasExtra(Intent.EXTRA_TEXT)) { - mForecastStr = intent.getStringExtra(Intent.EXTRA_TEXT); - ((TextView) rootView.findViewById(R.id.detail_text)) - .setText(mForecastStr); - } - - return rootView; - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - // Inflate the menu; this adds items to the action bar if it is present. - inflater.inflate(R.menu.detailfragment, menu); - - // Retrieve the share menu item - MenuItem menuItem = menu.findItem(R.id.action_share); - - // Get the provider and hold onto it to set/change the share intent. - ShareActionProvider mShareActionProvider = - (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); - - // Attach an intent to this ShareActionProvider. You can update this at any time, - // like when the user selects a new piece of data they might like to share. - if (mShareActionProvider != null ) { - mShareActionProvider.setShareIntent(createShareForecastIntent()); - } else { - Log.d(LOG_TAG, "Share Action Provider is null?"); - } - } - - private Intent createShareForecastIntent() { - Intent shareIntent = new Intent(Intent.ACTION_SEND); - shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); - shareIntent.setType("text/plain"); - shareIntent.putExtra(Intent.EXTRA_TEXT, - mForecastStr + FORECAST_SHARE_HASHTAG); - return shareIntent; - } - } -} diff --git a/app/src/main/java/com/example/android/sunshine/app/ForecastFragment.java b/app/src/main/java/com/example/android/sunshine/app/ForecastFragment.java deleted file mode 100644 index 7b5ada34d..000000000 --- a/app/src/main/java/com/example/android/sunshine/app/ForecastFragment.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app; - -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; -import android.text.format.Time; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.ListView; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.ArrayList; - -/** - * Encapsulates fetching the forecast and displaying it as a {@link ListView} layout. - */ -public class ForecastFragment extends Fragment { - - private ArrayAdapter mForecastAdapter; - - public ForecastFragment() { - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - // Add this line in order for this fragment to handle menu events. - setHasOptionsMenu(true); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.forecastfragment, menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - if (id == R.id.action_refresh) { - updateWeather(); - return true; - } - return super.onOptionsItemSelected(item); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - // The ArrayAdapter will take data from a source and - // use it to populate the ListView it's attached to. - mForecastAdapter = - new ArrayAdapter( - getActivity(), // The current context (this activity) - R.layout.list_item_forecast, // The name of the layout ID. - R.id.list_item_forecast_textview, // The ID of the textview to populate. - new ArrayList()); - - View rootView = inflater.inflate(R.layout.fragment_main, container, false); - - // Get a reference to the ListView, and attach this adapter to it. - ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast); - listView.setAdapter(mForecastAdapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long l) { - String forecast = mForecastAdapter.getItem(position); - Intent intent = new Intent(getActivity(), DetailActivity.class) - .putExtra(Intent.EXTRA_TEXT, forecast); - startActivity(intent); - } - }); - - return rootView; - } - - private void updateWeather() { - FetchWeatherTask weatherTask = new FetchWeatherTask(); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - String location = prefs.getString(getString(R.string.pref_location_key), - getString(R.string.pref_location_default)); - weatherTask.execute(location); - } - - @Override - public void onStart() { - super.onStart(); - updateWeather(); - } - - public class FetchWeatherTask extends AsyncTask { - - private final String LOG_TAG = FetchWeatherTask.class.getSimpleName(); - - /* The date/time conversion code is going to be moved outside the asynctask later, - * so for convenience we're breaking it out into its own method now. - */ - private String getReadableDateString(long time){ - // Because the API returns a unix timestamp (measured in seconds), - // it must be converted to milliseconds in order to be converted to valid date. - SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd"); - return shortenedDateFormat.format(time); - } - - /** - * Prepare the weather high/lows for presentation. - */ - private String formatHighLows(double high, double low, String unitType) { - - if (unitType.equals(getString(R.string.pref_units_imperial))) { - high = (high * 1.8) + 32; - low = (low * 1.8) + 32; - } else if (!unitType.equals(getString(R.string.pref_units_metric))) { - Log.d(LOG_TAG, "Unit type not found: " + unitType); - } - - // For presentation, assume the user doesn't care about tenths of a degree. - long roundedHigh = Math.round(high); - long roundedLow = Math.round(low); - - String highLowStr = roundedHigh + "/" + roundedLow; - return highLowStr; - } - - /** - * Take the String representing the complete forecast in JSON Format and - * pull out the data we need to construct the Strings needed for the wireframes. - * - * Fortunately parsing is easy: constructor takes the JSON string and converts it - * into an Object hierarchy for us. - */ - private String[] getWeatherDataFromJson(String forecastJsonStr, int numDays) - throws JSONException { - - // These are the names of the JSON objects that need to be extracted. - final String OWM_LIST = "list"; - final String OWM_WEATHER = "weather"; - final String OWM_TEMPERATURE = "temp"; - final String OWM_MAX = "max"; - final String OWM_MIN = "min"; - final String OWM_DESCRIPTION = "main"; - - JSONObject forecastJson = new JSONObject(forecastJsonStr); - JSONArray weatherArray = forecastJson.getJSONArray(OWM_LIST); - - // OWM returns daily forecasts based upon the local time of the city that is being - // asked for, which means that we need to know the GMT offset to translate this data - // properly. - - // Since this data is also sent in-order and the first day is always the - // current day, we're going to take advantage of that to get a nice - // normalized UTC date for all of our weather. - - Time dayTime = new Time(); - dayTime.setToNow(); - - // we start at the day returned by local time. Otherwise this is a mess. - int julianStartDay = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff); - - // now we work exclusively in UTC - dayTime = new Time(); - - String[] resultStrs = new String[numDays]; - - // Data is fetched in Celsius by default. - // If user prefers to see in Fahrenheit, convert the values here. - // We do this rather than fetching in Fahrenheit so that the user can - // change this option without us having to re-fetch the data once - // we start storing the values in a database. - SharedPreferences sharedPrefs = - PreferenceManager.getDefaultSharedPreferences(getActivity()); - String unitType = sharedPrefs.getString( - getString(R.string.pref_units_key), - getString(R.string.pref_units_metric)); - - for(int i = 0; i < weatherArray.length(); i++) { - // For now, using the format "Day, description, hi/low" - String day; - String description; - String highAndLow; - - // Get the JSON object representing the day - JSONObject dayForecast = weatherArray.getJSONObject(i); - - // The date/time is returned as a long. We need to convert that - // into something human-readable, since most people won't read "1400356800" as - // "this saturday". - long dateTime; - // Cheating to convert this to UTC time, which is what we want anyhow - dateTime = dayTime.setJulianDay(julianStartDay+i); - day = getReadableDateString(dateTime); - - // description is in a child array called "weather", which is 1 element long. - JSONObject weatherObject = dayForecast.getJSONArray(OWM_WEATHER).getJSONObject(0); - description = weatherObject.getString(OWM_DESCRIPTION); - - // Temperatures are in a child object called "temp". Try not to name variables - // "temp" when working with temperature. It confuses everybody. - JSONObject temperatureObject = dayForecast.getJSONObject(OWM_TEMPERATURE); - double high = temperatureObject.getDouble(OWM_MAX); - double low = temperatureObject.getDouble(OWM_MIN); - - highAndLow = formatHighLows(high, low, unitType); - resultStrs[i] = day + " - " + description + " - " + highAndLow; - } - return resultStrs; - - } - @Override - protected String[] doInBackground(String... params) { - - // If there's no zip code, there's nothing to look up. Verify size of params. - if (params.length == 0) { - return null; - } - - // These two need to be declared outside the try/catch - // so that they can be closed in the finally block. - HttpURLConnection urlConnection = null; - BufferedReader reader = null; - - // Will contain the raw JSON response as a string. - String forecastJsonStr = null; - - String format = "json"; - String units = "metric"; - int numDays = 7; - - try { - // Construct the URL for the OpenWeatherMap query - // Possible parameters are avaiable at OWM's forecast API page, at - // http://openweathermap.org/API#forecast - final String FORECAST_BASE_URL = - "http://api.openweathermap.org/data/2.5/forecast/daily?"; - final String QUERY_PARAM = "q"; - final String FORMAT_PARAM = "mode"; - final String UNITS_PARAM = "units"; - final String DAYS_PARAM = "cnt"; - - Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon() - .appendQueryParameter(QUERY_PARAM, params[0]) - .appendQueryParameter(FORMAT_PARAM, format) - .appendQueryParameter(UNITS_PARAM, units) - .appendQueryParameter(DAYS_PARAM, Integer.toString(numDays)) - .build(); - - URL url = new URL(builtUri.toString()); - - // Create the request to OpenWeatherMap, and open the connection - urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setRequestMethod("GET"); - urlConnection.connect(); - - // Read the input stream into a String - InputStream inputStream = urlConnection.getInputStream(); - StringBuffer buffer = new StringBuffer(); - if (inputStream == null) { - // Nothing to do. - return null; - } - reader = new BufferedReader(new InputStreamReader(inputStream)); - - String line; - while ((line = reader.readLine()) != null) { - // Since it's JSON, adding a newline isn't necessary (it won't affect parsing) - // But it does make debugging a *lot* easier if you print out the completed - // buffer for debugging. - buffer.append(line + "\n"); - } - - if (buffer.length() == 0) { - // Stream was empty. No point in parsing. - return null; - } - forecastJsonStr = buffer.toString(); - } catch (IOException e) { - Log.e(LOG_TAG, "Error ", e); - // If the code didn't successfully get the weather data, there's no point in attemping - // to parse it. - return null; - } finally { - if (urlConnection != null) { - urlConnection.disconnect(); - } - if (reader != null) { - try { - reader.close(); - } catch (final IOException e) { - Log.e(LOG_TAG, "Error closing stream", e); - } - } - } - - try { - return getWeatherDataFromJson(forecastJsonStr, numDays); - } catch (JSONException e) { - Log.e(LOG_TAG, e.getMessage(), e); - e.printStackTrace(); - } - - // This will only happen if there was an error getting or parsing the forecast. - return null; - } - - @Override - protected void onPostExecute(String[] result) { - if (result != null) { - mForecastAdapter.clear(); - for(String dayForecastStr : result) { - mForecastAdapter.add(dayForecastStr); - } - // New data is back from the server. Hooray! - } - } - } -} diff --git a/app/src/main/java/com/example/android/sunshine/app/MainActivity.java b/app/src/main/java/com/example/android/sunshine/app/MainActivity.java deleted file mode 100644 index d2e5e50fe..000000000 --- a/app/src/main/java/com/example/android/sunshine/app/MainActivity.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app; - -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v7.app.ActionBarActivity; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; - -public class MainActivity extends ActionBarActivity { - - private final String LOG_TAG = MainActivity.class.getSimpleName(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - if (savedInstanceState == null) { - getSupportFragmentManager().beginTransaction() - .add(R.id.container, new ForecastFragment()) - .commit(); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - startActivity(new Intent(this, SettingsActivity.class)); - return true; - } - - if (id == R.id.action_map) { - openPreferredLocationInMap(); - return true; - } - return super.onOptionsItemSelected(item); - } - - private void openPreferredLocationInMap() { - SharedPreferences sharedPrefs = - PreferenceManager.getDefaultSharedPreferences(this); - String location = sharedPrefs.getString( - getString(R.string.pref_location_key), - getString(R.string.pref_location_default)); - - // Using the URI scheme for showing a location found on a map. This super-handy - // intent can is detailed in the "Common Intents" page of Android's developer site: - // http://developer.android.com/guide/components/intents-common.html#Maps - Uri geoLocation = Uri.parse("geo:0,0?").buildUpon() - .appendQueryParameter("q", location) - .build(); - - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(geoLocation); - - if (intent.resolveActivity(getPackageManager()) != null) { - startActivity(intent); - } else { - Log.d(LOG_TAG, "Couldn't call " + location + ", no receiving apps installed!"); - } - } -} diff --git a/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java b/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java deleted file mode 100644 index 98dac5661..000000000 --- a/app/src/main/java/com/example/android/sunshine/app/SettingsActivity.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app; - -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceManager; - -/** - * A {@link PreferenceActivity} that presents a set of application settings. - *

- * See - * Android Design: Settings for design guidelines and the Settings - * API Guide for more information on developing a Settings UI. - */ -public class SettingsActivity extends PreferenceActivity - implements Preference.OnPreferenceChangeListener { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - // Add 'general' preferences, defined in the XML file - addPreferencesFromResource(R.xml.pref_general); - - // For all preferences, attach an OnPreferenceChangeListener so the UI summary can be - // updated when the preference changes. - bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_location_key))); - bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_units_key))); - } - - /** - * Attaches a listener so the summary is always updated with the preference value. - * Also fires the listener once, to initialize the summary (so it shows up before the value - * is changed.) - */ - private void bindPreferenceSummaryToValue(Preference preference) { - // Set the listener to watch for value changes. - preference.setOnPreferenceChangeListener(this); - - // Trigger the listener immediately with the preference's - // current value. - onPreferenceChange(preference, - PreferenceManager - .getDefaultSharedPreferences(preference.getContext()) - .getString(preference.getKey(), "")); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - String stringValue = value.toString(); - - if (preference instanceof ListPreference) { - // For list preferences, look up the correct display value in - // the preference's 'entries' list (since they have separate labels/values). - ListPreference listPreference = (ListPreference) preference; - int prefIndex = listPreference.findIndexOfValue(stringValue); - if (prefIndex >= 0) { - preference.setSummary(listPreference.getEntries()[prefIndex]); - } - } else { - // For other preferences, set the summary to the value's simple string representation. - preference.setSummary(stringValue); - } - return true; - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java b/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java deleted file mode 100644 index 9b003430d..000000000 --- a/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app.data; - -import android.content.ContentResolver; -import android.content.ContentUris; -import android.net.Uri; -import android.provider.BaseColumns; -import android.text.format.Time; - -/** - * Defines table and column names for the weather database. - */ -public class WeatherContract { - - // The "Content authority" is a name for the entire content provider, similar to the - // relationship between a domain name and its website. A convenient string to use for the - // content authority is the package name for the app, which is guaranteed to be unique on the - // device. - public static final String CONTENT_AUTHORITY = "com.example.android.sunshine.app"; - - // Use CONTENT_AUTHORITY to create the base of all URI's which apps will use to contact - // the content provider. - public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY); - - // Possible paths (appended to base content URI for possible URI's) - // For instance, content://com.example.android.sunshine.app/weather/ is a valid path for - // looking at weather data. content://com.example.android.sunshine.app/givemeroot/ will fail, - // as the ContentProvider hasn't been given any information on what to do with "givemeroot". - // At least, let's hope not. Don't be that dev, reader. Don't be that dev. - public static final String PATH_WEATHER = "weather"; - public static final String PATH_LOCATION = "location"; - - // To make it easy to query for the exact date, we normalize all dates that go into - // the database to the start of the the Julian day at UTC. - public static long normalizeDate(long startDate) { - // normalize the start date to the beginning of the (UTC) day - Time time = new Time(); - time.set(startDate); - int julianDay = Time.getJulianDay(startDate, time.gmtoff); - return time.setJulianDay(julianDay); - } - - /* Inner class that defines the table contents of the location table */ - public static final class LocationEntry implements BaseColumns { - - public static final Uri CONTENT_URI = - BASE_CONTENT_URI.buildUpon().appendPath(PATH_LOCATION).build(); - - public static final String CONTENT_TYPE = - ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION; - public static final String CONTENT_ITEM_TYPE = - ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION; - - // Table name - public static final String TABLE_NAME = "location"; - - // The location setting string is what will be sent to openweathermap - // as the location query. - public static final String COLUMN_LOCATION_SETTING = "location_setting"; - - // Human readable location string, provided by the API. Because for styling, - // "Mountain View" is more recognizable than 94043. - public static final String COLUMN_CITY_NAME = "city_name"; - - // In order to uniquely pinpoint the location on the map when we launch the - // map intent, we store the latitude and longitude as returned by openweathermap. - public static final String COLUMN_COORD_LAT = "coord_lat"; - public static final String COLUMN_COORD_LONG = "coord_long"; - - public static Uri buildLocationUri(long id) { - return ContentUris.withAppendedId(CONTENT_URI, id); - } - } - - /* Inner class that defines the table contents of the weather table */ - public static final class WeatherEntry implements BaseColumns { - - public static final Uri CONTENT_URI = - BASE_CONTENT_URI.buildUpon().appendPath(PATH_WEATHER).build(); - - public static final String CONTENT_TYPE = - ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_WEATHER; - public static final String CONTENT_ITEM_TYPE = - ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_WEATHER; - - public static final String TABLE_NAME = "weather"; - - // Column with the foreign key into the location table. - public static final String COLUMN_LOC_KEY = "location_id"; - // Date, stored as long in milliseconds since the epoch - public static final String COLUMN_DATE = "date"; - // Weather id as returned by API, to identify the icon to be used - public static final String COLUMN_WEATHER_ID = "weather_id"; - - // Short description and long description of the weather, as provided by API. - // e.g "clear" vs "sky is clear". - public static final String COLUMN_SHORT_DESC = "short_desc"; - - // Min and max temperatures for the day (stored as floats) - public static final String COLUMN_MIN_TEMP = "min"; - public static final String COLUMN_MAX_TEMP = "max"; - - // Humidity is stored as a float representing percentage - public static final String COLUMN_HUMIDITY = "humidity"; - - // Humidity is stored as a float representing percentage - public static final String COLUMN_PRESSURE = "pressure"; - - // Windspeed is stored as a float representing windspeed mph - public static final String COLUMN_WIND_SPEED = "wind"; - - // Degrees are meteorological degrees (e.g, 0 is north, 180 is south). Stored as floats. - public static final String COLUMN_DEGREES = "degrees"; - - public static Uri buildWeatherUri(long id) { - return ContentUris.withAppendedId(CONTENT_URI, id); - } - - /* - Student: Fill in this buildWeatherLocation function - */ - public static Uri buildWeatherLocation(String locationSetting) { - return null; - } - - public static Uri buildWeatherLocationWithStartDate( - String locationSetting, long startDate) { - long normalizedDate = normalizeDate(startDate); - return CONTENT_URI.buildUpon().appendPath(locationSetting) - .appendQueryParameter(COLUMN_DATE, Long.toString(normalizedDate)).build(); - } - - public static Uri buildWeatherLocationWithDate(String locationSetting, long date) { - return CONTENT_URI.buildUpon().appendPath(locationSetting) - .appendPath(Long.toString(normalizeDate(date))).build(); - } - - public static String getLocationSettingFromUri(Uri uri) { - return uri.getPathSegments().get(1); - } - - public static long getDateFromUri(Uri uri) { - return Long.parseLong(uri.getPathSegments().get(2)); - } - - public static long getStartDateFromUri(Uri uri) { - String dateString = uri.getQueryParameter(COLUMN_DATE); - if (null != dateString && dateString.length() > 0) - return Long.parseLong(dateString); - else - return 0; - } - } -} diff --git a/app/src/main/java/com/example/android/sunshine/app/data/WeatherDbHelper.java b/app/src/main/java/com/example/android/sunshine/app/data/WeatherDbHelper.java deleted file mode 100644 index a933c101f..000000000 --- a/app/src/main/java/com/example/android/sunshine/app/data/WeatherDbHelper.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.sunshine.app.data; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; - -import com.example.android.sunshine.app.data.WeatherContract.LocationEntry; -import com.example.android.sunshine.app.data.WeatherContract.WeatherEntry; - -/** - * Manages a local database for weather data. - */ -public class WeatherDbHelper extends SQLiteOpenHelper { - - // If you change the database schema, you must increment the database version. - private static final int DATABASE_VERSION = 2; - - static final String DATABASE_NAME = "weather.db"; - - public WeatherDbHelper(Context context) { - super(context, DATABASE_NAME, null, DATABASE_VERSION); - } - - @Override - public void onCreate(SQLiteDatabase sqLiteDatabase) { - // Create a table to hold locations. A location consists of the string supplied in the - // location setting, the city name, and the latitude and longitude - final String SQL_CREATE_LOCATION_TABLE = "CREATE TABLE " + LocationEntry.TABLE_NAME + " (" + - LocationEntry._ID + " INTEGER PRIMARY KEY," + - LocationEntry.COLUMN_LOCATION_SETTING + " TEXT UNIQUE NOT NULL, " + - LocationEntry.COLUMN_CITY_NAME + " TEXT NOT NULL, " + - LocationEntry.COLUMN_COORD_LAT + " REAL NOT NULL, " + - LocationEntry.COLUMN_COORD_LONG + " REAL NOT NULL " + - " );"; - - final String SQL_CREATE_WEATHER_TABLE = "CREATE TABLE " + WeatherEntry.TABLE_NAME + " (" + - // Why AutoIncrement here, and not above? - // Unique keys will be auto-generated in either case. But for weather - // forecasting, it's reasonable to assume the user will want information - // for a certain date and all dates *following*, so the forecast data - // should be sorted accordingly. - WeatherEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + - - // the ID of the location entry associated with this weather data - WeatherEntry.COLUMN_LOC_KEY + " INTEGER NOT NULL, " + - WeatherEntry.COLUMN_DATE + " INTEGER NOT NULL, " + - WeatherEntry.COLUMN_SHORT_DESC + " TEXT NOT NULL, " + - WeatherEntry.COLUMN_WEATHER_ID + " INTEGER NOT NULL," + - - WeatherEntry.COLUMN_MIN_TEMP + " REAL NOT NULL, " + - WeatherEntry.COLUMN_MAX_TEMP + " REAL NOT NULL, " + - - WeatherEntry.COLUMN_HUMIDITY + " REAL NOT NULL, " + - WeatherEntry.COLUMN_PRESSURE + " REAL NOT NULL, " + - WeatherEntry.COLUMN_WIND_SPEED + " REAL NOT NULL, " + - WeatherEntry.COLUMN_DEGREES + " REAL NOT NULL, " + - - // Set up the location column as a foreign key to location table. - " FOREIGN KEY (" + WeatherEntry.COLUMN_LOC_KEY + ") REFERENCES " + - LocationEntry.TABLE_NAME + " (" + LocationEntry._ID + "), " + - - // To assure the application have just one weather entry per day - // per location, it's created a UNIQUE constraint with REPLACE strategy - " UNIQUE (" + WeatherEntry.COLUMN_DATE + ", " + - WeatherEntry.COLUMN_LOC_KEY + ") ON CONFLICT REPLACE);"; - - sqLiteDatabase.execSQL(SQL_CREATE_LOCATION_TABLE); - sqLiteDatabase.execSQL(SQL_CREATE_WEATHER_TABLE); - } - - @Override - public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) { - // This database is only a cache for online data, so its upgrade policy is - // to simply to discard the data and start over - // Note that this only fires if you change the version number for your database. - // It does NOT depend on the version number for your application. - // If you want to update the schema without wiping data, commenting out the next 2 lines - // should be your top priority before modifying this method. - sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + LocationEntry.TABLE_NAME); - sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + WeatherEntry.TABLE_NAME); - onCreate(sqLiteDatabase); - } -} diff --git a/app/src/main/res/drawable-hdpi/ic_launcher.png b/app/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 786258ade..000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_launcher.png b/app/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index f415afeb3..000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_launcher.png b/app/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 5fba33f65..000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/app/src/main/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index b37fe2bfb..000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/layout/activity_detail.xml b/app/src/main/res/layout/activity_detail.xml deleted file mode 100644 index 3ecaa61f8..000000000 --- a/app/src/main/res/layout/activity_detail.xml +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index b69c03abf..000000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml deleted file mode 100644 index 70bef316d..000000000 --- a/app/src/main/res/layout/fragment_detail.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml deleted file mode 100644 index 372b60d63..000000000 --- a/app/src/main/res/layout/fragment_main.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - diff --git a/app/src/main/res/layout/list_item_forecast.xml b/app/src/main/res/layout/list_item_forecast.xml deleted file mode 100644 index 965bd5714..000000000 --- a/app/src/main/res/layout/list_item_forecast.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/menu/detail.xml b/app/src/main/res/menu/detail.xml deleted file mode 100644 index 865ac0539..000000000 --- a/app/src/main/res/menu/detail.xml +++ /dev/null @@ -1,9 +0,0 @@ -

- - diff --git a/app/src/main/res/menu/detailfragment.xml b/app/src/main/res/menu/detailfragment.xml deleted file mode 100644 index bfef05f66..000000000 --- a/app/src/main/res/menu/detailfragment.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/app/src/main/res/menu/forecastfragment.xml b/app/src/main/res/menu/forecastfragment.xml deleted file mode 100644 index 50bd1256d..000000000 --- a/app/src/main/res/menu/forecastfragment.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml deleted file mode 100644 index 87d2ed662..000000000 --- a/app/src/main/res/menu/main.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml deleted file mode 100644 index 63fc81644..000000000 --- a/app/src/main/res/values-w820dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 64dp - diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml deleted file mode 100644 index f752cb333..000000000 --- a/app/src/main/res/values/arrays.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - @string/pref_units_label_metric - @string/pref_units_label_imperial - - - - @string/pref_units_metric - @string/pref_units_imperial - - \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c822467..000000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 16dp - 16dp - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 14ae616c2..000000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - Sunshine - - - Settings - Map Location - Share - - - Refresh - Details - Settings - - - Location - - - location - - - 94043 - - - Temperature Units - - - Metric - - - Imperial - - - units - - - metric - - - imperial - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index 766ab9930..000000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml deleted file mode 100644 index 212b70ad3..000000000 --- a/app/src/main/res/xml/pref_general.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6356aabdc..000000000 --- a/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - jcenter() - } -} diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 1d3591c8a..000000000 --- a/gradle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 8c0fb64a8..000000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 0c71e760d..000000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Wed Apr 10 15:27:10 PDT 2013 -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 diff --git a/gradlew b/gradlew deleted file mode 100755 index 91a7e269e..000000000 --- a/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index aec99730b..000000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def49..000000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app'