Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: [ANDROAPP-6206] reduce number of warnings #3925

Merged
merged 11 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

import org.dhis2.App;
import org.dhis2.R;
import org.dhis2.commons.date.DateUtils;
import org.dhis2.commons.prefs.PreferenceProvider;
import org.dhis2.commons.resources.ResourceManager;
import org.dhis2.commons.Constants;
import org.dhis2.utils.DateUtils;
import org.dhis2.utils.NetworkUtils;
import org.hisp.dhis.android.core.maintenance.D2Error;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.reactivex.Observable
import org.dhis2.bindings.toSeconds
import org.dhis2.commons.bindings.enrollment
import org.dhis2.commons.bindings.program
import org.dhis2.commons.date.DateUtils
import org.dhis2.commons.prefs.Preference.Companion.DATA
import org.dhis2.commons.prefs.Preference.Companion.EVENT_MAX
import org.dhis2.commons.prefs.Preference.Companion.EVENT_MAX_DEFAULT
Expand All @@ -24,7 +25,6 @@ import org.dhis2.commons.prefs.PreferenceProvider
import org.dhis2.data.service.workManager.WorkManagerController
import org.dhis2.data.service.workManager.WorkerItem
import org.dhis2.data.service.workManager.WorkerType
import org.dhis2.utils.DateUtils
import org.dhis2.utils.analytics.AnalyticsHelper
import org.dhis2.utils.analytics.matomo.DEFAULT_EXTERNAL_TRACKER_NAME
import org.hisp.dhis.android.core.D2
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/usescases/crash/CrashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
import cat.ereza.customactivityoncrash.config.CaocConfig
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.BuildConfig
import org.dhis2.R
import org.hisp.dhis.mobile.ui.designsystem.component.Button
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle
import org.hisp.dhis.mobile.ui.designsystem.component.ColorStyle
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
Expand All @@ -61,7 +61,7 @@ class CrashActivity : AppCompatActivity() {
return
}
setContent {
MdcTheme {
DHIS2Theme {
Scaffold(
floatingActionButton = {
CrashGoBackButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.DatePicker
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -19,14 +19,14 @@ import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.unit.dp
import com.google.android.material.composethemeadapter.MdcTheme
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import org.dhis2.R
import org.dhis2.bindings.toDate
import org.dhis2.commons.Constants.ACCESS_DATA
import org.dhis2.commons.Constants.DATA_SET_SECTION
import org.dhis2.commons.Constants.DATA_SET_UID
import org.dhis2.commons.date.DateUtils
import org.dhis2.commons.dialogs.DialogClickListener
import org.dhis2.commons.dialogs.calendarpicker.CalendarPicker
import org.dhis2.commons.dialogs.calendarpicker.OnDatePickerListener
Expand All @@ -46,7 +46,6 @@ import org.dhis2.data.forms.dataentry.tablefields.spinner.SpinnerViewModel
import org.dhis2.usescases.datasets.dataSetTable.DataSetTableActivity
import org.dhis2.usescases.datasets.dataSetTable.DataSetTablePresenter
import org.dhis2.usescases.general.FragmentGlobalAbstract
import org.dhis2.utils.DateUtils
import org.dhis2.utils.customviews.OptionSetOnClickListener
import org.dhis2.utils.customviews.TableFieldDialog
import org.dhis2.utils.optionset.OptionSetDialog
Expand All @@ -55,6 +54,7 @@ import org.hisp.dhis.android.core.common.FeatureType
import org.hisp.dhis.android.core.common.ValueTypeRenderingType
import org.hisp.dhis.android.core.dataelement.DataElement
import org.hisp.dhis.android.core.organisationunit.OrganisationUnit
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
Expand Down Expand Up @@ -106,7 +106,7 @@ class DataSetSectionFragment : FragmentGlobalAbstract(), DataValueContract.View
return ComposeView(requireContext()).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
MdcTheme {
DHIS2Theme {
val localDensity = LocalDensity.current
val conf = LocalConfiguration.current
val tableConfState by presenterFragment.currentTableConfState().collectAsState()
Expand Down Expand Up @@ -191,9 +191,9 @@ class DataSetSectionFragment : FragmentGlobalAbstract(), DataValueContract.View

TableTheme(
tableColors = TableColors(
primary = MaterialTheme.colors.primary,
primaryLight = MaterialTheme.colors.primary.copy(alpha = 0.2f),
disabledSelectedBackground = MaterialTheme.colors.primary.copy(
primary = MaterialTheme.colorScheme.primary,
primaryLight = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f),
disabledSelectedBackground = MaterialTheme.colorScheme.primary.copy(
alpha = 0.5f,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.dhis2.bindings.ExtensionsKt;
import org.dhis2.bindings.ViewExtensionsKt;
import org.dhis2.commons.Constants;
import org.dhis2.commons.date.DateUtils;
import org.dhis2.commons.filters.FilterItem;
import org.dhis2.commons.filters.FilterManager;
import org.dhis2.commons.filters.FiltersAdapter;
Expand All @@ -32,7 +33,6 @@
import org.dhis2.ui.ThemeManager;
import org.dhis2.usescases.datasets.datasetDetail.datasetList.DataSetListFragment;
import org.dhis2.usescases.general.ActivityGlobalAbstract;
import org.dhis2.utils.DateUtils;
import org.dhis2.utils.category.CategoryDialog;
import org.dhis2.utils.granularsync.SyncStatusDialog;
import org.dhis2.utils.granularsync.SyncStatusDialogNavigatorKt;
Expand Down Expand Up @@ -197,7 +197,8 @@ public void showPeriodRequest(FilterManager.PeriodRequest periodRequest) {
DateUtils.getInstance().showPeriodDialog(
this,
datePeriods -> filterManager.addPeriod(datePeriods),
true
true,
() -> filterManager.addPeriod(null)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.viewmodel.DispatcherProvider

@Suppress("UNCHECKED_CAST")
class DataSetDetailViewModelFactory(
private val dispatcherProvider: DispatcherProvider,
private val dataSetPageConfigurator: DataSetPageConfigurator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.dhis2.commons.schedulers.SchedulerProvider
import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.usescases.datasets.datasetDetail.DataSetDetailRepository

@Suppress("UNCHECKED_CAST")
class DataSetListViewModelFactory(
val dataSetDetailRepository: DataSetDetailRepository,
val schedulerProvider: SchedulerProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.databinding.BindingAdapter
import com.google.android.material.composethemeadapter.MdcTheme
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme

@ExperimentalAnimationApi
@BindingAdapter("setReopen")
Expand All @@ -15,7 +15,7 @@ fun ComposeView.setReopenButton(viewModel: EventDetailsViewModel) {
setViewCompositionStrategy(
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed,
)
MdcTheme {
DHIS2Theme {
val eventDetail by viewModel.eventDetails.collectAsState()
ReopenButton(eventDetail.canReopen) { viewModel.onReopenClick() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.domain.CreateO
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.EventDetailResourcesProvider
import org.hisp.dhis.android.core.period.PeriodType

@Suppress("UNCHECKED_CAST")
class EventDetailsViewModelFactory(
private val configureEventDetails: ConfigureEventDetails,
private val configureEventReportDate: ConfigureEventReportDate,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/usescases/login/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.databinding.DataBindingUtil
import com.google.android.material.composethemeadapter.MdcTheme
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
Expand Down Expand Up @@ -64,6 +63,7 @@ import org.dhis2.utils.analytics.FORGOT_CODE
import org.dhis2.utils.session.PIN_DIALOG_TAG
import org.dhis2.utils.session.PinDialog
import org.hisp.dhis.android.core.user.openid.IntentWithRequestCode
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import timber.log.Timber
import java.io.BufferedReader
import java.io.File
Expand Down Expand Up @@ -202,7 +202,7 @@ class LoginActivity : ActivityGlobalAbstract(), LoginContracts.View {

binding.topbar.setContent {
val displayMoreActions by presenter.displayMoreActions().observeAsState(true)
MdcTheme {
DHIS2Theme {
LoginTopBar(
version = buildInfo(),
displayMoreActions = displayMoreActions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.livedata.observeAsState
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.bindings.app
import org.dhis2.commons.resources.ColorUtils
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.usescases.general.ActivityGlobalAbstract
import org.dhis2.usescases.login.LoginActivity
import org.dhis2.usescases.login.accounts.ui.AccountsScreen
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import timber.log.Timber
import java.io.File
import java.io.FileOutputStream
Expand Down Expand Up @@ -63,7 +63,7 @@ class AccountsActivity : ActivityGlobalAbstract() {
app().serverComponent()?.plus(AccountsModule())?.inject(this)

setContent {
MdcTheme {
DHIS2Theme {
val accounts = viewModel.accounts.observeAsState(listOf())
AccountsScreen(
accounts = accounts.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.dhis2.usescases.login.accounts
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

@Suppress("UNCHECKED_CAST")
class AccountsViewModelFactory(
val repository: AccountRepository,
) : ViewModelProvider.Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -45,60 +44,58 @@ fun AccountsScreen(
onAddAccountClicked: () -> Unit,
onImportDatabase: () -> Unit,
) {
MaterialTheme {
Column(
Modifier
.fillMaxWidth()
.background(colorResource(id = R.color.colorPrimary)),
) {
LoginTopBar(
version = LocalContext.current.buildInfo(),
onImportDatabase = onImportDatabase,
)

Column(
Modifier
.fillMaxWidth()
.background(colorResource(id = R.color.colorPrimary)),
verticalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxHeight()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp))
.background(Color.White),
) {
LoginTopBar(
version = LocalContext.current.buildInfo(),
onImportDatabase = onImportDatabase,
)

Column(
verticalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxHeight()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp))
.background(Color.White),
LazyColumn(
Modifier
.weight(1f)
.padding(top = 16.dp),
) {
LazyColumn(
Modifier
.weight(1f)
.padding(top = 16.dp),
) {
items(accounts) {
AccountItem(
Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
it,
onAccountClicked,
)
}
items(accounts) {
AccountItem(
Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
it,
onAccountClicked,
)
}
Column(Modifier.padding(16.dp)) {
Button(
modifier = Modifier
.fillMaxWidth(),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(id = R.color.colorPrimary),
contentColor = Color.White,
),
elevation = ButtonDefaults.elevation(
defaultElevation = 5.dp,
pressedElevation = 15.dp,
disabledElevation = 0.dp,
}
Column(Modifier.padding(16.dp)) {
Button(
modifier = Modifier
.fillMaxWidth(),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(id = R.color.colorPrimary),
contentColor = Color.White,
),
elevation = ButtonDefaults.elevation(
defaultElevation = 5.dp,
pressedElevation = 15.dp,
disabledElevation = 0.dp,
),
onClick = { onAddAccountClicked() },
) {
Text(
text = stringResource(R.string.add_accout).toUpperCase(Locale.current),
fontFamily = FontFamily(
Font(R.font.rubik_regular, FontWeight.Medium),
),
onClick = { onAddAccountClicked() },
) {
Text(
text = stringResource(R.string.add_accout).toUpperCase(Locale.current),
fontFamily = FontFamily(
Font(R.font.rubik_regular, FontWeight.Medium),
),
)
}
)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/dhis2/usescases/login/ui/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -52,7 +52,7 @@ fun LoginTopBar(
modifier = Modifier
.fillMaxWidth()
.height(80.dp)
.background(MaterialTheme.colors.primary),
.background(MaterialTheme.colorScheme.primary),
) {
val (logoLayout, versionLabel) = createRefs()

Expand Down Expand Up @@ -90,7 +90,7 @@ fun LoginTopBar(
Icon(
imageVector = Icons.Filled.MoreVert,
contentDescription = "More options",
tint = MaterialTheme.colors.onPrimary,
tint = MaterialTheme.colorScheme.onPrimary,
)
}

Expand All @@ -110,7 +110,7 @@ fun LoginTopBar(
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_import_db),
contentDescription = "Import database",
tint = MaterialTheme.colors.primary,
tint = MaterialTheme.colorScheme.primary,
)

Text(
Expand Down
Loading
Loading