-
Notifications
You must be signed in to change notification settings - Fork 0
Review Task 1 #1
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
base: master
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 |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| package pl.fracz.mcr.source; | ||
|
|
||
| /* | ||
| 2013-10-23, fracz, first implementation | ||
| 2013-10-30, fracz, added syntax highlighting | ||
| 2014-02-26, fracz, added ability to add voice comment | ||
| */ | ||
|
|
||
| import android.annotation.SuppressLint; | ||
| import android.content.Context; | ||
| import android.graphics.Color; | ||
| import android.graphics.Typeface; | ||
| import android.text.Html; | ||
| import android.widget.LinearLayout; | ||
| import android.widget.TextView; | ||
| import pl.fracz.mcr.comment.AbstractComment; | ||
| import pl.fracz.mcr.comment.Comment; | ||
| import pl.fracz.mcr.comment.CommentNotAddedException; | ||
|
|
||
| import java.io.File; | ||
| import java.io.Serializable; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * View that represents one line of code. | ||
|
Owner
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. Bezużyteczny komentarz |
||
| */ | ||
| @SuppressLint("ViewConstructor") | ||
|
Owner
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. Złe zastosowanie klasy |
||
| public class Line extends LinearLayout implements Serializable { | ||
| private static final long serialVersionUID = 3076583280108678995L; | ||
|
Owner
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. Niepotrzebny typ prymitywny |
||
| private static final int TWO = 2; | ||
|
Owner
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. Niepotrzebna stała |
||
|
|
||
| private final int _lineNumber; | ||
|
|
||
| private final String _lineOfCode; | ||
|
|
||
| // holds the line number | ||
|
Owner
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. Bezużyteczny komentarz |
||
| private TextView lineNumberView; | ||
|
|
||
| private TextView lineContent; | ||
|
|
||
| private SourceFile sourceFile; | ||
|
|
||
| private List<Comment> comments; | ||
|
|
||
| public Line(Context context, SourceFile sourceFile, int lineNumber, | ||
| String lineOfCode, boolean syntaxColor) { | ||
| super(context); | ||
| this.sourceFile = sourceFile; | ||
| this._lineNumber = lineNumber; | ||
| this._lineOfCode = lineOfCode; | ||
| setOrientation(LinearLayout.HORIZONTAL); | ||
|
|
||
| lineNumberView = new TextView(getContext()); | ||
| lineNumberView.setText(String.format("%d.", lineNumber);); | ||
|
Owner
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. Brak kompilacji |
||
| lineNumberView.setSingleLine(); | ||
| lineNumberView.setWidth(30); | ||
| addView(lineNumberView); | ||
|
|
||
| TextView lineContent = new TextView(getContext()); | ||
| addLineContent(syntaxColor); | ||
| } | ||
|
|
||
| public int get() { | ||
|
Owner
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. Zła nazwa |
||
| return _lineNumber; | ||
| } | ||
|
|
||
| /** | ||
| * Adds a text comment. | ||
|
Owner
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. Bezsesowny komentarz |
||
| * | ||
| * @param comment | ||
| * @throws CommentNotAddedException | ||
| */ | ||
| public void addTextComment(String comment) throws CommentNotAddedException { | ||
| Comment textComment = new Comment(AbstractComment.Type.TEXT, this); | ||
| textComment.setText(comment); | ||
| comments.add(textComment); | ||
| if (comments.size() > 0) { | ||
|
Owner
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. Łamie srp |
||
| lineNumberView.setBackgroundColor(Color.parseColor("#008000")); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Adds a voice comment. | ||
| * | ||
| * @param recordedFile | ||
| * @throws CommentNotAddedException | ||
| */ | ||
| public void createVoiceComment(File recodedFile) throws CommentNotAddedException { | ||
| Comment voiceComment = new Comment(AbstractComment.Type.VOICE, this); | ||
| voiceComment.setFile(recodedFile); | ||
| comments.add(voiceComment); | ||
| if (comments.size() > 0) { | ||
|
Owner
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. Łamie srp |
||
| lineNumberView.setBackgroundColor(Color.parseColor("#008000")); | ||
| } | ||
| } | ||
|
|
||
|
Owner
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. Zakomentowany, niewykorzystany kod (pewnie niedokończony albo pozostałość z refaktoryzacji) |
||
| // public void addVideoComment(File videoFile) throws CommentNotAddedException { | ||
| // } | ||
|
|
||
| private void addLineContent(boolean syntaxColor){ | ||
|
Owner
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. Parametr typu boolean |
||
| if (!syntaxColor || !SyntaxHighlighter.canBeHighlighted(syntaxColor)) | ||
|
Owner
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. Można uprościć wyrażenie logiczne |
||
| lineContent.setText(Html.fromHtml(lineOfCode)); | ||
| else | ||
|
Owner
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. Godline |
||
| lineContent.setText(SyntaxHighlighter.highlight(Html.fromHtml(lineOfCode))); | ||
| lineContent.setTypeface(Typeface.MONOSPACE); | ||
| addView(lineContent); | ||
| } | ||
|
|
||
| public List<Comment> getComments(){ | ||
| return this.comments; | ||
| } | ||
|
|
||
| public boolean hasConversation() { | ||
| sourceFile.markConversation(this); | ||
| return getComments().size() > TWO; | ||
| } | ||
| } | ||
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.
Historię można przejrzeć na gicie, komentarze śmiecą