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
feat: added a guide for Logic Analyzer Instrument using Alert Dialog Box #944
Conversation
dontShowAgain = (CheckBox) dialogView.findViewById(R.id.toggle_show_again); | ||
final TextView tv1 = (TextView) dialogView.findViewById(R.id.custom_dialog_text); | ||
final TextView tv2 = (TextView) dialogView.findViewById(R.id.description_text); | ||
final ImageView iv = (ImageView) dialogView.findViewById(R.id.custom_dialog_schematic); |
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.
Good Java practice is to use meaningful variable names instead of these type of naming
iv.setImageResource(iconID); | ||
tv2.setText(desc); | ||
|
||
final android.support.v7.app.AlertDialog dialog = builder.create(); |
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.
You can import these in the class imports section
@SuppressLint("ResourceType") | ||
public void howToConnectDialog(String title, String intro, int iconID, String desc) { | ||
try { | ||
final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(getContext()); |
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.
You can import these in the class imports section
View dialogView = inflater.inflate(R.layout.custom_dialog_box, null); | ||
|
||
final SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0); | ||
String skipMessage = settings.getString("skipMessage", "NOT checked"); |
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.
Make "NOT" to "Not"
View dialogView = inflater.inflate(R.layout.custom_dialog_box, null); | ||
|
||
final SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0); | ||
String skipMessage = settings.getString("skipMessage", "NOT checked"); |
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.
It's trivial to use a boolean in cases like this rather than a string matching.
SharedPreferences.Editor editor = settings.edit(); | ||
editor.putString("skipMessage", checkBoxResult); | ||
editor.apply(); | ||
|
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.
The whole file needs a reformat.
@CloudyPadmal All requested changes are done. |
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.
You're still using a string comparison to check if the check box is ticked or not. Make it a Boolean variable. Boolean variables hold only two states, true or false. If the check box is ticked, make it true. If not make it false. It's common practice.
@CloudyPadmal Changes done. I thought strings would be OK so I kept them. But now I changed them to Boolean value |
Boolean checkBoxResult = false; | ||
if (dontShowAgain.isChecked()) | ||
checkBoxResult = true; | ||
SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0); |
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.
Why is it this SharedPreference initialized again? You can use the previously initialized variable can't you?
@Vikum94 I made the changes and the duplication was due to using final keyword. |
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.
Good work! Thank you for the PR! 👍
Fixes #943
Changes: Added documentation including schematic for Logic Analyzer using Alert Dialog Box which won't pop up when Don't show again is checked
Screenshots for the change:
logic_analyzer.zip
APK for testing:
app-debug.zip