diff --git a/app/build.gradle b/app/build.gradle index 96b6332..176e2a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "com.fjun.hassalarm" minSdkVersion 23 targetSdkVersion 33 - versionCode 22 - versionName "1.22" + versionCode 23 + versionName "1.23" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { @@ -47,8 +47,6 @@ dependencies { implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1") kapt "androidx.room:room-compiler:2.5.1" implementation 'com.squareup.retrofit2:converter-gson:2.5.0' - implementation "com.google.auto.value:auto-value-annotations:1.7" - kapt "com.google.auto.value:auto-value:1.7" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/app/src/main/java/com/fjun/hassalarm/NextAlarmUpdaterJob.java b/app/src/main/java/com/fjun/hassalarm/NextAlarmUpdaterJob.java index e778aea..a041025 100644 --- a/app/src/main/java/com/fjun/hassalarm/NextAlarmUpdaterJob.java +++ b/app/src/main/java/com/fjun/hassalarm/NextAlarmUpdaterJob.java @@ -18,7 +18,6 @@ import com.fjun.hassalarm.history.AppDatabase; import com.fjun.hassalarm.history.Publish; import com.fjun.hassalarm.history.PublishDao; -import com.google.auto.value.AutoValue; import java.io.IOException; import java.text.SimpleDateFormat; @@ -62,7 +61,7 @@ public boolean onStartJob(JobParameters jobParameters) { final long triggerTimestamp; final String creatorPackage; try { - final Request request = createRequest(this); + final UpdateRequest request = createRequest(this); triggerTimestamp = request.triggerTimestamp(); creatorPackage = request.creatorPackage(); mCall = request.call(); @@ -134,7 +133,7 @@ public boolean onStopJob(JobParameters jobParameters) { return true; } - public Request createRequest(Context context) throws IllegalArgumentException { + public UpdateRequest createRequest(Context context) throws IllegalArgumentException { final SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String host = sharedPreferences.getString(KEY_PREFS_HOST, ""); final String apiKeyOrToken = sharedPreferences.getString(KEY_PREFS_API_KEY, ""); @@ -149,7 +148,7 @@ public Request createRequest(Context context) throws IllegalArgumentException { * Create a call that can be executed. Will throw an exception in case of any failure, * like missing parameters etc. */ - public static Request createRequest(Context context, + public static UpdateRequest createRequest(Context context, String host, String apiKeyOrToken, String entityId, @@ -234,7 +233,7 @@ public static Request createRequest(Context context, call = hassApi.setInputDatetimeUsingApiKey(datetime, apiKeyOrToken); } } - return Request.create(call, triggerTimestamp, creatorPackage); + return new UpdateRequest(triggerTimestamp, call, creatorPackage); } /** @@ -302,17 +301,4 @@ private static int deadline(Context context) { return (int)Math.min(MAX_EXECUTION_DELAY_MS, halfDiff); } } - - @AutoValue - static abstract class Request { - public abstract Call call(); - - public abstract long triggerTimestamp(); - - public abstract String creatorPackage(); - - static Request create(Call call, long triggerTimestamp, String creatorPackage) { - return new AutoValue_NextAlarmUpdaterJob_Request(call, triggerTimestamp, creatorPackage); - } - } } diff --git a/app/src/main/java/com/fjun/hassalarm/Request.kt b/app/src/main/java/com/fjun/hassalarm/Request.kt new file mode 100644 index 0000000..fa8418d --- /dev/null +++ b/app/src/main/java/com/fjun/hassalarm/Request.kt @@ -0,0 +1,13 @@ +package com.fjun.hassalarm + +import okhttp3.ResponseBody +import retrofit2.Call + +data class UpdateRequest( + @get:JvmName("triggerTimestamp") + val triggerTimestamp: Long, + @get:JvmName("call") + val call: Call, + @get:JvmName("creatorPackage") + val creatorPackage: String? = null, +) \ No newline at end of file diff --git a/app/src/main/java/com/fjun/hassalarm/TestConnectionActivity.java b/app/src/main/java/com/fjun/hassalarm/TestConnectionActivity.java index 4be59be..f0e8733 100644 --- a/app/src/main/java/com/fjun/hassalarm/TestConnectionActivity.java +++ b/app/src/main/java/com/fjun/hassalarm/TestConnectionActivity.java @@ -40,8 +40,8 @@ public class TestConnectionActivity extends AppCompatActivity { private static final String EXTRA_ENTITY_ID_IS_LEGACY = "entity_id_is_legacy"; private String mStrippedLog; + private UpdateRequest mRequest; private Boolean mLastRunWasSuccessful; - private NextAlarmUpdaterJob.Request mRequest; private ActivityTestConnectionBinding mBinding; private String mHost;