Skip to content

Commit

Permalink
Merge pull request #659 from SUPLA/v24.10.04
Browse files Browse the repository at this point in the history
V24.10.04
  • Loading branch information
przemyslawzygmunt authored Oct 25, 2024
2 parents 4ccc986 + 7b48106 commit c5ea4a2
Show file tree
Hide file tree
Showing 101 changed files with 442 additions and 154 deletions.
Binary file not shown.
Binary file not shown.
12 changes: 7 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
minSdk = Versions.MinSdk
targetSdk = Versions.TargetSdk
multiDexEnabled = true
versionCode = 253
versionName = "24.10.03"
versionCode = 254
versionName = "24.10.04"

ndk {
moduleName = "suplaclient"
Expand All @@ -38,8 +38,8 @@ android {
}

compileOptions {
sourceCompatibility(JavaVersion.VERSION_17)
targetCompatibility(JavaVersion.VERSION_17)
sourceCompatibility(JavaVersion.VERSION_21)
targetCompatibility(JavaVersion.VERSION_21)
isCoreLibraryDesugaringEnabled = true
}

Expand Down Expand Up @@ -103,7 +103,7 @@ android {
}

kotlinOptions {
jvmTarget = "17"
jvmTarget = "21"
freeCompilerArgs = listOf("-Xcontext-receivers", "-Xjvm-default=all")
}
}
Expand All @@ -113,6 +113,8 @@ repositories {
}

dependencies {
implementation(project(":shared-core"))

implementation(Deps.Androidx.Core.Splash)
implementation(Deps.Multidex)
implementation(Deps.Androidx.Lifecycle.Extensions)
Expand Down
53 changes: 21 additions & 32 deletions app/src/main/java/org/supla/android/AddDeviceWizardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ of the License, or (at your option) any later version.
import org.supla.android.core.networking.suplaclient.SuplaClientEvent.AddWizardFinished;
import org.supla.android.core.networking.suplaclient.SuplaClientEvent.AddWizardStopped;
import org.supla.android.core.networking.suplaclient.SuplaClientState.Reason.AddWizardStarted;
import org.supla.android.core.networking.suplaclient.SuplaClientStateHolder;
import org.supla.android.lib.SuplaConst;
import org.supla.android.lib.SuplaRegistrationEnabled;
import org.supla.android.profile.AuthInfo;
Expand Down Expand Up @@ -167,7 +166,6 @@ public class AddDeviceWizardActivity extends WizardActivity

@Inject ProfileManager profileManager;
@Inject EspHtmlParser espHtmlParser;
@Inject SuplaClientStateHolder suplaClientStateHolder;
@Inject DisconnectUseCase disconnectUseCase;
@Inject SuplaSchedulers suplaSchedulers;

Expand Down Expand Up @@ -446,8 +444,6 @@ protected void onStart() {
return;
}

SuplaApp.getApp().getSuplaClient();

watchDog = new Timer();
watchDog.schedule(
new TimerTask() {
Expand Down Expand Up @@ -1117,23 +1113,20 @@ public void onAvailable(@NonNull Network network) {
connectivityManager.bindProcessToNetwork(network);

wizard.runOnUiThread(
new Runnable() {
@Override
public void run() {
unregisterReceivers();
removeConfigTask();

espConfigTask = new ESPConfigureTask(espHtmlParser);
espConfigTask.setDelegate(wizard);

setStep(STEP_CONFIGURE);
AuthInfo info = profileManager.getCurrentProfile().blockingGet().getAuthInfo();
espConfigTask.execute(
getSelectedSSID(),
edPassword.getText().toString(),
info.getServerForEmail(),
info.getEmailAddress());
}
() -> {
unregisterReceivers();
removeConfigTask();

espConfigTask = new ESPConfigureTask(espHtmlParser);
espConfigTask.setDelegate(wizard);

setStep(STEP_CONFIGURE);
AuthInfo info = profileManager.getCurrentProfile().blockingGet().getAuthInfo();
espConfigTask.execute(
getSelectedSSID(),
edPassword.getText().toString(),
info.getServerForEmail(),
info.getEmailAddress());
});
}

Expand All @@ -1142,12 +1135,10 @@ public void onUnavailable() {
super.onUnavailable();

wizard.runOnUiThread(
new Runnable() {
@Override
public void run() {
unregisterCallbacks();
showError(R.string.wizard_iodev_connect_failed);
}
() -> {
unregisterCallbacks();
suplaClientStateHolder.handleEvent(AddWizardFinished.INSTANCE);
showError(R.string.wizard_iodev_connect_failed);
});
}
};
Expand Down Expand Up @@ -1181,6 +1172,7 @@ private void connect() {
}

if (iodev_NetworkID == -1) {
suplaClientStateHolder.handleEvent(AddWizardFinished.INSTANCE);
showError(R.string.wizard_addnetwork_error);
return;
}
Expand Down Expand Up @@ -1294,10 +1286,6 @@ public void onReceive(Context c, Intent i) {

stateChangedReceiver = null;

if (SuplaApp.getApp().getSuplaClient() != null) {
SuplaApp.getApp().getSuplaClient().reconnect();
}

setStep(STEP_DONE);
showDone(result);
}
Expand Down Expand Up @@ -1332,6 +1320,8 @@ public void onReceive(Context c, Intent i) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
connectToInternet_Q();
}

suplaClientStateHolder.handleEvent(AddWizardFinished.INSTANCE);
}

private String getSelectedSSID() {
Expand Down Expand Up @@ -1429,7 +1419,6 @@ public void onWifiThrottlingDialogFinish(WifiThrottlingNotificationDialog dialog
}

private void resumeClientAndClose() {
suplaClientStateHolder.handleEvent(AddWizardFinished.INSTANCE);
showMain(this);
finish();
}
Expand Down
48 changes: 32 additions & 16 deletions app/src/main/java/org/supla/android/WizardActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package org.supla.android;

/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
Expand All @@ -10,6 +28,9 @@
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.inject.Inject;
import org.supla.android.core.networking.suplaclient.SuplaClientState.Locked;
import org.supla.android.core.networking.suplaclient.SuplaClientStateHolder;

@SuppressLint("Registered")
public abstract class WizardActivity extends NavigationActivity {
Expand All @@ -23,6 +44,8 @@ public abstract class WizardActivity extends NavigationActivity {
private RelativeLayout mContent;
private ArrayList<View> mPages = new ArrayList<>();

@Inject SuplaClientStateHolder suplaClientStateHolder;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -43,6 +66,15 @@ protected void onCreate(Bundle savedInstanceState) {
setBtnNextEnabled(false);
}

@Override
protected void onStart() {
super.onStart();

if (suplaClientStateHolder.stateOrNull() == Locked.INSTANCE) {
finish();
}
}

protected View addStepPage(int layoutResId, int pageId) {
View stepPage = Inflate(layoutResId, null);
if (stepPage != null) {
Expand Down Expand Up @@ -78,18 +110,6 @@ protected int getVisiblePageId() {
return 0;
}

protected void setBtnNextVisible(boolean visible) {
if (visible) {
mBtnNextLeftPart.setVisibility(View.VISIBLE);
mBtnNextMiddlePart.setVisibility(View.VISIBLE);
mBtnNextRightPart.setVisibility(View.VISIBLE);
} else {
mBtnNextLeftPart.setVisibility(View.GONE);
mBtnNextMiddlePart.setVisibility(View.GONE);
mBtnNextRightPart.setVisibility(View.GONE);
}
}

protected void setBtnNextEnabled(boolean enabled) {
mBtnNextLeftPart.setEnabled(enabled);
mBtnNextMiddlePart.setEnabled(enabled);
Expand All @@ -104,10 +124,6 @@ protected void setBtnNextText(int resId) {
mBtnNextMiddlePart.setText(resId, TextView.BufferType.NORMAL);
}

protected void setBtnNextText(String text) {
mBtnNextMiddlePart.setText(text, TextView.BufferType.NORMAL);
}

protected boolean isBtnNextPreloaderVisible() {
return mBtnNextPreloaderTimer != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sealed interface SuplaClientState {
SuplaClientEvent.Lock,
SuplaClientEvent.OnStart,
SuplaClientEvent.NetworkConnected,
SuplaClientEvent.AddWizardStopped,
is SuplaClientEvent.Finish -> null

SuplaClientEvent.Unlock -> Connecting()
Expand All @@ -60,7 +61,6 @@ sealed interface SuplaClientState {
is SuplaClientEvent.Error -> throw IllegalEvent.IllegalErrorEvent("Unexpected event in Locked")
SuplaClientEvent.Initialized -> throw IllegalEvent.IllegalInitializedEvent("Unexpected event in Locked")
SuplaClientEvent.AddWizardFinished -> throw IllegalEvent.IllegalAddWizardFinishedEvent("Unexpected event in Locked")
SuplaClientEvent.AddWizardStopped -> throw IllegalEvent.IllegalAddWizardStoppedEvent("Unexpected event in Locked")
}
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ sealed interface SuplaClientState {

SuplaClientEvent.Lock -> Locking
is SuplaClientEvent.Finish -> Finished(reason ?: event.reason)
is SuplaClientEvent.Error -> Finished(event.reason)
is SuplaClientEvent.Error -> Finished(if (reason == Reason.AddWizardStarted) reason else event.reason)

// others which should not occur
SuplaClientEvent.NoAccount -> throw IllegalEvent.IllegalNoAccountEvent("Unexpected event in Disconnecting")
Expand Down Expand Up @@ -203,7 +203,7 @@ sealed interface SuplaClientState {
is SuplaClientEvent.Error -> if (event.reason != reason) Finished(event.reason) else null
is SuplaClientEvent.Finish ->
if (event.reason != reason && reason != Reason.AddWizardStarted) Finished(event.reason ?: reason) else null
SuplaClientEvent.AddWizardStopped -> Finished(Reason.AppInBackground)
SuplaClientEvent.AddWizardStopped -> if (reason == Reason.AddWizardStarted) Finished() else Connecting()

// others which should not occur
SuplaClientEvent.Connected -> throw IllegalEvent.IllegalConnectedEvent("Unexpected event in Finished")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class SuplaClientStateHolder @Inject constructor(

fun state(): Observable<SuplaClientState> = stateSubject.hide()

fun stateOrNull(): SuplaClientState? = stateSubject.value

fun handleEvent(event: SuplaClientEvent) {
synchronized(this) {
handleEventInternally(event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.supla.android.data.model.chart

import org.supla.android.core.ui.StringProvider
import org.supla.android.data.source.local.entity.complex.ChannelDataEntity
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.core.shared.data.SuplaChannelFunction

data class ChannelChartSets(
val remoteId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package org.supla.android.data.model.general
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.core.shared.data.SuplaChannelFunction

interface ChannelBase {
val id: Long?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.supla.android.data.source.local.entity
*/

import org.supla.android.data.model.general.ChannelBase
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.core.shared.data.SuplaChannelFunction

fun ChannelBase.isHvacThermostat() =
function == SuplaChannelFunction.HVAC_THERMOSTAT ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import org.supla.android.data.source.local.entity.ChannelEntity.Companion.COLUMN
import org.supla.android.data.source.local.entity.ChannelEntity.Companion.COLUMN_LOCATION_ID
import org.supla.android.data.source.local.entity.ChannelEntity.Companion.COLUMN_PROFILE_ID
import org.supla.android.data.source.local.entity.ChannelEntity.Companion.TABLE_NAME
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.android.lib.SuplaChannel
import org.supla.core.shared.data.SuplaChannelFunction

@Entity(
tableName = TABLE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import org.supla.android.data.source.local.entity.ChannelGroupEntity.Companion.C
import org.supla.android.data.source.local.entity.ChannelGroupEntity.Companion.COLUMN_PROFILE_ID
import org.supla.android.data.source.local.entity.ChannelGroupEntity.Companion.COLUMN_REMOTE_ID
import org.supla.android.data.source.local.entity.ChannelGroupEntity.Companion.TABLE_NAME
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.android.usecases.group.totalvalue.GroupTotalValue
import org.supla.android.usecases.group.totalvalue.GroupValue
import org.supla.core.shared.data.SuplaChannelFunction

@Entity(
tableName = TABLE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import org.supla.android.data.source.local.entity.ChannelEntity
import org.supla.android.data.source.local.entity.ChannelExtendedValueEntity
import org.supla.android.data.source.local.entity.ChannelValueEntity
import org.supla.android.data.source.local.entity.LocationEntity
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.android.db.Channel
import org.supla.android.db.ChannelExtendedValue
import org.supla.android.db.ChannelValue
import org.supla.android.lib.SuplaChannelExtendedValue
import org.supla.core.shared.data.SuplaChannelFunction

data class ChannelDataEntity(
@Embedded(prefix = "channel_") val channelEntity: ChannelEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import androidx.room.Embedded
import org.supla.android.data.model.general.ChannelDataBase
import org.supla.android.data.source.local.entity.ChannelGroupEntity
import org.supla.android.data.source.local.entity.LocationEntity
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.android.db.ChannelGroup
import org.supla.core.shared.data.SuplaChannelFunction

data class ChannelGroupDataEntity(
@Embedded(prefix = "group_") val channelGroupEntity: ChannelGroupEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.supla.android.data.source.remote
*/

import org.supla.android.data.source.local.entity.ChannelEntity
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.core.shared.data.SuplaChannelFunction

enum class ChannelConfigType(val value: Int) {
UNKNOWN(-1),
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/supla/android/db/ChannelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ of the License, or (at your option) any later version.
import org.supla.android.SuplaApp;
import org.supla.android.ValuesFormatterProvider;
import org.supla.android.data.ValuesFormatter;
import org.supla.android.data.source.remote.channel.SuplaChannelFunction;
import org.supla.android.extensions.ContextExtensionsKt;
import org.supla.android.lib.SuplaChannelBase;
import org.supla.android.lib.SuplaConst;
import org.supla.core.shared.data.SuplaChannelFunction;

public abstract class ChannelBase extends DbItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import androidx.room.TypeConverter
import org.supla.android.data.source.local.entity.ChannelRelationType
import org.supla.android.data.source.remote.ChannelConfigType
import org.supla.android.data.source.remote.channel.SuplaChannelFunction
import org.supla.core.shared.data.SuplaChannelFunction
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.util.Date
Expand Down
Loading

0 comments on commit c5ea4a2

Please sign in to comment.