commit 13ba1e328130811ae7fd159167d064e04b543d7a Author: Tommaso Berlose Date: Fri Oct 6 18:13:30 2017 +0200 First Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bdcf934 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + Android > Lint > Correctness + + + Android > Lint > Performance + + + Class structureJava + + + Cloning issuesJava + + + Groovy + + + Inheritance issuesJava + + + Internationalization issuesJava + + + Java + + + Numeric issuesJava + + + Performance issuesJava + + + Potentially confusing code constructsGroovy + + + Probable bugsJava + + + Security issuesJava + + + Serialization issuesJava + + + Threading issuesJava + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..63f1460 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..7f09280 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +apply plugin: 'kotlin-kapt' + +android { + compileSdkVersion 26 + buildToolsVersion "26.0.2" + defaultConfig { + applicationId "com.tommasoberlose.anotherwidget" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" + compile 'com.survivingwithandroid:weatherlib:1.6.0' + compile 'com.survivingwithandroid:weatherlib_volleyclient:1.6.0' + compile 'com.mcxiaoke.volley:library:1.0.6@aar' + compile 'com.android.support:customtabs:26.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/tommasoberlose/anotherwidget/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/tommasoberlose/anotherwidget/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..a01b8b4 --- /dev/null +++ b/app/src/androidTest/java/com/tommasoberlose/anotherwidget/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.tommasoberlose.anotherwidget + +import android.support.test.InstrumentationRegistry +import android.support.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("com.tommasoberlose.anotherwidget", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4d6ee20 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..53993a2 Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt new file mode 100644 index 0000000..1b6e98f --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt @@ -0,0 +1,22 @@ +package com.tommasoberlose.anotherwidget.`object` + +import java.text.SimpleDateFormat +import java.util.* + +/** + * Created by tommaso on 05/10/17. + */ + +object Constants { + val CALENDAR_REQUEST_CODE = 1 + val LOCATION_REQUEST_CODE = 2 + + val PREF_WEATHER_ICON = "PREF_WEATHER_ICON" + val PREF_WEATHER_TEMP = "PREF_WEATHER_TEMP" + + val dateFormat = SimpleDateFormat("EEEE, MMM d", Locale.getDefault()) + val hourFormat = SimpleDateFormat("HH:mm", Locale.getDefault()) + + val ACTION_TIME_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_TIME_UPDATE" + val ACTION_WEATHER_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_WEATHER_UPDATE" +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt new file mode 100644 index 0000000..2468172 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt @@ -0,0 +1,28 @@ +package com.tommasoberlose.anotherwidget.`object` + +import android.database.Cursor + +import java.util.Date + +/** + * Created by tommaso on 05/10/17. + */ + +class Event(eventCursor: Cursor, instanceCursor: Cursor) { + var id: Int = 0 + var title: String? = null + var startDate: Long = 0 + var endDate: Long = 0 + + init { + id = instanceCursor.getInt(0) + startDate = instanceCursor.getLong(1) + endDate = instanceCursor.getLong(2) + + title = eventCursor.getString(0) + } + + override fun toString(): String { + return "Event:\nID" + id + "\nTITLE: " + title + "\nSTART DATE: " + Date(startDate) + "\nEND DATE: " + Date(endDate) + } +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt new file mode 100644 index 0000000..a6cc082 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt @@ -0,0 +1,95 @@ +package com.tommasoberlose.anotherwidget.ui.activity + +import android.Manifest +import android.content.pm.PackageManager +import android.support.v7.app.AppCompatActivity +import android.os.Bundle +import android.support.v4.app.ActivityCompat +import android.appwidget.AppWidgetManager +import android.content.Intent +import android.content.ComponentName +import android.view.View +import android.widget.Toast +import com.tommasoberlose.anotherwidget.`object`.Constants +import com.tommasoberlose.anotherwidget.R +import com.tommasoberlose.anotherwidget.util.Util +import com.tommasoberlose.anotherwidget.ui.widget.TheWidget +import com.tommasoberlose.anotherwidget.util.UpdatesReceiver +import com.tommasoberlose.anotherwidget.util.WeatherReceiver +import kotlinx.android.synthetic.main.activity_main.* + + + + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + action_support.setOnClickListener(object: View.OnClickListener { + override fun onClick(p0: View?) { + Util.openURI(this@MainActivity, "https://paypal.me/tommasoberlose") + } + }) + + action_rate.setOnClickListener(object: View.OnClickListener { + override fun onClick(p0: View?) { + Util.openURI(this@MainActivity, "") + } + }) + + action_share.setOnClickListener(object: View.OnClickListener { + override fun onClick(p0: View?) { + Util.share(this@MainActivity) + } + }) + } + + override fun onResume() { + super.onResume() + updateUI() + Util.updateWidget(this) + } + + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, + grantResults: IntArray) { + when (requestCode) { + Constants.CALENDAR_REQUEST_CODE -> if (permissions.size != 1 || grantResults.size != 1 || grantResults[0] != PackageManager.PERMISSION_GRANTED) { + UpdatesReceiver().removeUpdates(this) + } else { + UpdatesReceiver().setUpdates(this) + } + Constants.LOCATION_REQUEST_CODE -> if (permissions.size != 1 || grantResults.size != 1 || grantResults[0] != PackageManager.PERMISSION_GRANTED) { + WeatherReceiver().removeUpdates(this) + } else { + WeatherReceiver().setUpdates(this) + } + } + } + + fun updateUI() { + no_calendar_permission_container.visibility= View.GONE + no_location_permission_container.visibility= View.GONE + + if (!Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)) { + no_calendar_permission_container.visibility = View.VISIBLE + request_calendar.setOnClickListener(object: View.OnClickListener { + override fun onClick(view: View?) { + ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.READ_CALENDAR), Constants.CALENDAR_REQUEST_CODE) + } + }) + } else { + if (!Util.checkGrantedPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)) { + no_location_permission_container.visibility = View.VISIBLE + request_location.setOnClickListener(object: View.OnClickListener { + override fun onClick(view: View?) { + ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION), Constants.LOCATION_REQUEST_CODE) + } + }) + } + } + } + + +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt new file mode 100644 index 0000000..7acf060 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt @@ -0,0 +1,224 @@ +package com.tommasoberlose.anotherwidget.ui.widget + +import android.Manifest +import android.appwidget.AppWidgetManager +import android.appwidget.AppWidgetProvider +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences +import android.preference.PreferenceManager +import android.util.Log +import android.view.View +import android.widget.RemoteViews + +import com.tommasoberlose.anotherwidget.`object`.Constants +import com.tommasoberlose.anotherwidget.`object`.Event +import com.tommasoberlose.anotherwidget.R +import com.tommasoberlose.anotherwidget.ui.activity.MainActivity +import com.tommasoberlose.anotherwidget.util.UpdatesReceiver +import com.tommasoberlose.anotherwidget.util.Util +import com.tommasoberlose.anotherwidget.util.WeatherReceiver + +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.Locale +import java.util.concurrent.TimeUnit +import android.app.PendingIntent +import android.net.Uri +import android.provider.CalendarContract +import android.content.ContentUris + + + + +/** + * Implementation of App Widget functionality. + */ +class TheWidget : AppWidgetProvider() { + + override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { + for (appWidgetId in appWidgetIds) { + updateAppWidget(context, appWidgetManager, appWidgetId) + } + } + + override fun onEnabled(context: Context) { + UpdatesReceiver().setUpdates(context) + WeatherReceiver().setUpdates(context) + Util.showNotification(context) + } + + override fun onDisabled(context: Context) { + UpdatesReceiver().removeUpdates(context) + WeatherReceiver().removeUpdates(context) + } + + companion object { + + internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, + appWidgetId: Int) { + + var views = RemoteViews(context.packageName, R.layout.the_widget) + + views = updateCalendarView(context, views, appWidgetId) + + views = updateLocationView(context, views) + + appWidgetManager.updateAppWidget(appWidgetId, views) + } + + fun updateCalendarView(context: Context, views: RemoteViews, widgetID: Int): RemoteViews { + val now = Calendar.getInstance() + val calendarLayout = Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR) + + views.setViewVisibility(R.id.empty_layout, View.VISIBLE) + views.setViewVisibility(R.id.calendar_layout, View.GONE) + views.setTextViewText(R.id.empty_date, Constants.dateFormat.format(now.time)) + + val calIntent = Intent(Intent.ACTION_MAIN) + calIntent.addCategory(Intent.CATEGORY_APP_CALENDAR) + val calPIntent = PendingIntent.getActivity(context, widgetID, calIntent, 0) + views.setOnClickPendingIntent(R.id.main_layout, calPIntent) + + + if (calendarLayout) { + val eventList = Util.getNextEvent(context) + + if (eventList.isNotEmpty()) { + val difference = eventList[0].startDate - now.timeInMillis + + if (difference > 1000 * 60) { + var time = "" + val hour = TimeUnit.MILLISECONDS.toHours(difference) + if (hour > 0) { + time = hour.toString() + "h" + } + val minutes = TimeUnit.MILLISECONDS.toMinutes(difference - hour * 3600 * 1000) + if (minutes > 0) { + time += " " + minutes + "min" + } + + views.setTextViewText(R.id.next_event, String.format("%s in %s", eventList[0].title, time)) + } else { + views.setTextViewText(R.id.next_event, String.format("%s", eventList[0].title)) + } + views.setTextViewText(R.id.next_event_date, String.format("%s - %s", Constants.hourFormat.format(eventList[0].startDate), Constants.hourFormat.format(eventList[0].endDate))) + + views.setViewVisibility(R.id.empty_layout, View.GONE) + views.setViewVisibility(R.id.calendar_layout, View.VISIBLE) + + val builder = CalendarContract.CONTENT_URI.buildUpon() + builder.appendPath("time") + ContentUris.appendId(builder, eventList[0].startDate) + val intent = Intent(Intent.ACTION_VIEW) + .setData(builder.build()) + val pIntent = PendingIntent.getActivity(context, widgetID, intent, 0) + views.setOnClickPendingIntent(R.id.main_layout, pIntent) + } + } + + return views + } + + fun updateLocationView(context: Context, views: RemoteViews): RemoteViews { + val locationLayout = Util.checkGrantedPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) + + val SP = PreferenceManager.getDefaultSharedPreferences(context) + if (locationLayout && SP.contains(Constants.PREF_WEATHER_TEMP) && SP.contains(Constants.PREF_WEATHER_ICON)) { + views.setViewVisibility(R.id.weather, View.VISIBLE) + views.setViewVisibility(R.id.calendar_weather, View.VISIBLE) + val temp = String.format(Locale.getDefault(), "%.0f °C", SP.getFloat(Constants.PREF_WEATHER_TEMP, 0f)) + + + views.setViewVisibility(R.id.weather_icon, View.VISIBLE) + views.setViewVisibility(R.id.empty_weather_icon, View.VISIBLE) + when (SP.getString(Constants.PREF_WEATHER_ICON, "")) { + "01d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.clear_day) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.clear_day) + } + "02d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.partly_cloudy) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.partly_cloudy) + } + "03d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.mostly_cloudy) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.mostly_cloudy) + } + "04d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.cloudy_weather) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.cloudy_weather) + } + "09d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.storm_weather_day) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.storm_weather_day) + } + "10d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.rainy_day) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.rainy_day) + } + "11d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.thunder_day) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.thunder_day) + } + "13d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.snow_day) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.snow_day) + } + "50d" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.haze_day) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.haze_day) + } + "01n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.clear_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.clear_night) + } + "02n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.partly_cloudy_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.partly_cloudy_night) + } + "03n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.mostly_cloudy_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.mostly_cloudy_night) + } + "04n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.cloudy_weather) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.cloudy_weather) + } + "09n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.storm_weather_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.storm_weather_night) + } + "10n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.rainy_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.rainy_night) + } + "11n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.thunder_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.thunder_night) + } + "13n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.snow_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.snow_night) + } + "50n" -> { + views.setImageViewResource(R.id.weather_icon, R.drawable.haze_night) + views.setImageViewResource(R.id.empty_weather_icon, R.drawable.haze_night) + } + else -> { + views.setViewVisibility(R.id.weather_icon, View.GONE) + views.setViewVisibility(R.id.empty_weather_icon, View.GONE) + } + } + + views.setTextViewText(R.id.temp, temp) + views.setTextViewText(R.id.calendar_temp, temp) + } else { + views.setViewVisibility(R.id.weather, View.GONE) + views.setViewVisibility(R.id.calendar_weather, View.GONE) + } + return views + } + } +} + diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/NewCalendarEventReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/NewCalendarEventReceiver.kt new file mode 100644 index 0000000..e6fe475 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/NewCalendarEventReceiver.kt @@ -0,0 +1,12 @@ +package com.tommasoberlose.anotherwidget.util + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent + +class NewCalendarEventReceiver : BroadcastReceiver() { + + override fun onReceive(context: Context, intent: Intent) { + Util.updateWidget(context) + } +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/UpdatesReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/UpdatesReceiver.kt new file mode 100644 index 0000000..b450fe0 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/UpdatesReceiver.kt @@ -0,0 +1,42 @@ +package com.tommasoberlose.anotherwidget.util + +import android.Manifest +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.R.string.cancel +import android.app.AlarmManager +import android.app.PendingIntent +import android.util.Log +import com.tommasoberlose.anotherwidget.`object`.Constants + + +class UpdatesReceiver : BroadcastReceiver() { + + override fun onReceive(context: Context, intent: Intent) { + if (intent.action.equals(Intent.ACTION_BOOT_COMPLETED) || intent.action.equals(Intent.ACTION_INSTALL_PACKAGE) || intent.action.equals(Constants.ACTION_TIME_UPDATE)) { + Util.updateWidget(context) + } + } + + fun setUpdates(context: Context) { + removeUpdates(context) + + if (Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) { + Util.updateWidget(context) + + val am = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager + val i = Intent(context, UpdatesReceiver::class.java) + i.action = Constants.ACTION_TIME_UPDATE + val pi = PendingIntent.getBroadcast(context, 0, i, 0) + am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (1000 * 60).toLong(), pi) + } + } + + fun removeUpdates(context: Context) { + val intent = Intent(context, UpdatesReceiver::class.java) + val sender = PendingIntent.getBroadcast(context, 0, intent, 0) + val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager + alarmManager.cancel(sender) + } +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt new file mode 100644 index 0000000..b8e469d --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt @@ -0,0 +1,238 @@ +package com.tommasoberlose.anotherwidget.util + +import android.Manifest +import android.annotation.SuppressLint +import android.app.Notification +import android.app.NotificationManager +import android.app.PendingIntent +import android.appwidget.AppWidgetManager +import android.content.* +import android.content.pm.PackageManager +import android.database.Cursor +import android.location.Location +import android.location.LocationListener +import android.location.LocationManager +import android.net.Uri +import android.os.Bundle +import android.preference.PreferenceManager +import android.provider.CalendarContract +import android.support.customtabs.CustomTabsIntent +import android.support.v4.app.NotificationCompat +import android.support.v4.content.ContextCompat +import android.util.Log +import com.survivingwithandroid.weather.lib.WeatherClient +import com.survivingwithandroid.weather.lib.WeatherConfig +import com.survivingwithandroid.weather.lib.exception.LocationProviderNotFoundException +import com.survivingwithandroid.weather.lib.exception.WeatherLibException +import com.survivingwithandroid.weather.lib.model.City +import com.survivingwithandroid.weather.lib.model.CurrentWeather +import com.survivingwithandroid.weather.lib.provider.forecastio.ForecastIOProviderType +import com.survivingwithandroid.weather.lib.provider.forecastio.ForecastIOWeatherProvider +import com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProviderType +import com.survivingwithandroid.weather.lib.provider.yahooweather.YahooProviderType +import com.survivingwithandroid.weather.lib.request.WeatherRequest +import com.tommasoberlose.anotherwidget.R +import com.tommasoberlose.anotherwidget.`object`.Constants + +import com.tommasoberlose.anotherwidget.`object`.Event +import com.tommasoberlose.anotherwidget.ui.activity.MainActivity +import com.tommasoberlose.anotherwidget.ui.widget.TheWidget + +import java.util.ArrayList +import java.util.Calendar + +/** + * Created by tommaso on 05/10/17. + */ + +object Util { + + + fun checkGrantedPermission(context: Context, permission: String): Boolean { + return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED + } + + fun getNextEvent(context: Context): List { + val eventList = ArrayList() + + val now = Calendar.getInstance() + val hourLimit = Calendar.getInstance() + hourLimit.add(Calendar.HOUR, 6) + + val builder = CalendarContract.Instances.CONTENT_URI.buildUpon() + ContentUris.appendId(builder, now.timeInMillis) + ContentUris.appendId(builder, hourLimit.timeInMillis) + + if (!checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) { + return eventList + } + + val instanceCursor = context.contentResolver.query(builder.build(), arrayOf(CalendarContract.Instances.EVENT_ID, CalendarContract.Instances.BEGIN, CalendarContract.Instances.END), null, null, null) ?: return eventList + instanceCursor.moveToFirst() + + for (i in 0 until instanceCursor.count) { + val ID = instanceCursor.getInt(0) + + val eventCursor = context.contentResolver.query(CalendarContract.Events.CONTENT_URI, arrayOf(CalendarContract.Events.TITLE), + CalendarContract.Events._ID + " is ?", + arrayOf(Integer.toString(ID)), null) ?: return eventList + eventCursor.moveToFirst() + + for (j in 0 until eventCursor.count) { + val e = Event(eventCursor, instanceCursor) + if (e.endDate - now.timeInMillis > 1000 * 60 * 60) { + eventList.add(e) + } + eventCursor.moveToNext() + } + + eventCursor.close() + + instanceCursor.moveToNext() + } + + instanceCursor.close() + return eventList + } + + fun updateWidget(context: Context) { + val widgetManager = AppWidgetManager.getInstance(context) + val widgetComponent = ComponentName(context, TheWidget::class.java) + val widgetIds = widgetManager.getAppWidgetIds(widgetComponent) + val update = Intent() + update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds) + update.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE + context.sendBroadcast(update) + } + + fun getWeather(context: Context) { + if (!checkGrantedPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)) { + return + } + val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + + val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + getCurrentWeather(context, locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)) + + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0f, object: LocationListener { + override fun onLocationChanged(location: Location) { + locationManager.removeUpdates(this) + getCurrentWeather(context, location) + } + + @SuppressLint("ApplySharedPref") + override fun onProviderDisabled(p0: String?) { + SP.edit() + .remove(Constants.PREF_WEATHER_TEMP) + .remove(Constants.PREF_WEATHER_ICON) + .commit() + } + + @SuppressLint("ApplySharedPref") + override fun onProviderEnabled(p0: String?) { + SP.edit() + .remove(Constants.PREF_WEATHER_TEMP) + .remove(Constants.PREF_WEATHER_ICON) + .commit() + } + + override fun onStatusChanged(p0: String?, p1: Int, p2: Bundle?) { + } + }) + } + + @SuppressLint("ApplySharedPref") + fun getCurrentWeather(context: Context, location: Location) { + val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + + try { + val config = WeatherConfig() + config.unitSystem = WeatherConfig.UNIT_SYSTEM.M + config.lang = "en" // If you want to use english + config.maxResult = 1 // Max number of cities retrieved + config.numDays = 1 // Max num of days in the forecast + config.ApiKey = "43e744ad8ff91b09ea62dbc7d0e7c1dd"; + + val client = WeatherClient.ClientBuilder().attach(context) + .httpClient(com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault::class.java) + .provider(OpenweathermapProviderType()) + .config(config) + .build() + + client.getCurrentCondition(WeatherRequest(location.longitude, location.latitude), object : WeatherClient.WeatherEventListener { + @SuppressLint("ApplySharedPref") + override fun onWeatherRetrieved(currentWeather: CurrentWeather) { + Log.d("AW", "TEMP:" + currentWeather.weather.currentCondition.icon); + SP.edit() + .putFloat(Constants.PREF_WEATHER_TEMP, currentWeather.weather.temperature.temp) + .putString(Constants.PREF_WEATHER_ICON, currentWeather.weather.currentCondition.icon) + .commit() + updateWidget(context) + } + + @SuppressLint("ApplySharedPref") + override fun onWeatherError(e: WeatherLibException?) { + SP.edit() + .remove(Constants.PREF_WEATHER_TEMP) + .remove(Constants.PREF_WEATHER_ICON) + .commit() + } + + @SuppressLint("ApplySharedPref") + override fun onConnectionError(throwable: Throwable?) { + SP.edit() + .remove(Constants.PREF_WEATHER_TEMP) + .remove(Constants.PREF_WEATHER_ICON) + .commit() + } + }) + } catch (t: Exception) { + SP.edit() + .remove(Constants.PREF_WEATHER_TEMP) + .remove(Constants.PREF_WEATHER_ICON) + .commit() + } + } + + fun showNotification(context: Context) { + val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager; + + if (!Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) { + val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Settings") + .setSmallIcon(R.drawable.ic_stat_name) + .setPriority(Notification.PRIORITY_MIN) + .setColor(ContextCompat.getColor(context, R.color.colorPrimary)) + .setContentTitle(context.getString(R.string.notification_title)) + .setContentText(context.getString(R.string.notification_subtitle)) + .setAutoCancel(true); + + val intent: Intent = Intent(context, MainActivity::class.java); + val pi: PendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + mBuilder.setContentIntent(pi); + mNotificationManager.notify(0, mBuilder.build()); + } else { + mNotificationManager.cancel(0); + } + + } + + fun openURI(context: Context, url: String) { + try { + val builder: CustomTabsIntent.Builder = CustomTabsIntent.Builder(); + builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimary)); + val customTabsIntent: CustomTabsIntent = builder.build(); + customTabsIntent.launchUrl(context, Uri.parse(url)); + } catch (e: Exception) { + val legalIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)); + context.startActivity(legalIntent); + } + } + + fun share(context: Context) { + val sendIntent = Intent(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, + "Yep, just another cool widget: https://play.google.com/store/apps/details?id=com.tommasoberlose.anotherwidget"); + sendIntent.setType("text/plain"); + context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.action_share))); + } +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherReceiver.kt new file mode 100644 index 0000000..d6a32e8 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherReceiver.kt @@ -0,0 +1,39 @@ +package com.tommasoberlose.anotherwidget.util + +import android.Manifest +import android.app.AlarmManager +import android.app.PendingIntent +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.tommasoberlose.anotherwidget.`object`.Constants + +class WeatherReceiver : BroadcastReceiver() { + + override fun onReceive(context: Context, intent: Intent) { + if (intent.action.equals(Intent.ACTION_BOOT_COMPLETED) || intent.action.equals(Intent.ACTION_INSTALL_PACKAGE) || intent.action.equals(Constants.ACTION_WEATHER_UPDATE)) { + Util.getWeather(context) + } + } + + fun setUpdates(context: Context) { + removeUpdates(context) + + if (Util.checkGrantedPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)) { + Util.getWeather(context) + + val am = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager + val i = Intent(context, WeatherReceiver::class.java) + i.action = Constants.ACTION_WEATHER_UPDATE + val pi = PendingIntent.getBroadcast(context, 1, i, 0) + am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (1000 * 60 * 60 * 2).toLong(), pi) // 2 hour + } + } + + fun removeUpdates(context: Context) { + val intent = Intent(context, WeatherReceiver::class.java) + val sender = PendingIntent.getBroadcast(context, 1, intent, 0) + val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager + alarmManager.cancel(sender) + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_action_calendar.png b/app/src/main/res/drawable-hdpi/ic_action_calendar.png new file mode 100644 index 0000000..5e217b0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_calendar.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_feedback.png b/app/src/main/res/drawable-hdpi/ic_action_feedback.png new file mode 100644 index 0000000..7ff2b85 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_feedback.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_gift.png b/app/src/main/res/drawable-hdpi/ic_action_gift.png new file mode 100644 index 0000000..01f6a71 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_gift.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_location.png b/app/src/main/res/drawable-hdpi/ic_action_location.png new file mode 100644 index 0000000..4f610b4 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_location.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_rate.png b/app/src/main/res/drawable-hdpi/ic_action_rate.png new file mode 100644 index 0000000..220c2e1 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_rate.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_action_share.png b/app/src/main/res/drawable-hdpi/ic_action_share.png new file mode 100644 index 0000000..1beca5c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_stat_name.png b/app/src/main/res/drawable-hdpi/ic_stat_name.png new file mode 100644 index 0000000..dce1092 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_calendar.png b/app/src/main/res/drawable-mdpi/ic_action_calendar.png new file mode 100644 index 0000000..7f2e2fc Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_calendar.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_feedback.png b/app/src/main/res/drawable-mdpi/ic_action_feedback.png new file mode 100644 index 0000000..bd9ce90 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_feedback.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_gift.png b/app/src/main/res/drawable-mdpi/ic_action_gift.png new file mode 100644 index 0000000..61b96f3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_gift.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_location.png b/app/src/main/res/drawable-mdpi/ic_action_location.png new file mode 100644 index 0000000..d178b2b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_location.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_rate.png b/app/src/main/res/drawable-mdpi/ic_action_rate.png new file mode 100644 index 0000000..6cc7f06 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_rate.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_share.png b/app/src/main/res/drawable-mdpi/ic_action_share.png new file mode 100644 index 0000000..7560ad2 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_stat_name.png b/app/src/main/res/drawable-mdpi/ic_stat_name.png new file mode 100644 index 0000000..ab1fac0 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-nodpi/example_appwidget_preview.png b/app/src/main/res/drawable-nodpi/example_appwidget_preview.png new file mode 100644 index 0000000..894b069 Binary files /dev/null and b/app/src/main/res/drawable-nodpi/example_appwidget_preview.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_calendar.png b/app/src/main/res/drawable-xhdpi/ic_action_calendar.png new file mode 100644 index 0000000..b305279 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_calendar.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_feedback.png b/app/src/main/res/drawable-xhdpi/ic_action_feedback.png new file mode 100644 index 0000000..7abb816 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_feedback.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_gift.png b/app/src/main/res/drawable-xhdpi/ic_action_gift.png new file mode 100644 index 0000000..e4ccab1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_gift.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_location.png b/app/src/main/res/drawable-xhdpi/ic_action_location.png new file mode 100644 index 0000000..334ee55 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_location.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_rate.png b/app/src/main/res/drawable-xhdpi/ic_action_rate.png new file mode 100644 index 0000000..7efeac3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_rate.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_share.png b/app/src/main/res/drawable-xhdpi/ic_action_share.png new file mode 100644 index 0000000..b26e0d3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_stat_name.png b/app/src/main/res/drawable-xhdpi/ic_stat_name.png new file mode 100644 index 0000000..e8234ac Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_calendar.png b/app/src/main/res/drawable-xxhdpi/ic_action_calendar.png new file mode 100644 index 0000000..e48ce06 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_calendar.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_feedback.png b/app/src/main/res/drawable-xxhdpi/ic_action_feedback.png new file mode 100644 index 0000000..0772d5b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_feedback.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_gift.png b/app/src/main/res/drawable-xxhdpi/ic_action_gift.png new file mode 100644 index 0000000..ca9bac6 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_gift.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_location.png b/app/src/main/res/drawable-xxhdpi/ic_action_location.png new file mode 100644 index 0000000..b2678e5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_location.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_rate.png b/app/src/main/res/drawable-xxhdpi/ic_action_rate.png new file mode 100644 index 0000000..600c811 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_rate.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_share.png b/app/src/main/res/drawable-xxhdpi/ic_action_share.png new file mode 100644 index 0000000..8d25ace Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_share.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_stat_name.png b/app/src/main/res/drawable-xxhdpi/ic_stat_name.png new file mode 100644 index 0000000..4e553d3 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable/card_background.xml b/app/src/main/res/drawable/card_background.xml new file mode 100644 index 0000000..61e15f5 --- /dev/null +++ b/app/src/main/res/drawable/card_background.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/circle_background.xml b/app/src/main/res/drawable/circle_background.xml new file mode 100644 index 0000000..8836d09 --- /dev/null +++ b/app/src/main/res/drawable/circle_background.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/clear_day.png b/app/src/main/res/drawable/clear_day.png new file mode 100755 index 0000000..7668543 Binary files /dev/null and b/app/src/main/res/drawable/clear_day.png differ diff --git a/app/src/main/res/drawable/clear_night.png b/app/src/main/res/drawable/clear_night.png new file mode 100755 index 0000000..3059ce9 Binary files /dev/null and b/app/src/main/res/drawable/clear_night.png differ diff --git a/app/src/main/res/drawable/cloudy_weather.png b/app/src/main/res/drawable/cloudy_weather.png new file mode 100755 index 0000000..af10b10 Binary files /dev/null and b/app/src/main/res/drawable/cloudy_weather.png differ diff --git a/app/src/main/res/drawable/dark_card_background.xml b/app/src/main/res/drawable/dark_card_background.xml new file mode 100644 index 0000000..cb6b3b0 --- /dev/null +++ b/app/src/main/res/drawable/dark_card_background.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gradient_background.xml b/app/src/main/res/drawable/gradient_background.xml new file mode 100644 index 0000000..8001332 --- /dev/null +++ b/app/src/main/res/drawable/gradient_background.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/haze_day.png b/app/src/main/res/drawable/haze_day.png new file mode 100755 index 0000000..8a58826 Binary files /dev/null and b/app/src/main/res/drawable/haze_day.png differ diff --git a/app/src/main/res/drawable/haze_night.png b/app/src/main/res/drawable/haze_night.png new file mode 100755 index 0000000..94e645b Binary files /dev/null and b/app/src/main/res/drawable/haze_night.png differ diff --git a/app/src/main/res/drawable/haze_weather.png b/app/src/main/res/drawable/haze_weather.png new file mode 100755 index 0000000..193d352 Binary files /dev/null and b/app/src/main/res/drawable/haze_weather.png differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..1cd2a36 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/mostly_cloudy.png b/app/src/main/res/drawable/mostly_cloudy.png new file mode 100755 index 0000000..016361f Binary files /dev/null and b/app/src/main/res/drawable/mostly_cloudy.png differ diff --git a/app/src/main/res/drawable/mostly_cloudy_night.png b/app/src/main/res/drawable/mostly_cloudy_night.png new file mode 100755 index 0000000..37a0133 Binary files /dev/null and b/app/src/main/res/drawable/mostly_cloudy_night.png differ diff --git a/app/src/main/res/drawable/partly_cloudy.png b/app/src/main/res/drawable/partly_cloudy.png new file mode 100755 index 0000000..da7bba3 Binary files /dev/null and b/app/src/main/res/drawable/partly_cloudy.png differ diff --git a/app/src/main/res/drawable/partly_cloudy_night.png b/app/src/main/res/drawable/partly_cloudy_night.png new file mode 100755 index 0000000..4c40868 Binary files /dev/null and b/app/src/main/res/drawable/partly_cloudy_night.png differ diff --git a/app/src/main/res/drawable/rain_snow.png b/app/src/main/res/drawable/rain_snow.png new file mode 100755 index 0000000..8786304 Binary files /dev/null and b/app/src/main/res/drawable/rain_snow.png differ diff --git a/app/src/main/res/drawable/rain_snow_day.png b/app/src/main/res/drawable/rain_snow_day.png new file mode 100755 index 0000000..ffb7fcb Binary files /dev/null and b/app/src/main/res/drawable/rain_snow_day.png differ diff --git a/app/src/main/res/drawable/rain_snow_night.png b/app/src/main/res/drawable/rain_snow_night.png new file mode 100755 index 0000000..425ec46 Binary files /dev/null and b/app/src/main/res/drawable/rain_snow_night.png differ diff --git a/app/src/main/res/drawable/rainy_day.png b/app/src/main/res/drawable/rainy_day.png new file mode 100755 index 0000000..7cd3b14 Binary files /dev/null and b/app/src/main/res/drawable/rainy_day.png differ diff --git a/app/src/main/res/drawable/rainy_night.png b/app/src/main/res/drawable/rainy_night.png new file mode 100755 index 0000000..f6d26c6 Binary files /dev/null and b/app/src/main/res/drawable/rainy_night.png differ diff --git a/app/src/main/res/drawable/rainy_weather.png b/app/src/main/res/drawable/rainy_weather.png new file mode 100755 index 0000000..99df6ed Binary files /dev/null and b/app/src/main/res/drawable/rainy_weather.png differ diff --git a/app/src/main/res/drawable/showcase.png b/app/src/main/res/drawable/showcase.png new file mode 100755 index 0000000..d094d51 Binary files /dev/null and b/app/src/main/res/drawable/showcase.png differ diff --git a/app/src/main/res/drawable/snow_day.png b/app/src/main/res/drawable/snow_day.png new file mode 100755 index 0000000..363f918 Binary files /dev/null and b/app/src/main/res/drawable/snow_day.png differ diff --git a/app/src/main/res/drawable/snow_night.png b/app/src/main/res/drawable/snow_night.png new file mode 100755 index 0000000..c34aa1a Binary files /dev/null and b/app/src/main/res/drawable/snow_night.png differ diff --git a/app/src/main/res/drawable/snow_weather.png b/app/src/main/res/drawable/snow_weather.png new file mode 100755 index 0000000..b08fb89 Binary files /dev/null and b/app/src/main/res/drawable/snow_weather.png differ diff --git a/app/src/main/res/drawable/storm_weather.png b/app/src/main/res/drawable/storm_weather.png new file mode 100755 index 0000000..adaa311 Binary files /dev/null and b/app/src/main/res/drawable/storm_weather.png differ diff --git a/app/src/main/res/drawable/storm_weather_day.png b/app/src/main/res/drawable/storm_weather_day.png new file mode 100755 index 0000000..8cb290c Binary files /dev/null and b/app/src/main/res/drawable/storm_weather_day.png differ diff --git a/app/src/main/res/drawable/storm_weather_night.png b/app/src/main/res/drawable/storm_weather_night.png new file mode 100755 index 0000000..d23581d Binary files /dev/null and b/app/src/main/res/drawable/storm_weather_night.png differ diff --git a/app/src/main/res/drawable/thunder_day.png b/app/src/main/res/drawable/thunder_day.png new file mode 100755 index 0000000..512b054 Binary files /dev/null and b/app/src/main/res/drawable/thunder_day.png differ diff --git a/app/src/main/res/drawable/thunder_night.png b/app/src/main/res/drawable/thunder_night.png new file mode 100755 index 0000000..3cc624a Binary files /dev/null and b/app/src/main/res/drawable/thunder_night.png differ diff --git a/app/src/main/res/drawable/thunder_weather.png b/app/src/main/res/drawable/thunder_weather.png new file mode 100755 index 0000000..a2312f6 Binary files /dev/null and b/app/src/main/res/drawable/thunder_weather.png differ diff --git a/app/src/main/res/drawable/unknown.png b/app/src/main/res/drawable/unknown.png new file mode 100755 index 0000000..4887f60 Binary files /dev/null and b/app/src/main/res/drawable/unknown.png differ diff --git a/app/src/main/res/drawable/windy_day.png b/app/src/main/res/drawable/windy_day.png new file mode 100755 index 0000000..ffdbf08 Binary files /dev/null and b/app/src/main/res/drawable/windy_day.png differ diff --git a/app/src/main/res/drawable/windy_night.png b/app/src/main/res/drawable/windy_night.png new file mode 100755 index 0000000..54fd851 Binary files /dev/null and b/app/src/main/res/drawable/windy_night.png differ diff --git a/app/src/main/res/drawable/windy_weather.png b/app/src/main/res/drawable/windy_weather.png new file mode 100755 index 0000000..5b20afb Binary files /dev/null and b/app/src/main/res/drawable/windy_weather.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f15ce5f --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/the_widget.xml b/app/src/main/res/layout/the_widget.xml new file mode 100644 index 0000000..9a19688 --- /dev/null +++ b/app/src/main/res/layout/the_widget.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/weather_layout.xml b/app/src/main/res/layout/weather_layout.xml new file mode 100644 index 0000000..6fa9f71 --- /dev/null +++ b/app/src/main/res/layout/weather_layout.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..d42b387 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..d42b387 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..67003b7 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..bcfcb21 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..67003b7 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..078ad10 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..b90487f Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..078ad10 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..59c34d1 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..6d536d9 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..59c34d1 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9404420 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a623d38 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9404420 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..c15ec1a Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..b3b777e Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c15ec1a Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..0bf55d3 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,12 @@ + + + #0092ca + #0083B5 + #124E96 + #FF008E + #DAEAF6 + #80000000 + #48000000 + #1A000000 + #CCFFFFFF + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..605950a --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,10 @@ + + + + + 16dp + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..d3cb4db --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,19 @@ + + Another Widget + Add Another Widget + Just + Grant Permission + See your Events + Control the Weather + Grant access to your calendar\nto view events in your widget. + Grant access to your location\nto view weather in your widget. + Get more from your widget + View your events and the weather in another widget. + | + Share + Rate + Support + Good Job! + You have completed the configuration.\nWatch out for updates. + Stay up to date + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..4f7ca1d --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/the_widget_info.xml b/app/src/main/res/xml/the_widget_info.xml new file mode 100644 index 0000000..e64af29 --- /dev/null +++ b/app/src/main/res/xml/the_widget_info.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/app/src/test/java/com/tommasoberlose/anotherwidget/ExampleUnitTest.kt b/app/src/test/java/com/tommasoberlose/anotherwidget/ExampleUnitTest.kt new file mode 100644 index 0000000..7d9054a --- /dev/null +++ b/app/src/test/java/com/tommasoberlose/anotherwidget/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.tommasoberlose.anotherwidget + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..fd9f706 --- /dev/null +++ b/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.1.4-3' + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.0.0-beta7' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..aac7c9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# 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. +org.gradle.jvmargs=-Xmx1536m + +# 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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e9bc18c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Oct 05 09:43:50 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/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 + +# 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\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +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"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # 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 new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@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 new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'