-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Change log server URL locally #2852
base: commcare_2.54
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.commcare.preferences; | ||
|
||
import static org.commcare.preferences.HiddenPreferences.ENABLE_CERTIFICATE_TRANSPARENCY; | ||
import static org.commcare.preferences.ServerUrls.PREFS_LOG_POST_URL_KEY; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import android.content.Intent; | ||
|
@@ -85,6 +86,7 @@ public class DeveloperPreferences extends CommCarePreferenceFragment { | |
WHITELISTED_DEVELOPER_PREF_KEYS.add(AUTO_PURGE_ENABLED); | ||
WHITELISTED_DEVELOPER_PREF_KEYS.add(ALTERNATE_QUESTION_LAYOUT_ENABLED); | ||
WHITELISTED_DEVELOPER_PREF_KEYS.add(ENABLE_CERTIFICATE_TRANSPARENCY); | ||
WHITELISTED_DEVELOPER_PREF_KEYS.add(PREFS_LOG_POST_URL_KEY); | ||
} | ||
|
||
/** | ||
|
@@ -120,6 +122,19 @@ protected int getPreferencesResource() { | |
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { | ||
super.onCreatePreferences(savedInstanceState, rootKey); | ||
setHasOptionsMenu(true); | ||
EditTextPreference editTextPreference = (EditTextPreference)findPreference(PREFS_LOG_POST_URL_KEY); | ||
if (editTextPreference != null) { | ||
editTextPreference.setOnPreferenceChangeListener((preference, newValue) -> { | ||
if (newValue == null || newValue.toString().trim().isEmpty() | ||
|| newValue.equals(getString(R.string.logs_server_url_protocol))) { | ||
SharedPreferences appPreferences = CommCareApplication.instance().getCurrentApp() | ||
.getAppPreferences(); | ||
appPreferences.edit().remove(PREFS_LOG_POST_URL_KEY).apply(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. think we should be defaulting to the url from app profile xml instead of completely removing it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is related to the notion of what is the default URL for the logs submission, right now it seems to be the form submission URL There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah we should be defaulting it to form submission url instead of removing it completely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shubham1g5 that would be changing the way this preference is currently used and create redundancy. Right now, it seems that we only set the preference when the logs URL is different from the form submissions URL. Defaulting to the submissions URL and to keep consistency, would require setting it during app installation as well, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shubham1g5 that was my first impulse as well, but I think it's actually too dangerous to set this redundantly for two reasons. 1 - It introduces a new parity requirement. If we changed the submission URL for form submissions on HQ's end, we'd now need to also change the log URL, but we can't really do that with HQ settings because it'll blow away the config for anyone who's added the custom setting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Makes sense, I didn't realise we don't do it already.
I am not sure I understand it. My thought was to do this as a one time action at app install time -
No strong thoughts here though overall, though with the current change behaviour it's probably better to rename the field from |
||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if user ever sees this
defaultValue
as an app should always have thelog_receiver_url
populated ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they see it when
log_receiver_url
is not set, by default the logs URL is the Form Submission log