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

AC-745 fixed the transition error upon language change #741

Merged
merged 1 commit into from
May 18, 2020
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 @@ -30,6 +30,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
Expand Down Expand Up @@ -163,6 +164,14 @@ private void setSyncButtonState(boolean syncState) {
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == ApplicationConstants.RequestCodes.START_SETTINGS_REQ_CODE) {
recreate();
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
Expand All @@ -171,7 +180,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.actionSettings:
startActivity(new Intent(this, SettingsActivity.class));
startActivityForResult(new Intent(this, SettingsActivity.class), ApplicationConstants.RequestCodes.START_SETTINGS_REQ_CODE);
return true;
case R.id.actionContact:
startActivity(new Intent(this, ContactUsActivity.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
import android.view.Menu;
import android.view.MenuItem;

import androidx.appcompat.app.ActionBar;

import org.openmrs.mobile.R;
import org.openmrs.mobile.activities.ACBaseActivity;

import androidx.appcompat.app.ActionBar;

public class SettingsActivity extends ACBaseActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -38,18 +36,17 @@ protected void onCreate(Bundle savedInstanceState) {

// Create fragment
SettingsFragment settingsFragment =
(SettingsFragment) getSupportFragmentManager().findFragmentById(R.id.settingsContentFrame);
(SettingsFragment) getSupportFragmentManager().findFragmentById(R.id.settingsContentFrame);
if (settingsFragment == null) {
settingsFragment = SettingsFragment.newInstance();
}
if (!settingsFragment.isActive()) {
addFragmentToActivity(getSupportFragmentManager(),
settingsFragment, R.id.settingsContentFrame);
settingsFragment, R.id.settingsContentFrame);
}

// Create the presenter
new SettingsPresenter(settingsFragment, mOpenMRSLogger);

}

@Override
Expand All @@ -65,12 +62,17 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
setResult(RESULT_OK, null);
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}


@Override
public void onBackPressed() {
setResult(RESULT_OK, null);
super.onBackPressed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

package org.openmrs.mobile.activities.settings;

import java.util.Objects;

import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -36,9 +34,11 @@
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

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

import org.openmrs.mobile.R;
import org.openmrs.mobile.activities.ACBaseFragment;
import org.openmrs.mobile.activities.community.contact.ContactUsActivity;
Expand All @@ -47,14 +47,13 @@
import org.openmrs.mobile.utilities.ApplicationConstants;
import org.openmrs.mobile.utilities.ToastUtil;

public class SettingsFragment extends ACBaseFragment<SettingsContract.Presenter> implements SettingsContract.View {
import java.util.Objects;

public class SettingsFragment extends ACBaseFragment<SettingsContract.Presenter> implements SettingsContract.View {
private BroadcastReceiver bReceiver;

private TextView conceptsInDbTextView;
private ImageButton downloadConceptsButton;
private Spinner spinner;

private View root;

public static SettingsFragment newInstance() {
Expand Down Expand Up @@ -87,16 +86,17 @@ public void onPause() {
public void onResume() {
super.onResume();
mPresenter.updateConceptsInDBTextView();
LocalBroadcastManager.getInstance(this.getActivity()).registerReceiver(bReceiver, new IntentFilter(ApplicationConstants.BroadcastActions.CONCEPT_DOWNLOAD_BROADCAST_INTENT_ID));
LocalBroadcastManager.getInstance(this.getActivity())
.registerReceiver(bReceiver, new IntentFilter(ApplicationConstants.BroadcastActions.CONCEPT_DOWNLOAD_BROADCAST_INTENT_ID));
}

@Override
public void setConceptsInDbText(String text) {
if (text.equals("0")) {
downloadConceptsButton.setEnabled(true);
ToastUtil.showLongToast(getActivity(),
ToastUtil.ToastType.WARNING,
R.string.settings_no_concepts_toast);
ToastUtil.ToastType.WARNING,
R.string.settings_no_concepts_toast);
} else {
downloadConceptsButton.setEnabled(false);
}
Expand Down Expand Up @@ -179,17 +179,16 @@ public void rateUs() {

// Ignore Playstore backstack, on back press will take us back to our app
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" + ApplicationConstants.PACKAGE_NAME)));
Uri.parse("http://play.google.com/store/apps/details?id=" + ApplicationConstants.PACKAGE_NAME)));
}
});

}

@Override
Expand Down Expand Up @@ -228,5 +227,4 @@ public void onNothingSelected(AdapterView<?> parent) {
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public abstract static class EncounterTypes {
public abstract static class RequestCodes{
public static final int ADD_PROVIDER_REQ_CODE = 100;
public static final int EDIT_PROVIDER_REQ_CODE = 101;
public static final int START_SETTINGS_REQ_CODE = 102;
}

public abstract static class OpenMRSThemes{
Expand Down