Skip to content
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
10 changes: 5 additions & 5 deletions openmrs-client/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
android:name=".activities.visitdashboard.VisitDashboardActivity"
android:label="@string/visit_dashboard_label"
android:launchMode="singleTop"
android:theme="@style/AppTheme">
android:theme="@style/AppThemeOrig">

<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
Expand All @@ -143,7 +143,7 @@
android:label="@string/action_form_entry"
android:launchMode="singleTop"
android:parentActivityName=".activities.formentrypatientlist.FormEntryPatientListActivity"
android:theme="@style/AppTheme">
android:theme="@style/AppThemeOrig">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.formentrypatientlist.FormEntryPatientListActivity" />
Expand All @@ -153,7 +153,7 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/action_form_entry"
android:parentActivityName=".activities.dashboard.DashboardActivity"
android:theme="@style/AppTheme">
android:theme="@style/AppThemeOrig">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.dashboard.DashboardActivity" />
Expand All @@ -163,7 +163,7 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/action_register_patient"
android:parentActivityName=".activities.addeditpatient.AddEditPatientActivity"
android:theme="@style/AppTheme">
android:theme="@style/AppThemeOrig">

<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
Expand All @@ -188,7 +188,7 @@
android:label="@string/title_activity_form_create"
android:parentActivityName=".activities.formlist.FormListActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/AppTheme">
android:theme="@style/AppThemeOrig">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.openmrs.mobile.activities.formlist.FormListActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand All @@ -50,6 +51,7 @@
import org.openmrs.mobile.utilities.ApplicationConstants;
import org.openmrs.mobile.utilities.ForceClose;
import org.openmrs.mobile.utilities.NetworkUtils;
import org.openmrs.mobile.utilities.ThemeUtils;
import org.openmrs.mobile.utilities.ToastUtil;

import java.io.File;
Expand Down Expand Up @@ -79,6 +81,9 @@ public abstract class ACBaseActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.setDefaultUncaughtExceptionHandler(new ForceClose(this));

setupTheme();

mFragmentManager = getSupportFragmentManager();
mAuthorizationManager = new AuthorizationManager();
locationList = new ArrayList<>();
Expand Down Expand Up @@ -383,4 +388,11 @@ public void showAppCrashDialog(String error) {
alertDialog.show();
}

public void setupTheme(){
if(ThemeUtils.isDarkModeActivated()){
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else{
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;

import org.openmrs.mobile.R;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void onBindViewHolder(@NonNull VisitViewHolder visitViewHolder, final int
visitViewHolder.mBirthDate.setText(" ");
}

visitViewHolder.mRelativeLayout.setOnClickListener(view -> {
visitViewHolder.mLinearLayout.setOnClickListener(view -> {
Intent intent = new Intent(mContext, VisitDashboardActivity.class);
intent.putExtra(ApplicationConstants.BundleKeys.VISIT_ID, mVisits.get(adapterPos).getId());
mContext.startActivity(intent);
Expand All @@ -100,11 +101,11 @@ class VisitViewHolder extends RecyclerView.ViewHolder {
private TextView mGender;
private TextView mBirthDate;
private TextView mVisitPlace;
private LinearLayout mRelativeLayout;
private LinearLayout mLinearLayout;

public VisitViewHolder(View itemView) {
super(itemView);
mRelativeLayout = (LinearLayout) itemView;
mLinearLayout = itemView.findViewById(R.id.findVisitContainerLL);
mIdentifier = itemView.findViewById(R.id.findVisitsIdentifier);
mDisplayName = itemView.findViewById(R.id.findVisitsDisplayName);
mVisitPlace = itemView.findViewById(R.id.findVisitsPlace);
Expand All @@ -113,7 +114,7 @@ public VisitViewHolder(View itemView) {
}

public void clearAnimation() {
mRelativeLayout.clearAnimation();
mLinearLayout.clearAnimation();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_patient_info);

Toolbar toolbar = findViewById(R.id.toolbar);

if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

// Create fragment
addEditPatientFragment =
(AddEditPatientFragment) getSupportFragmentManager().findFragmentById(R.id.patientInfoContentFrame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private void addSingleChoiceItemsListView(List<String>locationList) {
LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_single_choice_list_view, null);
locationListView = field.findViewById(R.id.singleChoiceListView);
locationListView.setAdapter(new ArrayAdapter<>(getActivity(),
android.R.layout.simple_list_item_single_choice, locationList));
R.layout.row_single_checked_layout, locationList));
locationListView.setItemChecked(locationList.indexOf(mOpenMRS.getLocation()),true);
mFieldsLayout.addView(field);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_form_display);

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

Bundle bundle = getIntent().getExtras();
String valuereference = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public class FormEntryPatientListActivity extends ACBaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_form_entry_patient_list);
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

// Create fragment
FormEntryPatientListFragment formEntryPatientListFragment =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;

import org.openmrs.mobile.R;
Expand Down Expand Up @@ -99,7 +100,7 @@ public int getItemCount() {
}

class PatientViewHolder extends RecyclerView.ViewHolder {
private LinearLayout mRowLayout;
private CardView mRowLayout;
private TextView mIdentifier;
private TextView mDisplayName;
private TextView mGender;
Expand All @@ -110,7 +111,7 @@ class PatientViewHolder extends RecyclerView.ViewHolder {
public PatientViewHolder(View itemView) {
super(itemView);
mVisitStatus = itemView.findViewById(R.id.visitStatusLabel);
mRowLayout = (LinearLayout) itemView;
mRowLayout = (CardView) itemView;
mIdentifier = itemView.findViewById(R.id.syncedPatientIdentifier);
mDisplayName = itemView.findViewById(R.id.syncedPatientDisplayName);
mGender = itemView.findViewById(R.id.syncedPatientGender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_form_list);

Toolbar toolbar = findViewById(R.id.toolbar);

if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

// Create fragment
FormListFragment formListFragment =
(FormListFragment) getSupportFragmentManager().findFragmentById(R.id.formListContentFrame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.openmrs.mobile.activities.lastviewedpatients;

import android.app.Activity;
import android.content.res.ColorStateList;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -28,6 +29,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;

import org.openmrs.mobile.R;
Expand Down Expand Up @@ -167,23 +169,26 @@ public int getItemCount() {
}

class PatientViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener {
private LinearLayout mRowLayout;
private CardView mRowLayout;
private TextView mIdentifier;
private TextView mDisplayName;
private TextView mGender;
private TextView mBirthDate;
private CheckBox mAvailableOfflineCheckbox;
private ColorStateList cardBackgroundColor;

public PatientViewHolder(View itemView) {
super(itemView);
mRowLayout = (LinearLayout) itemView;
mRowLayout = (CardView) itemView;
mIdentifier = itemView.findViewById(R.id.lastViewedPatientIdentifier);
mDisplayName = itemView.findViewById(R.id.lastViewedPatientDisplayName);
mGender = itemView.findViewById(R.id.lastViewedPatientGender);
mBirthDate = itemView.findViewById(R.id.lastViewedPatientBirthDate);
mAvailableOfflineCheckbox = itemView.findViewById(R.id.offlineCheckbox);
mRowLayout.setOnClickListener(this);
mRowLayout.setOnLongClickListener(this);

cardBackgroundColor = mRowLayout.getCardBackgroundColor();
}

public void clearAnimation() {
Expand All @@ -203,22 +208,26 @@ private void setSelected(boolean select) {
toggleDownloadButton();
selectedPatientPositions.add(getAdapterPosition());
this.mRowLayout.setSelected(true);
mRowLayout.setCardBackgroundColor(mContext.getResources().getColor(R.color.selected_card));
} else {
removeIdFromSelectedIds(getAdapterPosition());
this.mRowLayout.setSelected(false);
mRowLayout.setCardBackgroundColor(cardBackgroundColor);
}
}

@Override
public boolean onLongClick(View v) {
if (v.isSelected()) {
setSelected(false);
mRowLayout.setCardBackgroundColor(cardBackgroundColor);
} else {
if (!isLongClicked) {
startActionMode();
}
isLongClicked = true;
setSelected(true);
mRowLayout.setCardBackgroundColor(mContext.getResources().getColor(R.color.selected_card));
notifyDataSetChanged();
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;

import org.openmrs.mobile.R;
Expand Down Expand Up @@ -73,7 +74,7 @@ public void onBindViewHolder(@NonNull VisitViewHolder visitViewHolder, final int
visitViewHolder.mVisitPlace.setText(mContext.getString(R.string.visit_in, visit.getLocation().getDisplay()));
}

visitViewHolder.mRelativeLayout.setOnClickListener(view -> mContext.goToVisitDashboard(mVisits.get(adapterPos).getId()));
visitViewHolder.mCardView.setOnClickListener(view -> mContext.goToVisitDashboard(mVisits.get(adapterPos).getId()));
}

@Override
Expand All @@ -91,19 +92,19 @@ class VisitViewHolder extends RecyclerView.ViewHolder {
private TextView mVisitStart;
private TextView mVisitEnd;
private TextView mVisitStatus;
private RelativeLayout mRelativeLayout;
private CardView mCardView;

public VisitViewHolder(View itemView) {
super(itemView);
mRelativeLayout = (RelativeLayout) itemView;
mCardView = (CardView) itemView;
mVisitStart = itemView.findViewById(R.id.patientVisitStartDate);
mVisitEnd = itemView.findViewById(R.id.patientVisitEndDate);
mVisitPlace = itemView.findViewById(R.id.patientVisitPlace);
mVisitStatus = itemView.findViewById(R.id.visitStatusLabel);
}

public void clearAnimation() {
mRelativeLayout.clearAnimation();
mCardView.clearAnimation();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ interface View extends BaseView<Presenter> {

void rateUs();

void setDarkMode();
}

interface Presenter extends BasePresenterContract {

void logException(String exception);

void updateConceptsInDBTextView();

boolean isDarkModeActivated();

void setDarkMode(boolean darkMode);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Objects;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

public class SettingsFragment extends ACBaseFragment<SettingsContract.Presenter> implements SettingsContract.View {
Expand All @@ -49,6 +50,7 @@ public class SettingsFragment extends ACBaseFragment<SettingsContract.Presenter>

private TextView conceptsInDbTextView;
private ImageButton downloadConceptsButton;
private SwitchCompat darkModeSwitch;

private View root;

Expand Down Expand Up @@ -179,6 +181,17 @@ public void rateUs() {

}

@Override
public void setDarkMode() {
darkModeSwitch = root.findViewById(R.id.frag_settings_dark_mode_switch);
darkModeSwitch.setChecked(mPresenter.isDarkModeActivated());

darkModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
mPresenter.setDarkMode(isChecked);
getActivity().recreate();
});
}

public static SettingsFragment newInstance() {
return new SettingsFragment();
}
Expand Down
Loading