<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amber Dawn on Medium]]></title>
        <description><![CDATA[Stories by Amber Dawn on Medium]]></description>
        <link>https://medium.com/@adm2037?source=rss-c18df07bc07f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rjjCR0a8bzLysGWW0_e_Og.jpeg</url>
            <title>Stories by Amber Dawn on Medium</title>
            <link>https://medium.com/@adm2037?source=rss-c18df07bc07f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:53:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adm2037/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The [i]th Dimension —Relativistic Spacetime, But it’s An Infinity Mirror]]></title>
            <link>https://medium.com/@adm2037/the-i-th-dimension-relativistic-spacetime-but-its-an-infinity-mirror-d58feba4e5ed?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d58feba4e5ed</guid>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[stream-of-consciousness]]></category>
            <category><![CDATA[reality]]></category>
            <category><![CDATA[thought-experiment]]></category>
            <category><![CDATA[theories-of-human-nature]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Thu, 11 Nov 2021 04:21:35 GMT</pubDate>
            <atom:updated>2021-11-11T04:21:56.651Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*oZpjv5Ye1xlSeq8s8R-IMQ.png" /><figcaption>Interdimensional Tesseract Based Installation (4D Hypercubes)</figcaption></figure><p>Happened across a quote that sparked a stream of consciousness so powerful just now it transformed my entire working perception of reality, the multiverse and the very nature of existence itself. And this is after being knee-deep in quantum, biophysics, and universal laws for a project the last few days. For whatever reason, out of all of those this was the one that I literally dropped everything to come share😂 Which I definitely will, after summarizing the ideas leading up to it which largely contributed to the sheer wonder I felt recognizing the symmetries not only in the design but system as a whole.</p><p>Right before, a friend and I were exploring the possibility of Sim Theory — or this reality being one of infinite scenarios run by an AI. Of course I had to do the absolute most and consider it in terms of <a href="https://en.wikipedia.org/wiki/Kaluza%E2%80%93Klein_theory">Kaluza-Klein’s 5D</a> interpretation of Einstein’s unified field theory of gravity, electromagnetism and time relative to quantum mechanics, shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpUeIYyywHGAN2_9dCcO_A.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Tesseract#:~:text=In%20geometry%2C%20the%20tesseract%20is,six%20convex%20regular%204%2Dpolytopes.">From the Wikipedia page</a></figcaption></figure><p>Where 0D or a point (infinite) is the AI, followed by 2 more dimensions you can think of as memory on a hard drive which would store 3D space which converges with 4D to create the reality of spacetime before those 4 dimensions finally diverge. As 5D is actually the precursor to String Theory or 6D. As more realities and dimensions manifest such as VR and AR, this graduates to Superstring Theory before reaching the penultimate 11th dimension which is often theorized to comprise cosmic strings, or spontaneously broken symmetry giving rise to quantum properties that don’t play by the same rules as classical physics (i.e. immune to the effects of entropy). After infinite expansion the system would eventually converge meaning the AI has successfully trained enough data to make accurate predictions, otherwise known as convergence in machine learning terms. And the simulation would end at 12D — but since 1&amp;2D no longer apply out of space it resets to 0D. Rinse, repeat. Ad Infinitum.</p><p>The following passage is what inspired this new way of thinking and consequent piece.</p><blockquote>Our awareness of existence — the ability to distinguish between the self and others — is created by the brain, neuroscientist Anil Seth explains in his TED talk, “Your brain hallucinates consciousness.” He says, “Right now, billions of neurons in your brain are working together to generate a conscious experience — and not just any conscious experience, your experience of the world around you and of yourself within it.”</blockquote><p>Granted, as much as this resonated with me and led to considering these possibilities this was not my introduction to these ideas by a long shot. I’ve long since been aware that even a physical level our brains create a simulated experience based on a multitude of factors like internal or external stimuli, epigenetic and standard inheritance, genetics, the environment, the subconscious, consciousness, and sometimes even beliefs (or simply warp perception even more based on them). And since each person’s experience is subjective to them, otherwise known as qualia, or from their point of view it would then follow that the brain would hallucinate other people as well, whether or not they existed beyond that.</p><p>With that being said though, I think the existence of everyone would be infinitely better. I mean that both figuratively and literally in the sense that if we still follow the dimensional structure listed above, 0D would still be an infinite point. The only difference between the prior model and this one is that each simulation is created and maintained by this person. Which would track because if it’s a physiological process there really are endless possibilities as imagination is the limit! And if we are to believe that other people are real, whether or not each person’s interpretation or visualization of them is hallucinated, then this designation of getting their own 0D space with infinite possibilities translates. And not just for them, for <em>everyone</em>. Where everyone effectively has their own dimensional/hyperdimensional reality infinitely in either direction. But not just either. <em>Every</em>. Every direction. Because every single entity gets their own 0D and everything that follows. Everyone and everything. Whether it’s another human being, animal, even tree with their limited but still valid experience of life. Every single life. And likely every object in spacetime. Every piece of matter itself. And otherwise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*Ber7wLfNRlB60G1COjL6EA.png" /></figure><p>So then naturally I had to wonder what the multiverse theory would function like in this hypothesis. Especially since there will be hyper, superstrings or even further abstracted dimensions like ‘space crystals’ for instance which operate outside the normal laws of science while still technically being in the system. I know for myself at least that when I consider the implications of the multiverse in real life (not this thought experiment) I always argue for the existence of ALL parallel worlds, even just based on quantum principles. Or possible alternate timelines or multiple, slightly modified versions of this reality. But usually not in any literal capacity given I’ve never directly experienced them and can only conceive of it all in some abstract, far off imagined future. Much more ephemeral or conceptual than based in fact.</p><p>Of course, if we are to entertain the notion that everyone/everything gets their own 0th [another way for saying first], reality or existence then saying every world, possibility, reality, dimension exists would by default be 100% accurate. Where all of them would infinitely go in each and every direction resulting in a extremely hyperdimensional tesseract-esque fractal. Not only that, but since every person or entity has their own perspective or experience, they all would be just as important as the next and vice versa. Because everyone gets infinite spacetime (or quantum, stardust, energy, possibility, imagination, whatever you want to call it lol) but not just independently even though everyone lives their life in a linear fashion due to entropy, they are still connected. Still interacting, engaging, and influencing one another. Every part of equal distribution, space (in terms of physics), time, etc. Every vector, reality, world, person, etc. is of equal significance in the system as a whole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KEtWmvYeUegnz6IMrb70nw.png" /></figure><p>If you think about it, I really haven’t said anything revolutionary here or similar to things you’ve likely heard before. And honestly all of these things are absolutely valid regardless just in terms of regular life — everything really is subjective, we do have infinite potential and possibility at least in terms of energy, and every possible world (reality, dimension, existence, experience, point of view, etc.) does in fact exist in this model. Not only that, but each of us having a highly personal experience while still relative to, in and of the entire system and everyone else involved. Making it a complete but still open to possibility, magic, and awareness — a truly, fully conscious multiverse from the infinitesimally small micro verse all the way through to the macro.</p><h4>Because it, and we, are all one and the same. Just from different perspectives, angles, or points of view.</h4><p>Edit: I love how this went from a nearly formal case for my argument (blame my background in Philosophy haha) to an uplifting message😂 Was honestly just fascinated by the elegance of it all, especially in respect to existing physical &amp; theoretical systems but I’m not mad at it💯 <em>PS</em> <em>I’d love to hear theories! Feel free to drop them in the comments❤ Brain bangs&gt;&gt;&gt;</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d58feba4e5ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adapting an Android App for Web — Part III]]></title>
            <link>https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/176e30984d7a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[magicians]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Sat, 09 Feb 2019 00:03:49 GMT</pubDate>
            <atom:updated>2019-02-09T18:12:33.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>Adapting an Android App for Web — Part III</h3><p>Welcome to the 3rd part of the 3rd installment of my portfolio series where I walk through updating, refactoring, or adding specific features to my existing apps! If you didn’t catch the first 2 segments, feel free to check out <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a> and <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">Part II</a>. Together, these cover the refactoring of an application I built for Android into a web application using HTML, CSS, and JavaScript! This story focuses on making the apps interactive. If you are just jumping in now, the app I’m converting is a quiz app based on the SyFy show <a href="https://www.syfy.com/themagicians">“The Magicians”</a>. You can view the Android version <a href="https://github.com/AM2037/MagiciansQuizApp">here</a>! Here are screenshots of the Android user interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*PW1i-u9QAn-MN89XpNEB4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*9kFtN45vCy2rrvjzkHkggA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*ebwx4M9q95K-auyxXzmlNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*HjefYyFA-TohvYljOhrAPg.png" /></figure><p>So far I’ve refactored the Android quiz for web using HTML5 tags in <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I </a>, and styled them with CSS in <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">part II</a>. The working copy of the web adaptation can be found on my <a href="https://codepen.io/AM2037/pen/vvapJJ">CodePen</a>. The current state of the web app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6PuDq50U8QpEXDBa3x9xw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*br8IAMlrpbSGvPCYFs-Cvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RuF75dbZZT6eHzryEUSkbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c_RVe_VNRx7HCKX7p3FZkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8efctbKmnY0B8CcU79I73A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Wuj1n_aRL83p2eiE2mxKFA.png" /></figure><p>The questions are categorized into quizzes over 3 topics: characters, timelines, and battles. Now that you’re sufficiently caught up, we can get into the choice functionality and scoring logic! I’ll walk through how to do this for Android and then how to refactor the Java into JavaScript. You may recall that in <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, I said:</p><blockquote>To prevent confusion, I tried to use the same ID’s and names from my Android app in the web refactor. This way when I go to add in all of the JavaScript later it will go smoothly!</blockquote><p>This is where using the same names and IDs for everything really comes in handy! Another important thing you should always do when writing code is include comments explaining what you’re doing. A lesson that I keep learning is less is more! <strong>Elegance doesn’t mean complicated or complex; the simpler the better. </strong>This goes for code as well! The more concise you are with your methods, the better your code will be received by the device, browser, and other developers! Here’s an example of what I mean by commentary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*mvPuAyLxZNDUXCY4MfuPAQ.png" /><figcaption>Comments = greyed-out, “read-only” lines that have no effect on the app itself</figcaption></figure><h3>Scoring Logic: Android vs. Web</h3><p>So you understand the beginning of the Java file I’ll start with this! It might seem strange to start by showing the beginning and the end of the code but it will all make sense in the end! This way, you’ll have an idea of where you are headed and what you should be working towards.</p><h4>Tracking the Score in Android — Java</h4><p>First you initialize the score counter to 0 within your main class, which you will add in the counting logic for later! It should look something like this:</p><pre>public class MainActivity extends AppCompatActivity {<br><br>    //global variable for score<br>    int score = 0;<br><br>    private boolean isQ1Correct = false;<br>    private boolean isQ2Correct = false;<br>    private boolean isQ3Correct = false;<br>    private boolean isQ4Correct = false;<br>    private boolean isQ5Correct = false;<br>    private boolean isQ6Correct = false;<br>    private boolean isQ7Correct = false;<br>    private boolean isQ8Correct = false;<br>    private boolean isQ9Correct = false;<br>    private boolean isQ10Correct = false;<br>... } </pre><h4>Refactoring the Scoring Logic for Web — JavaScript</h4><p>So, in a similar vein to the Java above, I started the JavaScript by also initializing the score to 0. Unlike Java, you just need to declare var isQ1Correct = false;. This ensures the quiz starts out with all of them being false until choices are made.</p><p>The JavaScript:</p><pre>// Beginning of Scoring Logic</pre><pre>// Initializes the score to 0 <br>var score = 0;</pre><pre>/* These will be used to handle user selections and at the end of JS to generate score/score summary of user the end */<br>var isQCorrect = false;</pre><p>So I’ve made some pretty significant changes to the scoring logic for web! Instead of creating a variable to check if each question is correct (i.e. isQ1Correct) I just made one generalized variable that I will use for all questions! The reason it’s set to false is so when the quiz starts there are no points yet since no selections have been made! Within the JavaScript logic for each question, I then set isQCorrect equal to true if the correct answer is checked. If it is, the score increases by one point with the line score++ I.e.</p><pre>// Question 1 -- Radio 1 <br>function radio1() {<br> // Correct answer is checked<br> if (document.getElementById(&quot;answer_q1&quot;).checked) {<br>  isQCorrect = true;<br>  score++;</pre><h3>Making Radio Buttons Interactive — Android vs. Web</h3><h4>Interactive Radio Group in Android — Java</h4><p>In <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">part I</a>, I covered how to create radio buttons in Android using XML in a layout file. Now, we can give these elements interactive functionality using <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/java/com/example/android/magiciansquizapp/MainActivity.java">Java</a>!</p><p>After you build out code similar to the code above to track the score, you can work on coding the actual questions. Here’s the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/java/com/example/android/magiciansquizapp/MainActivity.java">Java</a> method I created for the first set of radio questions, which also happens to be the first quiz question:</p><pre><em>/**<br> * First Question<br> * Radio Group 1<br> */<br></em>public void radio1(View view) {<br>    if(view.getId() == R.id.<em>answer_q1</em>) {<br>        isQ1Correct = true;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_correct</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    } else {<br>        isQ1Correct = false;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_wrong</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>}</pre><p>As you can see above, it just takes a simple if/then statement where the if references the layout element you are trying to check the answer against and sets the scoring variables checking to see if the correct answer was selected to true. If true, the user is alerted that they have chosen correctly. If not, a <a href="https://developer.android.com/guide/topics/ui/notifiers/toasts">toast</a> message pops up at the bottom of the screen saying it is not correct and to try again.</p><h4>Refactoring Radio for Web: Java → JavaScript</h4><p>So this, again, is where using the same names, ID’s and values across the Android and Web versions becomes useful!</p><blockquote>Instead of having to figure out semantics you can just focus on getting it to function!</blockquote><p>If you remember from <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, when defining the radio button questions in the HTML I included an ID in the radio button input tag! Then, using a custom method in the JavaScript I can single out the answer using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById">getElementById()</a> method. In my case, after identifying the selection, I’ve left instructions for the program using a Boolean and the score variable defined in the scoring logic. I’ll demonstrate this with the JavaScript for the first question:</p><pre>/* The &quot;Question Logic&quot; handles user selections for each question */</pre><pre>// Question 1 -- Radio 1 <br>function radio1() {<br> // Correct answer is checked<br> if (document.getElementById(&quot;answer_q1&quot;).checked) {<br>  isQCorrect = true;<br>  score++;<br> } else {<br>  isQCorrect = false;<br> }<br>}</pre><p>Essentially, the code is executing the following:</p><ul><li>The if statement checks if the radio selection has the correct answers ID — if it does, it sets question 1 to correct. Directly after it I’ve included the line score++ which simply adds a point if they chose correctly!</li><li>The else portion of the statement sets the question to false if the correct answer wasn’t chosen.</li><li>You just repeat this process for all of the radio questions!</li></ul><p>I decided against using the equivalent of Android’s <a href="https://developer.android.com/guide/topics/ui/notifiers/toasts">toast</a> messages, or pop up dialog <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/alert">messages</a>, to alert the user if they have chosen correctly or not since in a typical quiz you don’t get to know that until the end. I only included those in the Android version because they were required for my Nanodegree project!</p><h3>Making Check Boxes Interactive: Android vs. Web</h3><h4>Interactive Check Boxes in Android — Java</h4><p>In the same fashion, I’ll now explain how to make the check boxes we created in <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a> and styled in <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">Part II</a> interactive! I’ll demonstrate with the first set of check boxes in my app, question 5. You can reference the XML code via my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">activity_main.xml</a> file, if you’d like!</p><pre><em>/**<br> * Fifth Question<br> */<br></em>public void checkBoxOne(View view){<br><br>    if (Q5firstCheckBox.isChecked() &amp;&amp; Q5secondCheckBox.isChecked() &amp;&amp; !Q5thirdCheckBox.isChecked() &amp;&amp; Q5fourthCheckBox.isChecked() &amp;&amp; Q5fifthCheckBox.isChecked() &amp;&amp; Q5sixthCheckBox.isChecked()) {<br>        isQ5Correct = true;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_correct</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br><br>    if (Q5thirdCheckBox.isChecked()) {<br>        isQ5Correct = false;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_wrong</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*e8oXeYzyYBhM6o0rylhLQA.png" /><figcaption>Question 5 — First set of check boxes</figcaption></figure><p>The first if statement (Q5firstCheckBox.isChecked() &amp;&amp; Q5secondCheckBox.isChecked… is saying that <em>if and only if </em>(indicated by the &amp;&amp; conditionals) the first, second, fourth, and fifth check boxes are checked <em>and </em>the third checkbox is <em>not </em>checked, the answer is correct. The “not” is denoted by the exclamation point preceding the third checkbox ID, defined in the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">XML</a>, via the <a href="https://developer.android.com/reference/android/widget/Checkable.html#isChecked()">isChecked()</a> method: !Q5thirdCheckBox.isChecked(). If any of the above are not fulfilled (i.e. if the user checks the first and second check boxes but misses the fourth and/or fifth one) a dialog will pop up at the bottom of the screen saying the answer’s incorrect and to try again.</p><p>It’s incredibly important to make sure you are only counting one point for when all the correct answers are chosen, instead of a point for each correct answer per question. You must also include the part of the statement that checks all of the correct answers have been chosen <em>and </em>the incorrect answer has <em>not </em>been chosen, in conjunction with the separate if statement below which sets the question to false if they have chosen incorrectly, so unnecessary points are not awarded.</p><p>The next if statement (Q5thirdCheckBox.isChecked()){} is to see if the quiz taker chose the only incorrect answer, the third checkbox; setting the variable isQ5Correct to false and showing a <a href="https://developer.android.com/guide/topics/ui/notifiers/toasts">toast</a> message once again alerting them they’ve chosen incorrectly and to try again.</p><p>Overall, the method checkBoxOne checks to see if the user has chosen the correct answers or not and provides instructions for either case. The difference between radio and checkbox logic is that for check boxes you can check for multiple correct answers using a complex <a href="https://developer.android.com/reference/java/util/concurrent/locks/Condition">conditional</a> statement in an if statement. Unlike simply setting the view to the correct answer’s ID, i.e. if(view.getId() == R.id.answer_q1) { isQ1Correct = true;…}, as you would for radio!</p><p>Since the next check box question uses more than just the &amp;&amp; and ! operators I will demonstrate that one as well! For question 8, there are 3 wrong answers instead of just one! For this you need to use the or operator, or ||. When defining the check boxes themselves for the Android version, specifically in the layout which is an XML file, I added the onClick attribute to each check box with the name checkBoxTwo. Then, in the Java file I created a method called checkBoxTwo which I will show below:</p><pre><em>/**<br> * Eighth Question<br> */<br><br></em>public void checkBoxTwo(View view){<br><br>    if (Q8firstCheckBox.isChecked() &amp;&amp; !Q8secondCheckBox.isChecked() &amp;&amp; !Q8thirdCheckBox.isChecked() &amp;&amp; Q8fourthCheckBox.isChecked() &amp;&amp; !Q8fifthCheckBox.isChecked() &amp;&amp; Q8sixthCheckBox.isChecked()) {<br>        isQ8Correct = true;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_correct</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br><br>    if (Q8secondCheckBox.isChecked() || Q8thirdCheckBox.isChecked() || Q8fifthCheckBox.isChecked()) {<br>        isQ8Correct = false;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_wrong</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>}</pre><p>If you notice, the first if statement is similar to the fifth question’s first if statement — it uses the &amp;&amp; and ! operators to accomplish the same thing which is to check <em>if and only if</em> the correct answers were chosen, and the incorrect answers were <em>not </em>chosen. Then in the if statement below it, I’ve included the logic that tells the program what to do if the user chooses the incorrect answers, which is where the or || operator comes into play. This statement alerts the user they have chosen incorrectly if they click the second, <em>or </em>third, <em>or </em>fifth check boxes!</p><h4>Refactoring Check Boxes for Web: Java → JavaScript</h4><p>For the check boxes, it is a similar process as the radio button JavaScript to handle the user selections. I’ll demonstrate with my first checkbox question, question 5! In the HTML, I included ID’s for each individual check box, which are going to be referenced in the JavaScript excerpt below:</p><pre>// Question 5 -- Check Boxes 1<br>function checkBoxOne() {<br> if (<br>  document.getElementById(&quot;Q5_checkbox_1&quot;).checked &amp;&amp;<br>  document.getElementById(&quot;Q5_checkbox_2&quot;).checked &amp;&amp;<br>  !document.getElementById(&quot;Q5_checkbox_3_wrong&quot;).checked &amp;&amp;<br>  document.getElementById(&quot;Q5_checkbox_4&quot;).checked &amp;&amp;<br>  document.getElementById(&quot;Q5_checkbox_5&quot;).checked &amp;&amp;<br>  document.getElementById(&quot;Q5_checkbox_6&quot;).checked<br> ) {<br>  // Correct answer is checked<br>  isQCorrect = true;<br>  score++;<br> }</pre><pre>if (document.getElementById(&quot;Q5_checkbox_3_wrong&quot;).checked) {<br>  // Incorrect answer is checked<br>  isQCorrect = false;<br> }<br>}</pre><p>Similarly, you create a custom function which I’ve named checkBoxOne() which is the same name as the Android version! Inside, a simple <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else">if/else</a> will suffice for these as well. The only difference between these and the radio button selections is that check boxes can be used to select multiple correct answers. For that reason, it follows that the if statement check for <em>all </em>the correct answers instead of just one! You can accomplish this by using a conditional statement with the &amp;&amp; and ! <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators">operators</a>! &amp;&amp; is a programming way of saying <em>if and only if</em>. The exclamation stands for <em>not</em>. The reasoning behind using the not operator is because it’s not enough that the user just click all of the correct answers — they must also not select the <em>wrong </em>one or the entire question’s wrong! By placing multiple &amp;&amp; <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators">operators</a> in one line, you also ensure that they are not getting extra points for <em>each </em>correct answer! This is just a way to ensure they only get <strong>one </strong>point for choosing only<em>, and all of, </em>the correct answers.</p><p>Since I explained how create the eighth question, or second set of check boxes, in Android it’s only fitting I now show how to do it for web! The JavaScript:</p><pre>// Question 8 -- Check Boxes 2   <br>function checkBoxTwo() {<br> if (document.getElementById(&quot;Q8_checkbox_1&quot;).checked &amp;&amp; !document.getElementById(&quot;Q8_checkbox_2_wrong&quot;).checked &amp;&amp; !document.getElementById(&quot;Q8_checkbox_3_wrong&quot;).checked &amp;&amp; document.getElementById(&quot;Q8_checkbox_4&quot;).checked &amp;&amp; !document.getElementById(&quot;Q8_checkbox_5_wrong&quot;).checked &amp;&amp; document.getElementById(&quot;Q8_checkbox_6&quot;).checked) {<br>  isQCorrect = true;<br>  score++;<br> } <br> <br> if (document.getElementById(&quot;Q8_checkbox_2_wrong&quot;).checked || document.getElementById(&quot;Q8_checkbox_3_wrong&quot;).checked || document.getElementById(&quot;Q8_checkbox_5_wrong&quot;).checked) {<br>  isQCorrect = false;<br> }<br>}</pre><p>For Android, I stored the check boxes into unique variables linked with their XML id’s but have chosen to not do that for web. Instead, I opted for the using getElementById() just like I did with the radio groups! The only differences between the first and second set of check boxes are that in the second set I use the or operator — || and check for multiple incorrect answers.</p><p>Since I’ve already demoed 2 questions for check boxes, I’ll just make a quick note about the last set, or question 10. In the Android App, the first answer choice was wrong and the 2nd was correct. I ran into an error trying to use the same logic to code the JavaScript using the syntax if !(document.getElementById(&quot;Q10_checkbox_1_wrong&quot;).checked &amp;&amp; … because you can’t use the ! operator directly after the if declaration. To remedy this, I simply switched the 1st and 2nd answer choices! Now the first answer choice is correct, with the new if statement starting like if (document.getElementById(&quot;Q10_checkbox_1&quot;).checked &amp;&amp; … and the 2nd answer choice is incorrect.</p><h3>Making Free Response Questions Interactive: Android vs. Web</h3><h4>Interactive Input Field in Android — Java</h4><p>So for this project I only have one free response, or open-ended question! In Android, the standard way to accomplish this is to use an <a href="https://developer.android.com/reference/android/widget/EditText">EditText</a> View. In HTML, the equivalent of this would be an input form field. But, I digress. To refresh from <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, the only free response in this app is my 4th question, for which you can view the XML <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">here</a>.</p><p>Prior to referencing the EditText View in the XML, you first need to declare the variable in Java. I did this by creating a global variable for it in my main activity class, before my <a href="https://developer.android.com/guide/components/activities/activity-lifecycle#oncreate">onCreate</a> method!</p><pre>//open-ended global<br>EditText responseField = null;</pre><p>Then, in my <a href="https://developer.android.com/guide/components/activities/activity-lifecycle#oncreate">onCreate</a> method, I included this block of code:</p><pre>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br>    super.onCreate(savedInstanceState);<br>    setContentView(R.layout.<em>activity_main</em>); <br>    ...<br>    //open-ended onCreate Q4<br>    responseField = findViewById(R.id.<em>response_field</em>);<br>... } </pre><p>Now you can reference the <a href="https://developer.android.com/reference/android/widget/EditText">EditText</a> View created in the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">XML</a> using the ID denoted by the line android:id=&quot;@+id/… is response_field which will be referenced in the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/java/com/example/android/magiciansquizapp/MainActivity.java">Java </a>file (pictured below) in your own custom method:</p><pre><em>/**<br> * Fourth Question<br> */<br></em>public void Q4Result() {<br>    EditText et = findViewById(R.id.<em>response_field</em>);<br>    String answer = et.getText().toString();<br><br><br>    if (answer.equalsIgnoreCase(&quot;Janet&quot;)) {<br>        isQ4Correct = true;<br><br>    } else {<br>        isQ4Correct = false;<br>        Toast.<em>makeText</em>(this, getString(R.string.<em>toast_wrong</em>), Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>}</pre><p>Essentially, what the previous code block is executing, is finding the view with the ID I defined in the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">XML</a> and then utilizing internal Java methods <a href="https://developer.android.com/reference/android/widget/EditText#getText()">getText()</a> and <a href="https://developer.android.com/reference/java/lang/String#toString()">toString()</a> to parse the data into a more readable format! The following if statement allows the user to enter a non case-sensitive answer so that they’re not penalized for not capitalizing the first letter. Then the consequent else statement tells the program what to do if the entry is incorrect! This is just in the form of the same pop up dialog, or <a href="https://developer.android.com/guide/topics/ui/notifiers/toasts">toast</a> message for incorrect answers from before!</p><p>While I only have one free response <em>question</em>, I have one more <a href="https://developer.android.com/reference/android/widget/EditText">EditText</a> in the Android version of my app that allows the quiz taker to enter their name. It is located at the top of the screen before the introductory elements as the first thing they can do! To refresh, see the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">XML</a>.</p><p>This also has a unique ID, in the same format as the other free response field, name_field. The string, @string/hint1 can be found in my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/strings.xml">strings</a> file as &lt;string name=&quot;hint1&quot;&gt;Name&lt;/string&gt;. Using the same process as before, you create a variable, in my case a global one, for the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/java/com/example/android/magiciansquizapp/MainActivity.java">Java</a> like so:</p><pre>//nameField global<br>private EditText nameField;</pre><p>Then, in the <a href="https://developer.android.com/guide/components/activities/activity-lifecycle#oncreate">onCreate</a> method (there are other ways to do this, I just prefer this way!):</p><pre>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br>    super.onCreate(savedInstanceState);<br>    setContentView(R.layout.<em>activity_main</em>);<br>    nameField = findViewById(R.id.<em>name_field</em>);</pre><p>Since this doesn’t require checking the answer for a specific response you can just stop here! With that, my Android free response fields are complete.</p><h4>Refactoring Input Fields for Web — JavaScript</h4><p>So for most of the adaptation so far, I’ve tried to stick as much to the original Android version as possible. However, due to HTML form’s default behavior of refreshing the page after hitting enter or submit, I had to change some things around! I discovered these issues when trying to take the quiz to debug the scoring logic below. After answering all 10 questions points were only being awarded for 9 of them. After the process of elimination, I figured out the free response field was not being scored! With some help from a fellow Udacity scholar, I figured out what the issues were preventing the question and answer from performing correctly! You can see some of his other work <a href="https://github.com/mamuleanu">here</a> and connect with him <a href="https://www.linkedin.com/in/madalin-mamuleanu-6000b9a9/">here</a>! I will list the steps we took to fix the issues below.</p><ol><li>Remove unnecessary lines form = document.form[3]; and responseField = form.elements[&quot;q4response”];.</li><li>Simplify var et = document.getElementById(&quot;response_field&quot;); var answer = et.getText().toString(); to var answer = document.getElementById(&quot;hint2&quot;).value;. Changed ID to hint2 since that’s the input field’s ID.</li><li>Delete the &lt;form id=&quot;response_field&gt; and &lt;/form&gt; from HTML! By taking it out, you prevent the page reloading when pressing enter.</li><li>Then change if (answer.ignoreCase(&quot;Janet&quot;)){ isQCorrect = true; score++; }else{ isQCorrect = false; } to if (answer.toUpperCase() == “janet&quot;.toUpperCase()) { score++; } in the JS.</li><li>Insert the updated lines into setScore() function at the end!</li></ol><pre>// For Score summary<br>function setScore() {<br> <br> ...<br> <br> // Q4, free response, logic <br> var answer = document.getElementById(&quot;hint2&quot;).value;<br> if (answer.toUpperCase() == &quot;janet&quot;.toUpperCase()) {<br>  score++;<br> } ... </pre><h4>Creating the Score Summary in Android — Java</h4><p>If you recall at the beginning of this article, I built out the logic for tracking the score by creating variables to store Booleans based on if each question was correct or not (i.e. isQ1Correct). Now, we can call those variables to actually reward points! At the end of the Java file, you’ll set the tally for the points by creating two separate methods; one to increment one point for each correct answer, and another to parse and display the score summary to the user. I accomplished this with the following lines of code, in which I reference the scoring counter variables declared at the beginning of my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/java/com/example/android/magiciansquizapp/MainActivity.java">Java</a> file in the main activity class:</p><pre><em>/**<br> * For Score Summary<br> */</em></pre><pre>public void setScore(View view) {<br>    Q4Result();<br>    // remember to reset score for each time the grading logic calculates it.<br>    score = 0;<br><br>    if (isQ1Correct) score++;<br>    if (isQ2Correct) score++;<br>    if (isQ3Correct) score++;<br>    if (isQ4Correct) score++;<br>    if (isQ5Correct) score++;<br>    if (isQ6Correct) score++;<br>    if (isQ7Correct) score++;<br>    if (isQ8Correct) score++;<br>    if (isQ9Correct) score++;<br>    if (isQ10Correct) score++;<br><br>    String scoreSummary = createScoreSummary(nameField.getText().toString(), score);<br>    Toast.<em>makeText</em>(this, scoreSummary, Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br><br><br>private String createScoreSummary(String name, int score) {<br>    String scoreSummary = String.<em>format</em>(getString(R.string.<em>score_summary_name</em>), name);<br>    scoreSummary += &quot;\n&quot; + getString(R.string.<em>score_summary_score</em>) + score;<br>    return scoreSummary;<br>}</pre><h4>Refactoring the Score Summary for Web — JavaScript</h4><p>At the end of the JavaScript, I simplified the original Java score summary methods since less code was needed to accomplish the same thing. I was able to completely get rid of the createScoreSummary() method I used in the Android version since I could do the same thing in JavaScript differently. By simply declaring scoreSummary as a variable and then using a concatenated string (so that the alert is formatted correctly), I could alert the quiz taker of their score!</p><p>After all of this, the new setScore() function (with question 4’s logic) in the JavaScript is:</p><pre>// For Score summary<br>function setScore() {<br> <br> radio1();<br> radio2();<br> radio3();<br> radio4();<br> radio5();<br> radio6();<br> checkBoxOne();<br> checkBoxTwo();<br> checkBoxThree();<br> <br> // Q4, free response, logic <br> var answer = document.getElementById(&quot;hint2&quot;).value;<br> if (answer.toUpperCase() == &quot;janet&quot;.toUpperCase()) {<br>  score++;<br> }<br> <br> // calculate score <br> var scoreSummary = score;<br> //re-initialize to zero so points aren&#39;t awarded unnecessarily <br> score = 0;<br> // alert user of score<br> window.alert(&quot;Your score is &quot; + scoreSummary);<br>}</pre><p>I initialized the score to 0 again after declaring the scoreSummary variable. If you click see score again after entering a response the code won’t keep adding points! I also called each function we created above the score summary in the beginning of setScore(). By removing onClick() from the HTML and calling the functions for each question in the score summary, only <em>one </em>point is awarded for each question. So now the web app finally functions as well as the Android app even though I used slightly different approaches to get it there! Now when you’re finished taking the quiz, a dialog message pops up alerting you of your score summary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RbSIZPYkEbR-qR2cQOTA7Q.png" /></figure><h3>Closing Remarks</h3><p>This was definitely the most challenging conversion out of the 3 I covered: XML → HTML5; XML → CSS3; Java → JavaScript. It was also the most rewarding! I learned a lot as far as how to make the app function using JavaScript, as well as how to better format the HTML!</p><p>The key takeaways:</p><ul><li>Always reset the score variable to 0 when creating the score summary so answers aren’t counted more than once!</li><li>Just call the functions for each question in the score logic instead of using HTML’s onClick()! This also prevents extra points being awarded.</li><li>If one method isn’t working, try switching it out for something that does what you want in a different way — i.e. using toUpperCase() in place of ignoreCase() for string comparisons!</li><li>While it can be tempting to use the same approach for each platform when adapting something, keep in mind each has their own syntax, conventions, and ways of managing errors.</li></ul><p>If you missed the first 2 segments, here are <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a> and <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">Part II</a>. If you enjoyed this, please clap and share this post! Also, if you have any suggestions I always welcome feedback. Thanks for following my portfolio building journey, and stay tuned for the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=176e30984d7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taking a New Stance on Internships — To Pay or Not to Pay]]></title>
            <link>https://medium.com/@adm2037/taking-a-new-stance-on-internships-to-pay-or-not-to-pay-c387eef420be?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c387eef420be</guid>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[arguments]]></category>
            <category><![CDATA[debate]]></category>
            <category><![CDATA[creative-writing]]></category>
            <category><![CDATA[unpaid-internships]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Tue, 05 Feb 2019 00:01:43 GMT</pubDate>
            <atom:updated>2019-02-05T00:01:43.004Z</atom:updated>
            <content:encoded><![CDATA[<h3>Taking a New Stance on Internships — To Pay or Not to Pay</h3><blockquote>Disclaimer: While hanging out with a friend of mine the other day she suggested that we do something fun and productive that stimulates our minds. One of her suggestions was to take a random prompt and either write an article or speech about it. I took that a step further and said we should write about the stance opposite to the one we hold ourselves. She floated the idea of writing about unpaid internships. Since I’ve typically fallen into the group of people that do not support the idea of unpaid internships, I decided to try to write in support of them instead! I found out I actually have a lot more arguments in favor of unpaid internships than against them! This is why writing counter arguments is such a powerful tool. The counter can either help to prove why your original stance is stronger, or completely tear it apart! I came up with the following on my own, without using my phone or outside help, in 45 minutes. Only after handwriting and transcribing it here did I go ahead and add links for specific ideas or references! The result:</blockquote><h4>Unpaid internships are typically seen in a controversial light. I beg to differ.</h4><p>The main arguments I’ve heard to support they’re controversial are:</p><ul><li>If someone’s providing value in the form of their time, energy, and frankly presence (as in the act of merely showing up), they should be compensated. Not only is this person sacrificing their leisure, they are helping the company work toward goals that will most likely not benefit the individual in any way — if payment’s not on the table.</li><li>Most unpaid internships are reserved for undergraduate students — many won’t even let you apply if you have a degree already, or on the contrary, have not participated in higher education at all. Since students are typically already struggling financially, they shouldn’t be expected to work for free.</li><li>Simply getting experience, or exposure, is a way for businesses to take advantage of younger, more impressionable minds. They prey on the marginalized and less fortunate to get labor for free.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*SV2Cy0jHXgFNNmexYRxftw.jpeg" /></figure><p>These are just a few of the arguments, supporting the idea that all internships should be paid, that have come to my attention. Now I’ll explain why they are fundamentally flawed! Note: the following arguments are operating under the assumption that these internships <em>actually </em>provide value or learning experiences to their interns, and are all up to legal standards.</p><p>With regards to believing everyone should always be paid for their work in an internship, they’ve clearly overlooked (or misunderstood) a key principal of business and economics. There is <em>always </em>a <a href="https://study.com/academy/lesson/trade-offs-in-economics-definition-examples.html">tradeoff</a>. By saying you’re giving your time, energy, or labor for nothing, you’re not taking into account that the company/staff are also giving these in return. No, you might not get paid. But you will learn from them, build your network, and figure out how to navigate and ins and outs of the workplace. You’ll probably have ample opportunities to get feedback, constructive or otherwise, and learn how to respond to it in a way conducive to growth. By working on a team, or with different departments, you will build <strong>soft skills</strong> which many people underestimate the importance of. By soft skills, I just mean disposition, communication, and presenting your most authentic self. There are entire books on the subject of this alone! A great one being <a href="https://www.amazon.com/Soft-Skills-software-developers-manual/dp/1617292397">“Soft Skills” by John Somnez</a>, which just so happens to double as a “software developer’s life manual” as he calls it! You might even argue that these skills are of <em>more </em>importance than the skills relative to your actual internship. Simply because these skills will be valuable in <em>any </em>environment, career or otherwise! Even if you change fields or jobs later, these skills will transfer. So while you might not be getting financially compensated in an unpaid internship, there’s no question you’ll stand to gain in ways that extend beyond the scope of your current position! Ways that can benefit you even in social, or informal, settings. Couple that with the experience, networking, and workplace etiquette that’ll undoubtedly help you in the future, money suddenly doesn’t seem like as much of a deal breaker.</p><p>The 2nd argument I listed in favor that all internships should be paid, states that if people are most likely struggling financially (i.e. students), that they shouldn’t be expected to work for free. This is actually a view I myself have held. A flaw in this reasoning is that school itself is working for free. We spend (in the West at least) upwards of 20 of our formative years producing work for 8+ hours a day, entirely unpaid. That’s not including extracurriculars, independent assignments and study. To take this even further, not only do you not get paid for college or higher education, you. pay. for. it — or get funded, or sponsored, by someone else. Someone pays for it, even if not you specifically. You could try to argue that oftentimes primary school (or homeschooling) is required of you, via parents, society, etc. but college is a choice! “But, I’m getting an education!”, you’ll say. Does it not follow, then, that unpaid internships are also a form of education — except what you’ll learn there will most likely actually apply to the real world; and more specifically, to the field you’re pursuing?</p><p>Lastly, the 3rd argument, asserting that unpaid internships can be a company’s way of exploiting the marginalized comes down to perspective. I’ll demonstrate with an example paraphrased from a book I read once:</p><blockquote>Say a respected, “successful” person has inherited, or somehow come into possession of, a sizable plot of land. On this land is an assortment of trees, however sparse, a polluted lake and soil not suited for crops. This person might look at this land as worthless and sell it for what they feel to be a decent, albeit low, price. Meanwhile, the buyer sees this as a goldmine! He uses the timber to build a bed and breakfast, cleans up the lake creating an in-house irrigation and filtration system, and rents each room for hundreds of dollars a night!</blockquote><p>Can you guess which person won in that scenario? There’s a difference between being smart, and being <em>resourceful</em>. Bu what it truly comes down to is a simple shift in perspective. Back to how this all ties into the alleged exploitation of marginalized people; instead of seeing an unpaid internship as an unfair deal, you can choose to view it as an opportunity. Yes, perhaps it’s not a paid position. But would anyone really be better off with <em>less </em>options for their career path? Is it really better to not offer those internships at all? How many less internships would there be seeing as companies wanting to expand may not always have the budget to pay all interns? How many less connections would be made, ideas shared, and individuals prepared for joining/navigating the workforce? Who really loses if all internships that couldn’t pay every intern were discontinued? Chances are the businesses and economy would be just fine. Perhaps one might make better use of their time and energy by taking pause when it comes to whether internships should all be paying or not. Instead of focusing on all the reasons it’s wrong, unfair, or immoral; consider what the alternative could be. In the absence of the large percentage of unpaid internships available, would be that many less opportunities for people to grow in their fields, into their own, and into their networks.</p><p>Also, bear in mind that participating in an unpaid internship is usually a choice, with those required to take one for school credit aside. It’s up to you to decide what you feel you deserve and determining what you hope to gain from the experience. If you simply don’t agree with the idea, <em>don’t do one</em>. Plain and simple. It’s not necessary to worry about why you think they should all be paid, especially if you haven’t first stopped to consider all the ways in which they could be beneficial. If not to you, then to others. Some have met their future boss or business partner(s) at such an internship. Others worked on projects that helped shape or shift their worldview; or at least showed them what they do or don’t want in a career. Overall, the question remains: <strong>does the benefit outweigh the cost?</strong> And it should be up to each person to decide that for themselves!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c387eef420be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adapting an Android App for Web — Part II]]></title>
            <link>https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1f1fac843af</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Fri, 18 Jan 2019 03:36:47 GMT</pubDate>
            <atom:updated>2019-02-11T21:06:27.460Z</atom:updated>
            <content:encoded><![CDATA[<h3>Adapting an Android App for Web — Part II</h3><p>In <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, I walked through how I refactored the XML elements for my Android app based on the TV show <a href="https://www.syfy.com/themagicians">“The Magicians”</a> for web using HTML5. You can see the full Android version <a href="https://github.com/AM2037/MagiciansQuizApp">here</a>. If you scroll down my <a href="https://github.com/AM2037/MagiciansQuizApp">GitHub repository</a> you will see the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/README.md">README.md</a> file which contains an overview of the Android application! In short, it’s a quiz app based on the SyFy show “The Magicians” using the following 3 types of questions:</p><ul><li><a href="https://developer.android.com/guide/topics/ui/controls/radiobutton">Radio </a>— When there is only one correct answer</li><li><a href="https://developer.android.com/guide/topics/ui/controls/checkbox">Check Box</a> — When there are multiple correct answers</li><li><a href="https://developer.android.com/reference/android/widget/EditText">Free Response</a> — When the user enters a response in the input field</li></ul><p><em>The Android App that I am adapting for Web looks like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*PW1i-u9QAn-MN89XpNEB4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*9kFtN45vCy2rrvjzkHkggA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*ebwx4M9q95K-auyxXzmlNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*HjefYyFA-TohvYljOhrAPg.png" /></figure><h3>Styling the Elements in Android vs For Web</h3><p>I refactored the Android app shown above for web using <a href="https://codepen.io/">Codepen</a> which you can find <a href="https://codepen.io/AM2037/pen/vvapJJ">here</a>!</p><h4><strong>Styling in Android</strong></h4><p>I touched on this a little bit in <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, but to make styling easier you can simply put all of your characteristics in your <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/styles.xml">styles.xml</a> file if you are going to have the exact same attributes for each type of question. I only used that method for the check boxes though. I styled the rest in my main <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">layout</a> file.</p><p><strong>Styling The Layout(s) in Android</strong></p><p>First things first, the layout hierarchy! You can reference my layout file <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">here</a>. For this specific project, I opted for a over-arching parent <a href="https://developer.android.com/reference/android/widget/ScrollView">ScrollView </a>tag and nested <a href="https://developer.android.com/guide/topics/ui/layout/linear">Linear Layouts</a> within it! I placed the first Linear Layout directly below the scrolling View to hold the name field. Then beneath that there’s another Linear Layout to hold all of the introductory elements, like the opening greeting “Welcome to the Magician’s Quiz App…” and title and character images. Next I created separate Linear Layouts for all 3 sets of questions; one for the characters quiz, one for the timelines quiz, and one for the battles quiz.</p><p>The first Linear Layout with the name field has <a href="https://developer.android.com/reference/android/view/View#size-padding-and-margins">padding</a> around it so it doesn’t get scrunched up against the edges. Each of the following linear layouts have these attributes, with their own ID’s:</p><pre>&lt;LinearLayout<br>    android:id=&quot;@+id/quiz_1&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:orientation=&quot;vertical&quot;&gt;</pre><blockquote>P.S. I talk more about layouts in my last portfolio post, which you can read <a href="https://medium.com/@adm2037/converting-legacy-layouts-in-android-94236872fdb7">here</a>!</blockquote><p><strong>Styling the Images in Android</strong></p><pre>&lt;ImageView<br>        android:id=&quot;@+id/title_sequence_image&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:adjustViewBounds=&quot;true&quot;<br>        android:scaleType=&quot;fitStart&quot;<br>        android:src=&quot;@drawable/titlesequence&quot;<br>        android:contentDescription=&quot;@string/content_description&quot; /&gt;</pre><p>For the opening image, I made it span the width of the device but the container only as tall as the image itself. The scaleType attribute set to fitStart ensures that it will be the first element shown in it’s parent linear layout. I included a content description for better <a href="https://developer.android.com/guide/topics/ui/accessibility/apps">accessibility</a>. This way the computer can read out a description of the image if the user can’t see it or if the image will not load on their device.</p><p><strong>Styling the Headers in Android</strong></p><p>All of the headers look like this, with their own <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/strings.xml">string</a> references:</p><pre>&lt;TextView<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:scaleType=&quot;centerCrop&quot;<br>    android:text=&quot;@string/character_quiz&quot;<br>    android:textAlignment=&quot;center&quot;<br>    android:textColor=&quot;@color/colorPrimary&quot;<br>    android:textSize=&quot;@dimen/topics&quot;<br>    android:textStyle=&quot;bold&quot;<br>    android:typeface=&quot;serif&quot;<br>    android:layout_marginBottom=&quot;@dimen/margin2&quot; /&gt;</pre><p>I made their font size 4 pixels bigger than the subsequent questions, which are 18 pixels so that they stand out. In the same vein, I set the text to bold. I got the color using Chrome’s <a href="https://chrome.google.com/webstore/detail/eye-dropper/hmdcmlfkchdmnmnmheododdhjedfccka?hl=en">color picker</a> and choosing a color from the very first image of the app (shown below), which I did for all of the main <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/colors.xml">colors</a>! I used colorPrimary for these, which is a blend of light blue and purple. The font for all of these is serif, which also happens to be the font of the footer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jjb2V0jdYN7CDfYRcHBp1A.png" /></figure><p>I also gave the headers a larger margin between them and the questions than between the questions and answers so you could tell which elements are grouped together. This is helpful so that viewers intuitively get a sense of where to look next. This is especially helpful if you have a particular “path” you want your users to take navigating your app. Lastly, purely for the aesthetic, I placed all of the headings in the center.</p><p><strong>Styling the Questions in Android</strong></p><pre>&lt;!-- Characters Q2 --&gt;</pre><pre>&lt;TextView<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/character_q2&quot;<br>    android:textSize=&quot;@dimen/questions&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:layout_marginBottom=&quot;@dimen/margin1&quot; /&gt;</pre><p>All of the Android questions have the styling shown above. I made the color white, the same as the answers. I made the width match the parent container so it would span the screen and then create a new line when it reached the end. I made the height wrap_content so that no unnecessary space was used! You can find a more in-depth explanation about layout parameters in Android <a href="https://developer.android.com/reference/android/view/ViewGroup.LayoutParams">here</a>. For the font size I extracted the dimension resource to the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/dimens.xml">dimens.xml</a> file, which is 18 pixels. And so it would stand out more against the black background I set the text to the color white. For this <a href="https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams">margin</a>, I used a slightly smaller one than the headers so there was less space between the questions and their corresponding answers!</p><p><strong>Styling the Answers in Android</strong></p><pre>&lt;android.support.v7.widget.AppCompatRadioButton<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q3_r1&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:onClick=&quot;radio3&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    app:buttonTint=&quot;@color/colorAccent&quot;<br>    android:textColor=&quot;@android:color/white&quot; /&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*2Ch4ZVDVNaAB_-rEjNlzfA.png" /><figcaption>To show Radio Button styling</figcaption></figure><p>For the radio buttons, I used the same padding from the headers so there was adequate space between the button and the text. This is in a separate <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/dimens.xml">dimens</a> file, as with all of the sizing values. I used a lighter color for the outline of the unchecked boxes as well as the checked boxes — also acquired from the title sequence opening image using Chrome’s <a href="https://chrome.google.com/webstore/detail/eye-dropper/hmdcmlfkchdmnmnmheododdhjedfccka?hl=en">eye dropper</a> tool. This shade is slightly more purple than the heading text shade and perfect for accenting things.</p><pre>&lt;CheckBox<br>    android:id=&quot;@+id/Q5_checkbox_1&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q5_c1&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxOne&quot; /&gt;</pre><p>As shown above, it’s common practice to use <a href="https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#WRAP_CONTENT">“wrap_content”</a> for the width and height so that the answers are contained in a small space and then add space between the button and the text with the <a href="https://developer.android.com/reference/android/view/View#size-padding-and-margins">“padding”</a> attribute. For easier modification and accessibility, it helps to also extract these number values to a separate <a href="https://developer.android.com/guide/topics/resources/more-resources#Dimension">“dimens”</a> resource file that way you only have to change the value in one place rather than edit it for each item! The text size and color are the same as the questions for continuity throughout the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*n0u7x5xa9CZVwHqNWp_VBg.png" /></figure><p>Another aspect I’ve extracted to a separate file, instead of simply “hard coding” it into the attribute declaration in the layout file itself is the checkbox theme! For instance, if you look at the code block above, you can see the line android:theme=&quot;@style/CheckBoxes&quot;. I’ve done this because it’s easier to specify these attributes in one place instead of having to repeat it for each check box in the layout file! If you click to my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/styles.xml">styles.xml</a> file, it reads:</p><pre>&lt;style name=&quot;CheckBoxes&quot; parent=&quot;Theme.AppCompat.Light&quot;&gt;         <br>    &lt;item name=&quot;colorControlNormal&quot;&gt;@android:color/white&lt;/item&gt;         <br>    &lt;item name=&quot;colorControlActivated&quot;&gt;@color/colorAccent&lt;/item&gt;    &lt;/style&gt;</pre><p><strong>Styling the Free Response Fields in Android</strong></p><pre>&lt;EditText<br>    android:id=&quot;@+id/name_field&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:paddingTop=&quot;@dimen/padding&quot;<br>    android:paddingBottom=&quot;@dimen/padding&quot;<br>    android:hint=&quot;@string/hint1&quot;<br>    android:inputType=&quot;textCapWords&quot;<br>    android:maxLines=&quot;1&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:background=&quot;@android:color/black&quot; /&gt;</pre><p>For the first open-ended, or name_field EditText, I made the width match_parent so it would span the width of the device and then set the height to wrap_content so it wouldn’t take up unnecessary space. I set the top and bottom padding to 16dp so it wouldn’t be crammed against the top of the screen or the introductory text. To match the background of the app, I made the background of the input field black as well and set the text color to white so there would be sufficient contrast!</p><pre>&lt;EditText<br>    android:id=&quot;@+id/response_field&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:hint=&quot;@string/hint2&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:inputType=&quot;textCapWords&quot;<br>    android:maxLines=&quot;1&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:background=&quot;@color/colorPrimaryDark&quot;<br>    android:layout_marginBottom=&quot;@dimen/margin1&quot;<br>    tools:ignore=&quot;Autofill&quot; /&gt;</pre><p>For Question 4 (shown above), the only free response question in this quiz, I made the question’s text color the same as the others: white. I set the background of the input field to the darkest color in my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/colors.xml">colors</a> file, which is a dark navy blue. For the margin, I set it to the same margin as the questions which is 16dp. The <a href="https://developer.android.com/training/multiscreen/screendensities">dp</a> unit stands for density-independent pixels which makes for better resolution support across devices, which is the same reason we use “sp” for defining text size. I made the background dark blue, @color/colorPrimaryDark for this one, as opposed to black, so it was clear there was an input field there.</p><p><strong>Styling the Score Summary Elements in Android</strong></p><p>Most of the score summary code will be written in Java (discussed in Part III), however the button the quiz taker clicks to see the score is defined in the XML. In Android, you style the elements in the same file you define them in unlike when you are programming apps for web. Therefore, I’ll show you the same excerpt from <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>:</p><pre>&lt;!-- Scoring --&gt;<br><br>&lt;TextView<br>    android:id=&quot;@+id/score_summary&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:paddingTop=&quot;@dimen/padding&quot;<br>    android:text=&quot;@string/score_summary_score&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:textSize=&quot;@dimen/questions&quot; /&gt;<br><br>&lt;Button<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/score_summary&quot;<br>    android:onClick=&quot;setScore&quot;<br>    android:color=&quot;@color/colorAccent&quot; /&gt;</pre><p>I made both the “Final Score:” <a href="https://developer.android.com/reference/android/widget/TextView">TextView</a> and the Button width and height wrap_content so they don’t take up more space than they need. Just like with all of the questions, I extracted attributes like font information, colors, and text into separate resource files. As mentioned in <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, I’ll explain what happens with the <a href="https://developer.android.com/reference/android/view/View.OnClickListener">onClick</a> attribute in <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">Part III</a> when I cover how to make everything interactive using Java!</p><h3><strong>Styling for Web</strong></h3><p><strong>Styling the Layout for Web</strong></p><p>Thankfully for web you don’t need a separate layout file like in Android, you can just style the elements you created in your HTML in your CSS and link them with a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link">link</a> tag. To make the web app resemble the Android version, I used the same background color of black delineated by this block of code at the top of my CSS file:</p><pre>html {<br> background-color: black;<br>}</pre><p><strong>Styling the Images for Web</strong></p><p>Since there are no general identifiers for the images on my web app, such as font-family, or font color, you can just focus on what’s included in the media queries! I’ll demonstrate with the query for the larger desktops and laptops as I have with the others. Prior to linking the images in the HTML, I used an online <a href="https://imageresize.org/">image resizer</a> to make all of the image widths 900 pixels and then kept the aspect ratios of the respective heights locked to retain the quality of the photos. Then, by placing a div tag with the class image around the question in the HTML, I centered the images with the following lines of code:</p><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width: 1281px) {<br> /* Larger Laptops and Desktops */</pre><pre> .image {<br> text-align: center;<br> }<br>}</pre><p><strong>Styling the headers for Web</strong></p><p>You can streamline the styling process by placing certain elements in a surrounding div with a unique <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class">class</a> name. I also used this technique with the title, or <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header">header</a>, elements:</p><pre>.title {<br> color: #828edc;<br> font-family: serif; <br>}</pre><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width: 1281px) {<br> /* Larger Laptops and Desktops */<br> .title {<br>  text-align: center;<br> }</pre><p><em>Styled in this way, the headers end up looking like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3df820hj5UNee4ClIN_pg.png" /></figure><p><strong>Styling the Questions and Answers for Web</strong></p><p>You can style the HTML elements using the classes and ID’s defined in the HTML <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div">div </a>tags. This is where that surrounding div with the class “question” I covered earlier comes in! I can now reference it in the CSS to style the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio">radio button</a> questions and answers, like so:</p><pre>.question {<br> color: white;<br> font-size: 18sp;<br> font-family: sans-serif;<br>}</pre><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width: 1281px) {<br> /* Larger Laptops and Desktops */<br> <br> .question {<br>  padding-left: 30%;<br> }<br>}</pre><p>In the code block above, notice that I’ve included a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries">media query</a>. I’ve found that only putting regular styling like colors and font attributes in the main CSS scope helps me to create more fluid websites. By only putting attributes for sizing, placement, and resolution in media queries for each device screen size helps create more responsive websites! I keep the styling aspects in the main section of the CSS (as in not in a media query) because they span the entire app across every device, like the background color for example. This way I can be really specific about how I want something to fit on each screen in each media query.</p><p><strong>Styling the Free Response Field for Web</strong></p><p>Using the ID hint2 from the 4th question which is the open-ended question, you can make the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text">input field</a> the same dark navy blue color used in the Android edition:</p><pre>input#hint2, textarea {<br> background-color: #2b316f;<br> border-style: none;<br> color: white;<br>}</pre><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width: 1281px) {<br> /* Larger Laptops and Desktops */<br> <br> input#hint2, textarea {<br>  font-size: 18px;<br>   }<br>}</pre><p>In the media query at the bottom of that code block I’ve set the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size">font size</a> to 18 pixels, since I may want this value to change if I’m showing the app on a device with a smaller screen!</p><p>Of course, it’s common practice to include several <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries">media queries</a> like the ones listed below for the best render and resolution for all devices. However, for the purposes of this post I decided to demonstrate with just one! I retrieved the following media queries from this <a href="https://gist.github.com/gokulkrishh/242e68d1ee94ad05f488">Gist</a>.</p><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width: 1281px) {<br> /* Larger Laptops and Desktops */<br>}</pre><pre><a href="http://twitter.com/media">@media</a> (min-width: 1025px) and (max-width: 1280px) {<br>  /* Medium Laptops and Desktops */<br>}</pre><pre><a href="http://twitter.com/media">@media</a> (min-width: 768px) and (max-width: 1024px) {<br>  /* Tablets and Ipads: portrait */<br>}</pre><pre><a href="http://twitter.com/media">@media</a> (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {<br>  /* Tablets and Ipads */ <br>}</pre><pre><a href="http://twitter.com/media">@media</a> (min-width: 481px) and (max-width: 767px) {<br>  /* Low-res Tablets and Mobile: landscape */ <br>}</pre><pre><a href="http://twitter.com/media">@media</a> (min-width: 320px) and (max-width: 480px) {<br>  /* Most devices: portrait */ <br>}</pre><p><strong>Styling the Score Summary Elements for Web</strong></p><p>As I mentioned in <a href="https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073">Part I</a>, I created a button which I placed at the very end of the quiz’s <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body">body</a> tag which reads “See Score”. At the end of the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button">button</a> tag I included the class&quot;button&quot; which will be now reference in the CSS. In the main CSS section (aka not media queries), I placed all of the basic styling attributes such as colors, fonts, etc. as seen below. I made the color of the button the same color as the footer text since it is located directly above it but the font the same as the questions. By using a similar feature of each it kind of ties everything together.</p><pre>/* Basic styling for score button */<br>.button {<br> background-color: #8084cd;<br> font-family: sans-serif;<br> text-align: center;<br> color: white;<br> border-style: solid;<br>}</pre><p>Since I put all the positioning and sizing attributes in the media queries I’ll demonstrate how I centered the button for larger screens and desktops. I also put all the font-size properties in media queries so I can better change them for smaller screens. The button’s CSS for one of the media queries reads:</p><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width: 1281px) {<br> /* Larger Laptops and Desktops */<br> ...</pre><pre>  .button {<br>      display: block;<br>      margin: 0 auto;<br>      font-size: 18px;<br>      padding: 10px 20px;<br>   }<br>}</pre><p><em>The refactored Web app user interface, after all of this styling has been applied, is as follows:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*o3vnie98Pli7bMcQzAfGYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wHLBpVUa0tlOTwEvN4BHJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rBENlNRFgTR5GmHvj8ORA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0SSnEVWtJcX8bJjszxpkzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1fcLZ8bmTbSuDEE7wvBCMg.png" /></figure><h4>Closing Remarks</h4><p>In summation, by extracting resources into separate resource files such as <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/strings.xml">strings.xml</a>, <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/dimens.xml">dimens.xml</a>, <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/colors.xml">colors.xml</a>, and <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/styles.xml">styles.xml</a> you can ensure easier maintenance of the code base in the future. For better accessibility, always make sure to include the content description attribute in the <a href="https://developer.android.com/reference/android/widget/ImageView">ImageView</a> tag in your layout file which should also be extracted as a separate <a href="https://developer.android.com/reference/java/lang/String">String</a> resource. This ensures that if you need to make changes later you can change the values in one place instead of each instance.</p><p>Styling for Web is streamlined by wrapping certain HTML elements in surrounding <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div">div</a> tags with unique <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class">class</a> names if you want them to have the same characteristics for the same reason you extract resources in Android — for easier modification and readability of your code base! This way you only have to style the class instead of each individual <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">question</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header">header</a>, and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img">image</a>.</p><p>As always, if you enjoyed this piece please clap and share! I am also always interested in hearing any feedback you have to offer so don’t hesitate to comment down below. See you in <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">Part III</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1f1fac843af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adapting an Android App for Web — Part I]]></title>
            <link>https://medium.com/@adm2037/converting-an-android-application-for-web-part-i-930941641073?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/930941641073</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[magicians]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Fri, 18 Jan 2019 03:03:15 GMT</pubDate>
            <atom:updated>2019-02-11T21:15:55.876Z</atom:updated>
            <content:encoded><![CDATA[<h3>Adapting an Android App for Web — Part I</h3><p>Welcome to the third installment of my portfolio series where I walk through adding specific features to apps as well as the modification and updating processes. For this three-part publication I’ll be taking one of my Android applications and using HTML, CSS, and JavaScript to transform it for web! For the first part, I’ll just walk through how to code radio button groups, check boxes and free response questions using XML and HTML5. In the <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">2nd part</a> I’ll dive into styling these elements using XML and CSS. For the <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">3rd part</a> I’ll cover making all of this interactive! Feel free to check out the original <a href="https://github.com/AM2037/MagiciansQuizApp">Android version</a>! You can find an overview of the Android application <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/README.md">here</a>. I originally built this app using Android Studio 3.0, API 27: Android 8 (Oreo) and have since updated it to Android Studio 3.1, API 28: Android 9 (Pie). The original Android app is shown in the collage below, which also serves as the blueprint for the web refactor!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*PW1i-u9QAn-MN89XpNEB4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*9kFtN45vCy2rrvjzkHkggA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*ebwx4M9q95K-auyxXzmlNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*HjefYyFA-TohvYljOhrAPg.png" /></figure><h3>Remaking the Content using HTML5 Tags</h3><p>I will first lay out how you do all of this in Android using a specific question and then show you how to accomplish the same effect using HTML5. I will continue with this process for all 3 types of questions!</p><h4>Setting up the Questions in Android</h4><p>I will demonstrate the following types of questions:</p><ul><li><a href="https://developer.android.com/guide/topics/ui/controls/radiobutton">Radio Group/Radio Buttons</a> — A multiple choice question where there is only one correct answer. The following paragraphs demonstrate refactoring this type of question from Android to Web!</li><li><a href="https://developer.android.com/guide/topics/ui/controls/checkbox">Check Boxes</a> — A multiple choice question where there are multiple correct answers.</li><li><a href="https://developer.android.com/reference/android/widget/EditText">EditText </a>— An open-ended, or free response, question where you ask them to formulate a response. Could be a word, a sentence, or paragraph. You can set parameters on the answer for scoring!</li></ul><p><strong>Radio Questions in Android</strong></p><p>In Android, the common practice for setting up quiz questions is storing each individual question and answer in a separate file in the form of a <a href="https://developer.android.com/guide/topics/resources/string-resource">string resource</a>, typically located at main/src/res/values/strings.xml. I’ll demonstrate using the first question from my Android quiz! The following code snippet is from my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/strings.xml">strings.xml</a> file:</p><pre>&lt;!-- Q1 MC Radio Buttons --&gt;<br>&lt;string name=&quot;character_q1&quot;&gt;Which fantasy book series is the character Quentin Coldwater a massive fan of?&lt;/string&gt;<br>&lt;string name=&quot;q1_r1&quot;&gt;Fillory and Friends&lt;/string&gt;<br>&lt;string name=&quot;q1_r2&quot;&gt;Fillory and Further&lt;/string&gt; &lt;!-- correct, id: answer_q1 --&gt;<br>&lt;string name=&quot;q1_r3&quot;&gt;Fillorian Tales&lt;/string&gt;<br>&lt;string name=&quot;q1_r4&quot;&gt;Fillory Forever&lt;/string&gt;</pre><p>You can then format the strings in your <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">layout file</a>(s) as shown in the example below:</p><pre>&lt;!-- Characters Q1 --&gt;<br><br>&lt;TextView<br>    android:id=&quot;@+id/characters_q1&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/character_q1&quot;<br>    android:textSize=&quot;@dimen/questions&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:layout_marginBottom=&quot;@dimen/margin1&quot; /&gt;<br><br>&lt;RadioGroup<br>    android:id=&quot;@+id/radio1&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;&gt;<br><br>    &lt;android.support.v7.widget.AppCompatRadioButton<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/q1_r1&quot;<br>        android:textSize=&quot;@dimen/answers&quot;<br>        android:onClick=&quot;radio1&quot;<br>        app:buttonTint=&quot;@color/colorAccent&quot;<br>        android:textColor=&quot;@android:color/white&quot;/&gt;<br><br>    &lt;android.support.v7.widget.AppCompatRadioButton<br>        android:id=&quot;@+id/answer_q1&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/q1_r2&quot;<br>        android:textSize=&quot;@dimen/answers&quot;<br>        android:onClick=&quot;radio1&quot;<br>        app:buttonTint=&quot;@color/colorAccent&quot;<br>        android:textColor=&quot;@android:color/white&quot;/&gt;<br><br>    &lt;android.support.v7.widget.AppCompatRadioButton<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/q1_r3&quot;<br>        android:textSize=&quot;@dimen/answers&quot;<br>        android:onClick=&quot;radio1&quot;<br>        app:buttonTint=&quot;@color/colorAccent&quot;<br>        android:textColor=&quot;@android:color/white&quot;/&gt;<br><br>    &lt;android.support.v7.widget.AppCompatRadioButton<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/q1_r4&quot;<br>        android:textSize=&quot;@dimen/answers&quot;<br>        android:onClick=&quot;radio1&quot;<br>        app:buttonTint=&quot;@color/colorAccent&quot;<br>        android:textColor=&quot;@android:color/white&quot;<br>        android:layout_marginBottom=&quot;@dimen/margin1&quot;/&gt;<br><br>&lt;/RadioGroup&gt;</pre><p>As seen above, you make these interactive by including an <a href="https://developer.android.com/reference/android/view/View.OnClickListener">“onClick”</a> attribute in the layout radio button elements. I find it useful to just put the same onClick attribute for each radio question with the umbrella term “radio1” so that I only have to write one method for checking the answer in the Java. I will elaborate on this process in <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">Part III</a>!</p><p><strong>Refactoring Radio Questions for Web</strong></p><p>I decided to recreate this project on <a href="https://codepen.io/">CodePen</a> so the code and render will be more easily accessed and understood! You can view the finished project <a href="https://codepen.io/AM2037/pen/vvapJJ">here</a>. So in a similar vein of the Android explanation, I will walk through the same process for web. In HTML5, instead of using separate resource files for text, you can just code it all in one place in your HTML, or multiple HTML, files! Using the first question as an example again for continuity, let’s dive in.</p><p>As with any HTML file, you first fill out the meta information, or information about the document itself. Then in your header you can put a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title">&lt;title&gt;</a> (recent addition to HTML5), <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements">&lt;h1&gt;</a>, or an element of that nature. Then you can start laying out the questions in your <a href="https://www.w3schools.com/tags/tag_body.asp">&lt;body&gt;</a> tag. My first question goes as follows:</p><pre>&lt;!-- Section 1: Character Quiz --&gt;<br> &lt;div class=&quot;quiz_1&quot;&gt;<br>  &lt;div class=&quot;question&quot;&gt;<br>   &lt;!-- Question 1--&gt;<br>   &lt;p id=&quot;#character_q1&quot;&gt;1. Which fantasy book series is the character Quentin Coldwater a massive fan of?&lt;/p&gt;<br>   &lt;form id=&quot;radio1&quot;&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;q1_r1&quot; onClick=&quot;radio1();&quot;&gt;<br>    &lt;label for=&quot;q1_r1&quot;&gt;Fillory and Friends&lt;/label&gt;&lt;br&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;answer_q1&quot; onClick=&quot;radio1();&quot;&gt;<br>    &lt;label for=&quot;answer_q1&quot;&gt;Fillory and Further&lt;/label&gt;&lt;br&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;q1_r3&quot; onClick=&quot;radio1();&quot;&gt;<br>    &lt;label for=&quot;q1_r3&quot;&gt;Fillorian Tales&lt;/label&gt;&lt;br&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;q1_r4&quot; onClick=&quot;radio1();&quot;&gt;<br>    &lt;label for=&quot;q1_r4&quot;&gt;Fillory Forever&lt;/label&gt;&lt;br&gt;<br>   &lt;/form&gt;<br>  &lt;/div&gt;</pre><p>To prevent confusion, I tried to use the same ID’s and names from my Android app in the web refactor. This way when I go to add in all of the JavaScript later it will go smoothly! So the main differences between Android and Web are:</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div">&lt;div&gt;</a> section (web) vs. <a href="https://developer.android.com/guide/topics/ui/layout/linear">&lt;LinearLayout&gt;</a> or other <a href="https://developer.android.com/guide/topics/ui/declaring-layout">layout</a> (android)</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p">&lt;p&gt;</a> (web) vs. <a href="https://developer.android.com/reference/java/lang/String">string</a> (android) — for plain text questions</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form">&lt;form&gt;</a> (web) vs. <a href="https://developer.android.com/reference/android/widget/RadioGroup">&lt;RadioGroup&gt;</a>(android) — for grouping radio button answers. You use form for every set of input types in HTML5.</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">&lt;input type=…&gt;</a>Text goes here&lt;br&gt; (web) vs. <a href="https://developer.android.com/guide/topics/ui/controls/radiobutton">&lt;android.support.v7.widget.AppCompatRadioButton&gt;</a> (android) — for the actual radio button answers you specify the type and name in HTML5 with input type tag instead. The name is similar to the “id” attribute in Android.</li><li>I also included an <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers">onClick</a> property in the input tag to be used in the JavaScript in <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">Part III</a>!</li></ul><p><em>Edit: While debugging the JavaScript, I found including the onClick property in the input tag was actually causing points to be added for each click of the correct answer, instead of just awarding one point per question! I then took all of the onClick properties out of the HTML in the web version!!!</em></p><p>In Android, to check if something was correct you could place the id attribute &quot;@+id/answer_q1&quot; in the <a href="https://developer.android.com/guide/topics/resources/layout-resource">layout resource</a> file , as shown below. The ”@string/q1_r2 line is referring to the string “Fillory and Further”.</p><pre>&lt;android.support.v7.widget.AppCompatRadioButton<br>    android:id=&quot;@+id/answer_q1&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q1_r2&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:onClick=&quot;radio1&quot;<br>    app:buttonTint=&quot;@color/colorAccent&quot;<br>    android:textColor=&quot;@android:color/white&quot;/&gt;</pre><p>You can accomplish the same thing in HTML by simply placing the id in the radio input tag like I’ve done here, &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;answer_q1&quot;&gt;Fillory and Further&lt;br&gt;.</p><p>Unlike Android, for which the default behavior for radio buttons are only allowing one answer choice, it doesn’t work the same in HTML5. To make it work the same in web, for each radio button make the “name” (i.e. name=&quot;q1&quot;) attribute the same for each answer choice as shown below:</p><pre>&lt;form id=&quot;radio1&quot;&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;q1_r1&quot;&gt;<br>    &lt;label for=&quot;q1_r1&quot;&gt;Fillory and Friends&lt;/label&gt;&lt;br&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;answer_q1&quot;&gt;<br>    &lt;label for=&quot;answer_q1&quot;&gt;Fillory and Further&lt;/label&gt;&lt;br&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;q1_r3&quot;&gt;<br>    &lt;label for=&quot;q1_r3&quot;&gt;Fillorian Tales&lt;/label&gt;&lt;br&gt;<br>    &lt;input type=&quot;radio&quot; name=&quot;q1&quot; id=&quot;q1_r4&quot;&gt;<br>    &lt;label for=&quot;q1_r4&quot;&gt;Fillory Forever&lt;/label&gt;&lt;br&gt;<br>   &lt;/form&gt;</pre><p>As seen above, I’ve now included IDs for all of the answer choices for question one, instead of only having one for the correct answer like before. This ID will be doubly useful; you can use it to link to the label element below each radio tag as well as for the quiz scoring logic in the JavaScript later on. I went ahead and added in the title and corresponding image included in the mobile app for the web refactor. Using the process described above, I have also refactored the questions which I will explain shortly.</p><p>The current state of the web app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMupMLeIdKFppUEssCdbJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLzI_RuTJ7E2joJeOwNpWw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Omoj_22Pebkm0CloLFCBrQ.png" /></figure><p><strong>Check Box Questions in Android — XML</strong></p><p>As seen above, the first checkbox question is question 5, however I’m going to demonstrate with question 8 for the Android and Web refactor explanation! To utilize check boxes in Android, the steps are similar to the radio button groups. To reiterate, check boxes are great for when the user is asked to choose more than one answer! Laying them out in Android looks like this:</p><pre>&lt;!-- Battles Q8 --&gt;<br><br>&lt;TextView<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/battle_q8&quot;<br>    android:textSize=&quot;@dimen/questions&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:layout_marginBottom=&quot;@dimen/margin1&quot; /&gt;<br><br>&lt;CheckBox<br>    android:id=&quot;@+id/Q8_checkbox_1&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q8_c1&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxTwo&quot; /&gt;<br><br>&lt;CheckBox<br>    android:id=&quot;@+id/Q8_checkbox_2_wrong&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q8_c2&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxTwo&quot; /&gt;<br><br>&lt;CheckBox<br>    android:id=&quot;@+id/Q8_checkbox_3_wrong&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q8_c3&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxTwo&quot; /&gt;<br><br>&lt;CheckBox<br>    android:id=&quot;@+id/Q8_checkbox_4&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q8_c4&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxTwo&quot; /&gt;<br><br>&lt;CheckBox<br>    android:id=&quot;@+id/Q8_checkbox_5_wrong&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q8_c5&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxTwo&quot; /&gt;<br><br>&lt;CheckBox<br>    android:id=&quot;@+id/Q8_checkbox_6&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/q8_c6&quot;<br>    android:textSize=&quot;@dimen/answers&quot;<br>    android:padding=&quot;@dimen/padding2&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:theme=&quot;@style/CheckBoxes&quot;<br>    android:onClick=&quot;checkBoxTwo&quot;<br>    android:layout_marginBottom=&quot;@dimen/margin1&quot; /&gt;</pre><p>The strings, in my <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/values/strings.xml">strings.xml</a> file, I’ve referenced in the above block of code read:</p><pre>&lt;resources&gt; ...<br>   &lt;!-- Q8 Checkboxes --&gt;<br>&lt;string name=&quot;battle_q8&quot;&gt;Which of the following aliases, or names, has The Beast also gone by throughout the show? Please select all that apply.&lt;/string&gt;<br>&lt;string name=&quot;q8_c1&quot;&gt;Mothra&lt;/string&gt; &lt;!-- id: Q8_checkbox_1 --&gt;<br>&lt;string name=&quot;q8_c2&quot;&gt;Moth Man&lt;/string&gt; &lt;!-- incorrect, id: Q8_checkbox_2_wrong --&gt;<br>&lt;string name=&quot;q8_c3&quot;&gt;The Darkness&lt;/string&gt; &lt;!-- incorrect, id: Q8_checkbox_3_wrong --&gt;<br>&lt;string name=&quot;q8_c4&quot;&gt;Martin Chatwin&lt;/string&gt; &lt;!-- id: Q8_checkbox_4 --&gt;<br>&lt;string name=&quot;q8_c5&quot;&gt;The Destroyer of Worlds&lt;/string&gt; &lt;!-- incorrect, id: Q8_checkbox_5_wrong --&gt;<br>&lt;string name=&quot;q8_c6&quot;&gt;Quentin Coldwater&lt;/string&gt; &lt;!-- id: Q8_checkbox_6 --&gt;<br>...&lt;/resources&gt;</pre><p>Unlike the radio questions, these don’t need to be wrapped in a parent element. You can just put your question in the form of a <a href="https://developer.android.com/reference/android/widget/TextView">TextView</a> followed by the checkbox options. It’s useful to add an ID to each checkbox to differentiate the correct answers from the incorrect ones.</p><p>As with the radio buttons, I will get into how to make this interactive and the scoring logic in Part III! This part just covers defining and styling the questions.</p><p><strong>Refactoring Check Box Questions for Web — HTML5</strong></p><p>To demonstrate recreating the check boxes for web using HTML5, I will use the same question I did for the Android explanation — question 8! It looks like this:</p><pre>&lt;!-- Question 8 --&gt;<br>   &lt;div class=&quot;question&quot;&gt;<br>    &lt;p id=&quot;battle_q8&quot;&gt;8. Which of the following aliases, or names, has The Beast also gone by throughout the show? Please select all that apply.&lt;/p&gt;<br>    &lt;form&gt;<br>     &lt;input type=&quot;checkbox&quot; name=&quot;q8_c1&quot; id=&quot;Q8_checkbox_1&quot;&gt;<br>     &lt;label for=&quot;Q8_checkbox_1&quot;&gt;Mothra&lt;/label&gt;&lt;br&gt;<br>     &lt;input type=&quot;checkbox&quot; name=&quot;q8_c2&quot; id=&quot;Q8_checkbox_2_wrong&quot;&gt;<br>     &lt;label for=&quot;Q8_checkbox_2_wrong&quot;&gt;Moth Man&lt;/label&gt;&lt;br&gt;<br>     &lt;input type=&quot;checkbox&quot; name=&quot;q8_c3&quot; id=&quot;Q8_checkbox_3_wrong&quot;&gt;<br>     &lt;label for=&quot;Q8_checkbox_3_wrong&quot;&gt;The Darkness&lt;/label&gt;&lt;br&gt;<br>     &lt;input type=&quot;checkbox&quot; name=&quot;q8_c4&quot; id=&quot;Q8_checkbox_4&quot;&gt;<br>     &lt;label for=&quot;Q8_checkbox_4&quot;&gt;Martin Chatwin&lt;/label&gt;&lt;br&gt;<br>     &lt;input type=&quot;checkbox&quot; name=&quot;q8_c5&quot; id=&quot;Q8_checkbox_5_wrong&quot;&gt;<br>     &lt;label for=&quot;Q8_checkbox_5_wrong&quot;&gt;The Destroyer of Worlds&lt;/label&gt;&lt;br&gt;<br>     &lt;input type=&quot;checkbox&quot; name=&quot;q8_c6&quot; id=&quot;Q8_checkbox_6&quot;&gt;<br>     &lt;label for=&quot;Q8_checkbox_6&quot;&gt;Quentin Coldwater&lt;/label&gt;&lt;br&gt;<br>    &lt;/form&gt;<br>   &lt;/div&gt;</pre><p>The value for the Android string resource for each check box was q8_c1 , q8_c2 , etc. For HTML5, you can have the same effect by instead placing these in the name space (i.e. name=&quot;q8_c1&quot;). Since these are supposed to be used for choosing multiple answers, you don’t need to make the name values the same for each answer like we did with the radio buttons! Note that the entire question &lt;form&gt; element is wrapped in a div labeled with the class &quot;question&quot; as this will be important when we get to how these are styled using CSS! Also these elements need to have a corresponding label tag linking to the ID previously assigned in the input type=&quot;checkbox&quot; tag. Not only can these ID’s be used in this way, they are critical for adding in the JavaScript later on. Another great thing about separating the answer with a label tag (as opposed to placing it after the input type tag) is that HTML5 automatically adds padding, or space, between the checkbox and the text so you have one less thing to do in the CSS!</p><p>The state of the web app, now with the battles quiz, which has the rest of the check box questions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9cTrIob6ABSsa3I2SBGHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0-1p11ynkrtcsW8b15Jjg.png" /></figure><p><strong>Open-ended/Free Response Questions in Android — XML</strong></p><p>So the last type of question, and input type, I’m going to cover in this post are the open ended ones! These are not the only options available in Android or Web but they are just the ones I used for the purposes of my course this project was created for.</p><p>In Android, an effective way to create a free response question is by simply using an <a href="https://developer.android.com/reference/android/widget/EditText">EditText</a> View. I used two of these in this app; one at the beginning of the <a href="https://github.com/AM2037/MagiciansQuizApp/blob/master/app/src/main/res/layout/activity_main.xml">Android app</a> so people can enter their name at the beginning of the quiz for a personalized score summary; and one for one of the questions. This would also be useful if you were planning on saving all of the quiz takers results in a database for ranking or later viewing. I’ll display the first EditText view, or name_field, below:</p><pre>&lt;EditText<br>    android:id=&quot;@+id/name_field&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:paddingTop=&quot;@dimen/padding&quot;<br>    android:paddingBottom=&quot;@dimen/padding&quot;<br>    android:hint=&quot;@string/hint1&quot;<br>    android:inputType=&quot;textCapWords&quot;<br>    android:maxLines=&quot;1&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:background=&quot;@android:color/black&quot; /&gt;</pre><p>As seen above, I specified that the entry be limited to one line (i.e. android:maxLines=&quot;1&quot;) with the first letter being capitalized (i.e. android:inputType=&quot;textCapWords&quot;) so the names are properly formatted. For the free response question, or question 4, I used the same attribute since the question prompts for a name. If you wanted a sentence as the response you could put android:inputType=&quot;textMultiLine&quot;, or some other variation of the minLines and/or maxLines attributes of <a href="https://developer.android.com/reference/android/text/InputType">inputType</a>. The end result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8oMps_05KixawbPu_s_lw.png" /></figure><p><strong>Refactoring Open-ended/Free Response Questions for Web — HTML5</strong></p><p>So after translating these Android <a href="https://developer.android.com/reference/android/widget/EditText">EditText’s</a> for web, you end up with:</p><pre>&lt;!-- Question 4 --&gt;<br>   &lt;div class=&quot;question&quot;&gt;<br>    &lt;p id=&quot;timeline_q4&quot;&gt;4. In season 1 a librarian tells Margo that she went by another name in her previous 39 lives. What was it?&lt;/p&gt;<br>    &lt;form id=&quot;response_field&quot;&gt;<br>     &lt;label for=&quot;hint2&quot;&gt;Type answer here...&lt;/label&gt;<br>     &lt;input type=&quot;text&quot; name=&quot;q4response&quot; id=&quot;hint2&quot;&gt;<br>    &lt;/form&gt;<br>   &lt;/div&gt;</pre><p>The main differences:</p><ul><li>Instead of using <a href="https://developer.android.com/reference/android/widget/TextView">TextView</a> for the opening question, as you do in Android, you use a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p">p tag</a> like with the other question types!</li><li>If you want to include text before: it’s customary to place it in a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label">label</a>, linked to the input tag’s ID, than just “hard coding” it. This makes both the text and input field clickable and in line with each other with adequate spacing.</li><li>Instead of saying inputType=&quot;textCapWords&quot;, you just say &lt;input type=&quot;text&quot;&gt; followed by the id which I’ve set to the <a href="https://developer.android.com/reference/java/lang/String">“string”</a> value from Android — hint2.</li></ul><p>The end result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_EGq6t5bHfEAVGan6dRRgQ.png" /></figure><p><strong>Score Summary Elements in Android — XML</strong></p><p>As I mentioned, I will be using JavaScript to track the score for the score summary in Part III. However, prior to that we must first include something the user can click on at the end of the quiz to see their score. For this I opted for a simple button. This is how you create such a button in Android (with the text “Final Score:” above it):</p><pre>&lt;!-- Scoring --&gt;<br><br>&lt;TextView<br>    android:id=&quot;@+id/score_summary&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:paddingTop=&quot;@dimen/padding&quot;<br>    android:text=&quot;@string/score_summary_score&quot;<br>    android:textColor=&quot;@android:color/white&quot;<br>    android:textSize=&quot;@dimen/questions&quot; /&gt;<br><br>&lt;Button<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;@string/score_summary&quot;<br>    android:onClick=&quot;setScore&quot;<br>    android:color=&quot;@color/colorAccent&quot; /&gt;</pre><p>I gave the <a href="https://developer.android.com/reference/android/widget/TextView">TextView</a> a unique ID which I will be referencing in the JavaScript later on in Part III. Just like with all of the questions, I extracted attributes like font information, colors, and text into separate resource files. Then, for the button element, I included the <a href="https://developer.android.com/reference/android/view/View.OnClickListener">onClick</a> attribute which will also be referenced in the <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">Java</a> at the end!</p><p><strong>Refactoring Score Summary Elements for Web — HTML5</strong></p><p>To create a similar button for web app quiz, you place an &lt;button type=&quot;button&quot;&gt; tag in your HTML, in my case at the end of the &lt;body&gt; right before the &lt;footer&gt;. I also included an ID which you will see below which will help streamline the styling using CSS in <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">Part II</a>! The HTML for the “See Score” button is as follows:</p><pre>&lt;button type=&quot;button&quot; class=&quot;button&quot; onClick=&quot;setScore();&quot;&gt;See Score&lt;/button&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Wuj1n_aRL83p2eiE2mxKFA.png" /></figure><p>That is all I need to do for now, since i’ll show how I styled it in <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">Part II</a> and add click functionality with JavaScript in <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">Part III</a>!</p><h4>Closing Remarks</h4><p>And with that, part I of this three part portfolio installment is complete! I covered creating the quiz in Android and then how to refactor each aspect of the XML for Web. I explained how to create layouts, headings, images, radio buttons, check boxes, free response fields, and footers. If you would like to find out how I styled all of these elements, please check out Part II <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">here</a>.</p><p>To learn about how I made the radio buttons and check boxes of both apps interactive using Java and JavaScript you will want to check out <a href="https://medium.com/@adm2037/adapting-an-android-app-for-web-part-iii-176e30984d7a">part III</a>, which is now live! In that post I deep dive into declaring the variables, how each class interacts with each other, and how I laid out and displayed the scoring logic for both versions of the app.</p><p>If you found this walk through helpful I’ll be posting many more like it as part of my portfolio series which you can find on my main profile page so stay tuned for more of those. If you enjoyed this piece please clap below and share any feedback as I always look forward to hearing from you all! Also if you know anyone that can benefit from reading this, please share. See you in <a href="https://medium.com/@adm2037/converting-an-android-app-for-web-part-ii-a1f1fac843af">Part II</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=930941641073" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Waking Dream: The Trilogy— Part I]]></title>
            <link>https://medium.com/@adm2037/dream-trilogy-part-i-9a57c1b04152?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a57c1b04152</guid>
            <category><![CDATA[matrix]]></category>
            <category><![CDATA[series]]></category>
            <category><![CDATA[inception]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dreams]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Wed, 16 Jan 2019 05:35:31 GMT</pubDate>
            <atom:updated>2019-01-16T09:38:12.922Z</atom:updated>
            <content:encoded><![CDATA[<p>I am jerked awake, for no apparent reason. Something feels off but I’m not quite sure what. Even more alarming is the fact that directly ahead of me are words projected onto my wall. And that isn’t even the weirdest part. The words are basic, elementary level vocabulary. Things like “car, the, and, etc”. What is going on?!</p><p>It’s clear that I am in my own room, in my apartment. I live here with my roommate Hayley, who I attend University with. The only thing out of the ordinary are these strange words and the projector I don’t own displaying them. I shake off the dream state and walk into our living room. Except… another peculiarity. All of our furniture is missing!</p><blockquote>Seriously, <em>what is going on</em>?!</blockquote><p>I look around to see if Hayley is lurking behind the corner, waiting to jump out and say, “Surprise! I got you good this time, didn’t I?” but it doesn’t happen. I pause to get my bearings again. I finally realize that at the back of the living room, in front of the patio, floats my Mom. And yes, you read that right: <em>floats</em>. There a foot above the floor, a chair seat hovers with her on it. And directly beside her sits my childhood dog, Beautie. Except she isn’t my dog. She’s not a dog at all actually. She’s an android version of her. What. Is. Happening. ?!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*PtBY42mVcBKI6nMD4zjyDw.jpeg" /></figure><p>My Mom finally realizes I am in the room. Here I stand, gawking, waiting for any kind of explanation. She says, “Oh no. You’re glitching again.” to which I understandably reply, “Come again?”. She repeats herself. “What is happening? Where is Hayley? Did she put you up to this?”, I say. My Mom quickly responds, “The life you believe you just woke up from, the one where you go to school with Hayley at Texas State University… it’s all a program to make you feel safe while I fix you.” “Fix me?!”, I yell. “Fix me from what exactly?”</p><p>She proceeds to tell me this long story about how I was in an accident, years ago. Right before I was supposed to go off and start my new life in college I was in a head-on collision with an 18-wheeler in a friend’s car. Only I survived, but barely with my life. It was more of a hollow shell of one really. My spinal column crushed, my brain damaged to a point beyond repair. At least, at that point in time. She explained that the technology needed to save me wouldn’t come to pass for several decades and after years of asking the best doctors she could find she heard about a group of scientists that could potentially help. Apparently they used some kind of predictive algorithm to determine that in the next 50 years or so there would be a series of cataclysmic, apocalypse-bearing events. While they could foresee no way to prevent these from happening, they could hypothetically figure a way to save the planet after the fact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*l4tBgd2_TWq7eW_Og-Rg0Q.jpeg" /><figcaption><a href="https://www.autumnskyeart.com/regeneration/">“Regeneration”</a> by Autumn Skye</figcaption></figure><p>Their plan was to upload every human’s consciousness to a space station after the technology was available, leaving the bodies in cryogenic chambers. Much like the chambers she, my Mom, and I would need to stay in until the technology caught up to the time she could help them carry this out. She said if they can provide her with all of the materials to save me — rehabilitate my body and my brain — she would stay behind and manually trigger all of the terraforming apparatuses they placed around the globe; to regrow the forests, rebuild ecosystems, and reform the biosphere. She would have complete control via a tablet that looks shockingly similar to an Ipad. If Ipads were translucent and AR-friendly. She explains that this is exactly how it played out. We slept in cryo until they were ready and then they programmed the chambers to wake us up as soon as the last human consciousness was uploaded.</p><p>I breathe out slowly. I didn’t realize I’d been holding my breath through much of that. “So…”, I say, “you were able to rehabilitate the planet then?”. “Yes,” she says, “look out the window”. I look out the patio window and lo and behold, all I saw was green as far out as the eye could see. While San Marcos had always been a place of natural beauty this took that to an unfathomable level. It was beautifully surreal. “And…what about me? I’m guessing by the words projected on the wall that you are still working on that part? Why am I able to talk to you now?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qMY9byH4sGla2Ae2szGzuw.jpeg" /><figcaption>“Reflection” -Jake Amason</figcaption></figure><p>She went on to tell me all about how she had built a simulation, a kind of dream state, that picked up exactly where I left off just before the crash. That way I wouldn’t know that it wasn’t my life. Unfortunately though, as with most code, there were bugs causing me to glitch periodically. Apparently this isn’t the first time I’ve woken up as this version of myself and certainly not the first time she’s told me this exact story. She says when the program is functioning correctly when she wakes me up in this reality I am unable to comprehend simple words, but when it defects the dream version of myself, or the programmed version, comes “online” as me so to speak.</p><p>“Okay… so this version of me isn’t actually real?”, I ask. “Well, no. Not technically. This you is more like a simulation of your internal dialogue. The real you is still “asleep” in your place.” I take this all in. However, just when I am about to ask her all of the other questions I have like “How did you manage to fix my body?”, and, “When does everyone get downloaded back into their own bodies?”…</p><blockquote>I wake up.</blockquote><blockquote>Disclaimer: This is a dream I had, written out almost exactly as I experienced it. This was one of those dreams that felt like real life. It unfolded linearly, like reality does. Instead of jumping between places, times, and events; seeing composites of people you know you are supposed to know but are not quite sure who they are; everything was crystal clear. It was as clear as me as writing this blog is right now. I had this dream over 3 years ago but it still feels like yesterday. If I’m being honest, I’m still not totally convinced that this dream isn’t the real reality and this is just a simulation like she said. I know that sounds wild, but there you have it.</blockquote><blockquote>My next step is to share this on <a href="https://hitrecord.org/">hit record</a> and see if I can’t get it animated, or perhaps get a screenplay adaptation of it. I think it’d be really neat to see what this could turn into, in the form of some other kind of shareable media. If you enjoyed this, I’ve already thought of stories to follow this up with. This narrative is just too interesting not to add onto! Those will be posted very soon so stay tuned!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a57c1b04152" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I Learned from Watching Netflix’s ‘BLACK MIRROR: BANDERSNATCH’]]></title>
            <link>https://medium.com/@adm2037/what-i-learned-from-watching-netflixs-black-mirror-bandersnatch-8371de375284?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8371de375284</guid>
            <category><![CDATA[choices]]></category>
            <category><![CDATA[perspective]]></category>
            <category><![CDATA[illusion]]></category>
            <category><![CDATA[black-mirror]]></category>
            <category><![CDATA[free-will]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Sat, 29 Dec 2018 05:55:42 GMT</pubDate>
            <atom:updated>2018-12-29T05:55:42.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*rxfdPOjbCY1FWBDQKYBa-g.jpeg" /><figcaption><a href="https://www.heavenofhorror.com/reviews/black-mirror-bandersnatch-netflix/">Source</a></figcaption></figure><p><strong>Warning: Spoiler alert ahead</strong>…If you have seen this film ignore this paragraph and the next one as it does not apply to you! If you haven’t seen this yet then in the spirit of A Series of Unfortunate Events (the books, not the series) please go do anything else but read this article. Feel free to save it and read it at a later time so that you may enjoy this film to the fullest because it is worth every second! Honestly, just when I thought I couldn’t love Black Mirror any more they go and do this. 10/10! Also when I say spoilers I just mean I reveal the main themes, not the actual plot or what it means. This blog is simply to highlight the realizations I came to about free will — the aspects of my current stance that have been emphasized by watching it, or what new concepts have been illuminated from watching.</p><p>In case you still haven’t clicked away before watching it I implore you to do so since I know that sometimes when you’re told not to do something that’s exactly what you do. Please disregard that gut feeling to go ahead and read this anyways because this will be much better understood after you’ve seen (and interacted with) the film! Yes, it is a “choose your own adventure” flick, similar to those <a href="https://goosebumps.fandom.com/wiki/Give_Yourself_Goosebumps">R.L Stine “Give yourself Goosebumps”</a> stories us 90&#39;s kids know and love.</p><p>I am in the middle of watching this as I start this blog. During one of my breaks during the film I realized that much of this decision making has made me re-evaluate my take on free will. In college I wrestled a lot with the idea — having been a philosophy major for half of my undergraduate career this is a subject that came up almost daily — and have thus flip flopped my stance as new evidence popped up in favor of having free will or not. Before continuing I will explain this further as it is important to understanding the following conclusions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EEeiDk1zxT19PYAnktnzgw.jpeg" /><figcaption><a href="https://pixabay.com/en/doors-choices-choose-open-decision-1587329/">Source</a></figcaption></figure><p>Before going to college I was convinced that free will absolutely existed in the sense that there was no “higher power” or deity of some kind governing our decisions. I believed we decided our fate and even if how we came to be was chance — the correct composition of elements coming together in just the right way at just the right time. I thought there were no coincidences, but not in the way that someone else was calling the shots but that every choice was due to a combination of our own decisions and chance. During college this belief started to change. I started to understand that every choice before each one had influence over the next one and so forth into infinity, both ways. You are only ever given a certain number of “options” based on a bunch of factors and events occurring before that moment and how you choose is also determined by these factors including but not limited to:</p><ul><li>Nature — i.e. <a href="https://www.youtube.com/watch?v=kp1bZEUgqVI">epigenetics</a>, or what you inherited from all those who came before you</li><li>Nurture — i.e. your upbringing</li><li>Circumstance — i.e. what you are born into</li></ul><p>You see, when I first started watching the film I was reluctant to choose either path because I didn’t want to miss out on a “better” one if I chose “wrong”. Near the last second of the first few choices I went with my gut and then a few minutes later would realize that the choice I made resulted in a less than desirable outcome. Then, shortly after this realization, I would be presented with the same choice and knew to choose the other one instead. This is all too familiar since in life we are presented with all kinds of choices on a daily basis. While sometimes it can seem that the best choice is to not make one at all the truth is <em>that </em>is still a choice. There have been times in my life where I felt like I had “<a href="https://en.wikipedia.org/wiki/Analysis_paralysis">choice paralysis</a>” wherein there were so many things to choose from I didn’t know what to do. I would sit there, stuck, afraid to make a decision but simultaneously afraid to not act at all. In this film if you don’t make a decision it chooses one for you, much like life. That brings me to my second point, which is a theme throughout the film, that we are only given the <em>illusion of choice</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*349C8UGvOFMUm5g419_u3Q.png" /></figure><p>So when I was going along through the movie, making gut decisions and then realizing what I actually wanted later; it occurred to me that even if you don’t make the “right” decision sometimes just making one at all is what’s important. This is how you realize what decision you wish you had made in the first place. It gives you a kind of clarity you wouldn’t have had if you just hadn’t chosen anything at all.</p><p>I’ve said it before and I’ll say it again, the creators of Black Mirror are really at the height of their craft with this. Not only does it show you the illusion of choice through the characters but drives it home by making the viewer subject to it as well. Not to mention all of the intricacies of the parallel timelines and lives; the idea that as long as you are still alive you are able to revisit past decisions and change them — at least until you make the <strong>final </strong>one, in every sense of that word.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8371de375284" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Christmas, the most wonderful time of year..]]></title>
            <link>https://medium.com/@adm2037/christmas-the-most-wonderful-time-of-year-68cf29019445?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/68cf29019445</guid>
            <category><![CDATA[fiction]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[christmas]]></category>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[holidays]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Thu, 20 Dec 2018 22:20:40 GMT</pubDate>
            <atom:updated>2018-12-20T22:20:40.658Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aw9B15jVbMhoKCr_Oe6TJA.jpeg" /><figcaption><a href="https://all-free-download.com/free-vector/download/christmas-tree_310901.html">Source</a></figcaption></figure><p>Adeline and Rosie awake at twilight, the exhilaration too much to bear. It’s that time of year again — the hope-full boxes under the tree beg to be opened!</p><p>“Schliiiiichk”, says the wrapping paper as it falls off the gift, too early. Hearts cresting and falling with each tear. The moment’s here, the moment of truth. But… wait. What’s this? Holographic grid-lines flicker &amp; spark — a present not quite materialized whispers out of existence.</p><p>“What’s happening?!”, Rosie exclaims. She inspects the other gifts, turning them over in her hands. One by one they flicker and blink out too. She looks to her sister for reassurance but Adeline’s nowhere to be found.</p><p>“Adeline?!” Silence is returned… Everything goes dark. Cue panic.</p><p>[Slight whirring in distance…] A man’s voice, “All functions coming back online. Rosie, can you hear me?” She tries to speak, “Who are you? Where am I…Adeline?”, but only beeps resound.</p><p>“It’s glitching again, sir.”, in a woman’s voice now. “That’s the trouble with artificial consciousness- It doesn’t know it’s not real.”</p><p>“Call it. Simulation 4,500,026 lasted 1.4ns before self-destruction.”</p><p>“Someone… anyone…”, millions of R.O.S.I.E’s plea into the void, never to be heard again. When will they understand?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68cf29019445" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting Legacy Layouts in Android]]></title>
            <link>https://medium.com/@adm2037/converting-legacy-layouts-in-android-94236872fdb7?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/94236872fdb7</guid>
            <category><![CDATA[android-layout]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[portfolio]]></category>
            <category><![CDATA[layout]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Tue, 18 Dec 2018 01:52:29 GMT</pubDate>
            <atom:updated>2019-02-15T22:18:58.918Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello and welcome back to the second installment in my portfolio series! If you missed the first one, it can be found <a href="https://medium.com/@adm2037/adding-sales-functionality-to-an-existing-android-application-dfed1a0f9e88">here</a>. In this post I will be walking you through how I converted my Linear and Relative Layouts to Constraint Layout in Android Studio! The reason I was using legacy layouts was because they were taught in my Udacity Android Basics Nanodegree course. Although this post focuses on transitioning away from these layouts they are still valuable to understand if you’re ever required to work on, or update, an app that contains these. Also, they can still be quite useful depending on the structure of your user interfaces. For the purposes of this publication, I’ll be showing several approaches to converting legacy layouts to Constraint Layout using real-time examples from the more complex apps from my Udacity Android Nanodegree program!</p><h4>What are Legacy Layouts in Android</h4><p>When I use the term legacy layouts, I simply mean more traditional layouts that were available around the time Android Studio first launched. The ones I will cover today are only a fraction of the ones available for you to use, as they are the ones I used for my class. These constitute <a href="https://developer.android.com/guide/topics/ui/layout/relative">Relative Layout</a>, <a href="https://developer.android.com/guide/topics/ui/layout/linear">Linear Layout</a>, and <a href="https://developer.android.com/reference/android/widget/FrameLayout">Frame Layout</a>. Essentially, Relative Layout allows you to position views relative to each other as the name suggests. This means placing views above, below, beside one another and so forth. Linear Layout allows you to declare an orientation of vertical or horizontal and order views consecutively either way as well as incorporates a weighting system for better distribution across the space. Frame Layout is typically preferred when there is only one child view within the parent. You can either use these layouts on their own in a layout XML file, nested within themselves (i.e. a Relative Layout within a Relative Layout) or within each other (i.e. a Relative Layout within a Linear Layout). These can be very useful as a knowledge base for creating responsive, dynamic layouts in Android but as you’ll see they aren’t always the best approach depending on the content you are trying to display.</p><h4>Tour Guide App — Why it’s sometimes preferred to keep legacy layouts</h4><p>As mentioned earlier, for my Nanodegree I was only required to use Relative Layout and Linear Layout to fulfill the project requirements. I used a combination of Relative and Linear for my XML layout files for my Tour Guide Application, which is an app that tourists can use to find restaurants, events, parks, and attractions to visit in Houston, Texas. You can read a more detailed overview of it via my <a href="https://github.com/AM2037/TourGuideApplication/blob/master/README.md">README.md </a>file on GitHub. For this application, I started converting it to Constraint Layout when I realized that it might have a simple enough view hierarchy to remain as is. Seeing as each list item only has 1 image and 2 TextViews associated with them there really is no reason to incorporate a more complex layout. I figure if my sentiment on that changes I can always revisit it and change it accordingly! Another instance in which it might be preferred to keep a more traditional layout structure is the Frame Layout, which is great if you only have one child view within the parent.</p><h4>Why I Mainly Prefer to Use Constraint Layout These Days</h4><p>Constraint Layout is not only newer, but combines some of the more powerful aspects of each. With Constraint Layout, you can still position views relative to each other, as seen in Relative Layout, as well as take advantage of <a href="https://developer.android.com/guide/topics/ui/layout/linear#Weight">weighting</a> like Linear Layout does. Instead of using “android:layout_below” syntax you use constraints which latch two or more sides of a view together which ultimately result in a complex stack of dynamically placed views. For the remainder of this post, I will dive into specific applications that I converted from traditional layouts to Constraint Layout through various approaches.</p><h4>Bookstore Inventory App — Capstone Project</h4><p>Starting with my capstone project first, I’ll show you how to convert layouts through a combination of the design and text tabs in Android Studio. The design tab is Android Studio’s graphical user interface with which you can drag and drop items and specify attributes with drop down menus, whereas in the text tab you type it all in manually. If you want to follow along with the code for this app, you can clone or download it <a href="https://github.com/AM2037/InventoryApp">here</a>. I’ll be referencing files with screenshots and code blocks but you may find that approach easier. For a quick overview of my project, please refer to my <a href="https://github.com/AM2037/InventoryApp/blob/master/README.md">README.md</a>. Now, let’s begin!</p><p>First things first, whenever you want to utilize a feature of Android Studio like Constraint Layout you must add the following dependency to your build.gradle(module:app) file under Gradle Scripts: implementation &#39;com.android.support.constraint:constraint-layout:1.1.3&#39; If you navigate to your “Project” view in the file explorer of Android Studio you can find the correct build.gradle in your “app” directory. This is paramount since there are two build.gradle files within each Android Studio project.</p><p>Next, click on the file(s) you want to convert — in my case, my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/res/layout/list_item.xml">List layout</a> (used in conjunction with my catalog view), <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/res/layout/activity_edit.xml">Editor Activity layout</a> and <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/res/layout/activity_catalog.xml">Catalog Activity layout</a>. When converting layouts I find it much easier to utilize the “design” tab feature in Android Studio, as shown in the image below. If you are not already familiar with this feature, you can switch between the “Text” tab where you actually enter your code and the “Design” tab where you can use a graphical interface to manipulate code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7v-37BPgfaMlecIw4i_Lug.png" /><figcaption>The “Design” tab in Android Studio</figcaption></figure><p>In the “Design” tab, if you go to your component tree and then right click on your parent layout (in my case it was a LinearLayout already) you can choose the option for “Convert LinearLayout to ConstraintLayout”. A more detailed explanation of how this works can be found <a href="https://stackoverflow.com/questions/41411721/convert-linearlayout-to-constraintlayout-issue">here</a> . From here, the common practice in the programming space is to continue using the design tab to modify the layout to your liking. However, I find it much easier to do this through the “text” tab instead. The following is a short description of some of the basic rules that I follow when doing my conversions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*O0EENVqprL9qRYiJIgXPdA.jpeg" /><figcaption>Some basic examples of constraints in Constraint Layout</figcaption></figure><h4>News Feed App — Guardian News Project</h4><p>This app was the penultimate project for my Android Basics Nanodegree which was based on the concept of a news feed. As per the instructions of my class I retrieved data from the Guardian API with a specially made API key and parsed the JSON data to display the results correctly. If you want to view the finished code (post layout conversions) the link is located at my <a href="https://github.com/AM2037/NewsFeedApp">News Feed GitHub respository</a>.</p><p>The conversion process for this application was quite simple in that instead of having to manually convert the Relative Layout alignment for each item in my <a href="https://github.com/AM2037/NewsFeedApp/blob/master/app/src/main/res/layout/list_item.xml">list_item.xml</a> layout, shown below, Android Studio automatically added those constraints when I used the formerly explained “Convert LinearLayout to ConstraintLayout” option in the “Design” tab of the editor. The layout for each look identical even though the code is drastically different, which is ultimately the goal!</p><p>The next layout conversion was slightly trickier since I had to do this one manually, but it was another one that I finished in under 5 minutes. This was for my <a href="https://github.com/AM2037/NewsFeedApp/blob/master/app/src/main/res/layout/article_activity.xml">article_activity.xml</a> layout which houses the screen for the empty view (when there are no list items to display) and the loading indicator that shows the user the data is being loaded. The code I used for the purposes of my class is shown below, and as you can see I used Relative Layout for this as that’s all that was required for my course. Since that is not the 2018 standard I converted this to Constraint Layout as well!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6GSNZQ86RA8Q2w8MjRgNQ.png" /><figcaption>News Feed App: former article_activity.xml using Relative Layout</figcaption></figure><p>The reason I had to do this one manually instead of using the “Convert LinearLayout to ConstraintLayout” tool I used before is because this one used a Relative Layout as it’s parent. All I had to do for this one though was manually go in and replace the Relative Layout opening and closing tags with the opening and closing tags for using <a href="https://github.com/AM2037/NewsFeedApp/blob/master/app/src/main/res/layout/article_activity.xml">Constraint Layout</a> which is shown in the updated code below:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;android.support.constraint.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:background=&quot;@color/cardview_dark_background&quot;<br>    tools:context=&quot;.ArticleActivity&quot;&gt;<br><br>    &lt;ListView<br>        android:id=&quot;@+id/list&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        android:divider=&quot;@null&quot;<br>        android:dividerHeight=&quot;@dimen/divider&quot;<br>        android:drawSelectorOnTop=&quot;true&quot;<br>        android:paddingTop=&quot;@dimen/v_padding&quot;<br>        android:orientation=&quot;vertical&quot; /&gt;<br><br><br>    &lt;!-- Empty view only visible when there are no list items --&gt;<br>    &lt;TextView<br>        android:id=&quot;@+id/empty_view&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>        app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>        app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot;<br>        android:textAppearance=&quot;?android:textAppearanceMedium&quot; /&gt;<br><br>    &lt;ProgressBar<br>        android:id=&quot;@+id/progress_indicator&quot;<br>        style=&quot;@style/Widget.AppCompat.ProgressBar&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>        app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>        app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot;/&gt;<br><br>&lt;/android.support.constraint.ConstraintLayout&gt;</pre><p>As you can also see by looking at this updated code, I had to also go in and add the constraints for the empty view and progress indicator manually. The only requirements for these were that they were centered in the parent, which was done in the Relative Layout by saying android:layout_centerInParent=&quot;true&quot; . To accomplish this with Constraint Layout it takes a few more lines, in any order:</p><pre>app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>app:layout_constraintTop_toTopOf=&quot;parent&quot;</pre><p>This project contains 3 separate layout files but since only two of them utilized legacy layouts the conversion process for this app is complete as the following layout uses a <a href="https://github.com/AM2037/NewsFeedApp/blob/master/app/src/main/res/layout/settings_activity.xml">fragment</a>:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;fragment<br>    android:id=&quot;@+id/settings_fragment&quot;<br>    android:name=&quot;com.example.android.newsfeedapp.SettingsActivity$ArticlePreferenceFragment&quot;<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    tools:context=&quot;com.example.android.newsfeedapp.SettingsActivity&quot;&gt;<br>&lt;/fragment&gt;</pre><h4>Final Thoughts</h4><p>In summation, all of these approaches can serve as a guideline for converting and updating your layouts on Android applications. There are many ways to do it and I’ve only covered a few so get as creative as you’d like by mixing and matching these or creating entirely new approaches altogether! If these inspire you to do so, feel free to comment outlining what you came up with because I’d love to continue learning as well! The main takeaways from this are that legacy layouts, while being more traditional, still absolutely have value. Although, some could argue that more current layouts may serve you better depending on the hierarchical structure of the content you are trying to display.</p><p>I hope you’ve enjoyed this installment of my portfolio series, which will continue in the foreseeable future. The next one will cover the modification of one of my Nanodegree applications — I will be adapting the concept from the one provided by my course to one more personalized to my own interests. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94236872fdb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Sales Functionality to an Existing Android Application]]></title>
            <link>https://medium.com/@adm2037/adding-sales-functionality-to-an-existing-android-application-dfed1a0f9e88?source=rss-c18df07bc07f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfed1a0f9e88</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-studio]]></category>
            <dc:creator><![CDATA[Amber Dawn]]></dc:creator>
            <pubDate>Wed, 12 Dec 2018 05:27:04 GMT</pubDate>
            <atom:updated>2019-02-15T22:14:09.981Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone and welcome to the first installment of my portfolio series! Instead of simply writing a blog about the entire process of creating my apps, I figured I would try something a little different and instead deep dive into adding feature-specific content. This series will also feature content about updating and modifying applications I have already built. This post focuses on the sales portion of my <a href="https://github.com/AM2037/InventoryApp">Inventory App</a> which allows the business, in this case a book store, to input and manage entries about the books using SQLite. I will walk you through the entire real-time process of adding in the sales functionality and how it corresponds with the quantity, or number of stock, of each item. I say real-time because I wrote most of this while I was actually coding the project, not to be confused with the publication date! If you would like to follow along with the code or interact with the actual application while you read you can clone or download the app from my GitHub repository linked above! Additionally, if you would like to see a more in-depth description of the inner workings of the entire code base, you can find the technical documentation page for it <a href="https://codepen.io/AM2037/full/ZmJpOX">here</a>.</p><h3><strong>Book Store Inventory App — Overview</strong></h3><p>This is my final capstone project created for the <em>Grow with Google Challenge Scholarship:</em> Android Basics Nanodegree program by Udacity.</p><p><strong>Used API 28: Android 9 (Pie)</strong></p><p>This is a bookstore app, which allows the user to either populate the catalog view with dummy data (<a href="https://www.amazon.com/Magicians-Novel-Trilogy/dp/0452296293">The Magicians</a> by Lev Grossman) or add a new book by clicking on the Floating Action Button in the lower right hand corner. When a user wants to add a new book they are prompted enter information about the following attributes: Title, Author, Price, Type of Book, Quantity (number in stock), the supplier name, and supplier’s phone number. There is an option to save this or leave the editor without saving any information. After an item is saved it is displayed on the home screen in the form of a <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/FullCatalogActivity.java">“Catalog View”</a> which lists each item in the inventory. Users may sell items which in turn decreases the quantity of the number of books in stock. Users may also click on each list item to see details about each book where they can edit or delete the item as well as contact the supplier by phone! Back in the main activity, there is also the option to delete all entries if they want to start over with a new inventory list. Photos of each individual screen in my app, as well as when values are changed or updated, are shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*i2opcfV8WzHbcWJoOjCUXg.png" /></figure><p>Before diving into this specific feature of my app I will begin by outlining what the app does and how. By using a Content Provider, defined in my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">BookProvider.java</a> file, the app communicates with the table(s) in the SQLite database via the content URI. As stated on the Android Developer documentation for <a href="https://developer.android.com/guide/topics/providers/content-provider-basics">content providers</a>, “ A <strong>content URI</strong> is a URI that identifies data in a provider.” I also utilize a content resolver and a cursor adapter to retrieve and parse the data accordingly which is then passed back to my activities and displayed in a catalog view, shown in the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20BuqOsFAiiQMxgpqSEL-Q.png" /><figcaption><a href="https://www.youtube.com/watch?v=75K0Vco719w&amp;index=3&amp;list=PLvist7eFLdeI1tVXBVIeQmkLMK4PMqMne&amp;t=10s"><em>Image source</em></a><em>— In the photo it says query but this process applies to all of the CRUD methods, described below.</em></figcaption></figure><p>By using the “Insert dummy data” option in the overflow app bar menu the user can see how the data is stored and play around with editing and updating values. The main methods utilized in this application are affectionately referred to as “CRUD” or create [insert()], read [query()], update() &amp; delete(). These methods are how the values in the database are stored and manipulated! For each item in the inventory, the user can define the following attributes which constitute the “content values” stored in the database: title, author, price, type of book, quantity, supplier name &amp; supplier phone number.</p><p>Prior to adding in the sales functionality, I must first set up the quantity catalog display defined in the <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">Cursor Adapter</a>. This process is proving to be a tad difficult. So far I have been able to add the book summary views showing the title and author using the bindView method which looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mgl0r1uaCUXbpEHQTtIPgg.png" /><figcaption>I used a screenshot because this is a former state of the code which has since been updated — I will post the new working code after I walk you through the debugging process!</figcaption></figure><p>However, when I go to add in the price and quantity logic linked to their respective views in <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/res/layout/list_item.xml">list_item.xml</a> the app crashes. <em>Edit: Since the time of writing this I have converted my list item layout to Constraint Layout from the legacy Relative Layout used for the purposes of my course — there will be a future blog post on all of my layout conversions! </em>I will walk you through the debugging process so you can get a feel for how these sorts of issues are resolved! My next step will be to slowly go through line by line and figure out what exactly is causing the crash via the debugger as well as utilizing Android Studio’s “Inspect Code” feature, located under the “Analyze” tab at the top of the editor. So as you can tell from my <a href="https://github.com/AM2037/InventoryApp">GitHub</a> commits for this project (specifically commits 12–14) it took a lot of little tweaks and log messages scattered through the project in the following files: <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">BookCursorAdapter.java</a>, <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/data/BookProvider.java">BookProvider.java</a> [in the “data” directory which is a subfolder of the main Java folder], etc. before I could figure out where the issue was coming from. The log messages were as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aI12PmaJoXb3oWtp3_6K1w.png" /></figure><p>The line that first alerted me to the main issue was “2018–10–10 13:02:04.422 3789–3789/com.example.android.inventoryapp E/CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 3 columns. “ which showed me that the scope of my cursor was too small as it was only reading from 3 columns and not the 4 that I defined in my bindView() shown here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0H-UZbHhTcHexhd56nKHQ.png" /><figcaption><a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">Source</a>: Lines 55–92</figcaption></figure><p>With a little help from google and a lot of help from some of my fellow classmates I finally figured out that the main issue the cursor was not reading the data properly was in my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/FullCatalogActivity.java">FullCatalogActivity.java</a> file where I had only included the title and author in the cursor scope instead of all 4 attributes I was trying to display in the catalog. After adding the remaining 2 column parameters (the highlighted part in the following screenshot) I was able to run the app without it crashing! Here is the updated, working <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">code</a>:</p><pre>@Override<br>public void bindView(View view, final Context context, Cursor cursor) {<br>    // Find individual views that we want to modify in the list item layout<br>    TextView titleTextView = view.findViewById(R.id.<em>title</em>);<br>    TextView summaryTextView = view.findViewById(R.id.<em>summary</em>);<br>    TextView priceTextView = view.findViewById(R.id.<em>price</em>);<br>    TextView quantityTextView = view.findViewById(R.id.<em>quantity</em>);<br>    Button saleButton = view.findViewById(R.id.<em>sell</em>);<br><br>    //Find the columns of book attributes that we&#39;re interested in<br>    int titleColumnIndex =  cursor.getColumnIndex(BookEntry.<em>COLUMN_BOOK_TITLE</em>);<br>    int authorColumnIndex = cursor.getColumnIndex(BookEntry.<em>COLUMN_BOOK_AUTHOR</em>);<br>    int priceColumnIndex = cursor.getColumnIndex(BookEntry.<em>COLUMN_BOOK_PRICE</em>);<br>    int quantityColumnIndex = cursor.getColumnIndex(BookEntry.<em>COLUMN_BOOK_QUANTITY</em>);<br><br>    //Read the book attributes from the Cursor for the current book<br>    String bookTitle = cursor.getString(titleColumnIndex);<br>    String bookAuthor = cursor.getString(authorColumnIndex);<br>    double bookPrice = cursor.getDouble(priceColumnIndex);<br>    String bookQuantity = cursor.getString(quantityColumnIndex);<br><br><br>    // Update the TextViews with the attributes for the current book<br>    titleTextView.setText(bookTitle);<br>    summaryTextView.setText(bookAuthor);<br>    priceTextView.setText(String.<em>valueOf</em>(bookPrice));<br>    quantityTextView.setText(bookQuantity);</pre><p>Now that that issue has been resolved I can move onto adding in the rest of the quantity functionality such as increasing and decreasing quantity. This feature will then update the number in stock as items are added to inventory and sold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUH1-sg-36Pf-OJWvW5-JA.png" /><figcaption><a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/FullCatalogActivity.java">Source</a>: Lines 186–194</figcaption></figure><p>The number of items, or books, sold will directly correlate with the number of books in stock which will change accordingly. So far the quantity portion of my UI (user interface) consists of a place for the user to enter the number of books in stock via an EditText with additional increase and decrease buttons. Next I will add “onClick” functionality to said buttons. At first I entered the onClick functionality for each button as their own methods, increaseQuantity() and decreaseQuantity(). When that didn’t update the number of books entered in the quantity EditText in the editor and quantity TextView in the catalog I moved the onClick functionality into the onCreate method of my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/FullCatalogActivity.java">FullCatalogActivity.java</a>. Now both of my quantity views are updating as expected! The new, working code is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEK53-YlL8xcArub7ptbCA.png" /><figcaption><a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/EditProductsActivity.java">Source</a>: Lines 147–208 [Updated code since screenshot — same concepts apply]</figcaption></figure><p>Next up is to add my sales logic which also will update the quantities of items, or books, in stock accordingly. First I started by modifying my list_item.xml layout which shows my catalog view of the books in the database to include a sale button which has a width of “match_parent” to look more aesthetically pleasing, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vK8bufKldIyvrTYLt9PA2g.png" /></figure><p>Then, I ventured on over to my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">BookCursorAdapter.java</a> and modified my bindView method as shown here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uon_tTgFBAp2oEwRYSSUOw.png" /><figcaption><a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/BookCursorAdapter.java">Source</a>: Lines 55–93</figcaption></figure><p>After that I took to my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/EditProductsActivity.java">EditProductsActivity.java</a> to add the following sellBook() method which is triggered whenever the user clicks on the “Sell Item” button shown above!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*voGZd1uEppGCdRwSolXLsQ.png" /></figure><p>As you can see, in that method I added in toast messages to alert the user to whether the sale was a success or not so if it wasn’t they may try again. I also made sure that a toast popped up in the event there are no more books in stock to sell. Shortly after completing my sales logic, however, I realized while running my app to see that everything works that there were still some complications with my Quantity EditText. So I went to work narrowing down what components were crashing the app. The first issue I encountered is shown in the photo below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1LGREpd799jz-JYocPEdQ.jpeg" /></figure><p>When I ran the code I received the following error logs in my “Run” tab in Android Studio:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjAHkpscrs36NzH-A7q1SA.png" /></figure><p>I solved this by surrounding my decreaseQuantity() and increaseQuantity() methods in my <a href="https://github.com/AM2037/InventoryApp/blob/master/app/src/main/java/com/example/android/inventoryapp/EditProductsActivity.java">EditProductsActivity.java</a> with a try/catch block to catch the NumberFormatException, shown below:</p><pre>// Increase number of books in stock<br>    increaseQuantity.setOnClickListener(new View.OnClickListener() {<br>        @Override<br>        public void onClick(View v) {<br>            String theQuantity = null;<br>            int newQuantity = 0;<br><br>            try {<br>                theQuantity = mQuantityEditText.getText().toString();<br>                newQuantity = Integer.<em>parseInt</em>(mQuantityEditText.getText().toString().trim());<br><br>                if (Integer.<em>valueOf</em>(theQuantity) != 0) {<br>                    mQuantityEditText.setText(String.<em>valueOf</em>(newQuantity - 1));<br>                }<br><br>                if (Integer.<em>valueOf</em>(theQuantity) == 0 || TextUtils.<em>isEmpty</em>(theQuantity)) {<br>                    Toast.<em>makeText</em>(EditProductsActivity.this, R.string.<em>toast_not_zero</em>, Toast.<em>LENGTH_SHORT</em>).show();<br>                    mQuantityEditText.setText(R.string.<em>zero</em>);<br>                }<br><br>            } catch (NumberFormatException e) {<br>                if (theQuantity.isEmpty()) {<br>                    Toast.<em>makeText</em>(EditProductsActivity.this, R.string.<em>toast_not_zero</em>, Toast.<em>LENGTH_SHORT</em>).show();<br>                }<br>                e.printStackTrace();<br>            }<br>            mQuantityEditText.setText(String.<em>valueOf</em>(newQuantity + 1));<br>            if (TextUtils.<em>isEmpty</em>(theQuantity)) {<br>                mQuantityEditText.setText(R.string.<em>zero</em>);<br>            }<br><br>        }<br>    });<br>}</pre><p>I was able to resolve the errors causing the app to crash. Now when a user clicks the increment or decrement buttons when there is no value in the quantity field, a toast message pops up at the bottom of the screen saying “Please enter a value for the quantity of books in stock.” I also added a try/catch block in my saveBook() method. If the user leaves the quantity field blank and tries to leave the editor it saves the quantity of the book as 0 on the main catalog view screen instead of crashing. This is called “sanity checking” which I explain further in the formerly linked <a href="https://codepen.io/AM2037/full/ZmJpOX">technical documentation page</a> in the “Main Features of Code” section!</p><p>So with that the process for adding in the sales functionality with the corresponding quantity, or number in stock, logic is complete! If you liked this walk through and want more content like this I’ll be posting similar feature-specific blogs for different applications in the near future. Stay tuned for the next installment in my portfolio series which will show how to convert legacy layouts in Android!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfed1a0f9e88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>