2021_04.tex 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. \begin{center}
  2. \section*{\month}
  3. \end{center}
  4. \def\day{\textit{April 1st, 2021}}
  5. \def\weekday{\textit{Thursday}}
  6. \subsection*{\weekday, \day}
  7. Today I instaled this diary.
  8. \def\day{\textit{April 3st, 2021}}
  9. \def\weekday{\textit{Thursday}}
  10. \subsection*{\weekday, \day}
  11. I set up Android Studio and tried to install a KVM (i think it means Kernal Virtual Mashine) with \\
  12. https://help.ubuntu.com/community/KVM/Installation\\
  13. how to creat a android app with androidstudio \\
  14. https://developer.android.com/training/basics/firstapp/creating-project \\
  15. fundamentals how android apps works \\
  16. https://developer.android.com/guide/components/fundamentals \\
  17. How does an app get permissions for camera etc.\\
  18. https://developer.android.com/guide/topics/permissions/overview\\
  19. Activities\\
  20. https://developer.android.com/guide/components/activities/intro-activities\\
  21. Services\\
  22. https://developer.android.com/guide/components/services\\
  23. Notifications\\
  24. https://developer.android.com/guide/topics/ui/notifiers/notifications\\
  25. Content providers\\
  26. https://developer.android.com/guide/topics/providers/content-providers\\
  27. \newpage
  28. Each Android app lives in its own security sandbox, protected by the following Android security features: \\
  29. \begin{itemize}
  30. \item The Android operating system is a multi-user Linux system in which each app is a different user. \\
  31. \item By default, the system assigns each app a unique Linux user ID (the ID is used only by the system and is unknown to the app). \\
  32. The system sets permissions for all the files in an app so that only the user ID assigned to that app can access them. \\
  33. \item Each process has its own virtual machine (VM), so an app's code runs in isolation from other apps. \\
  34. \item By default, every app runs in its own Linux process. \\
  35. The Android system starts the process when any of the app's components need to be executed, \\
  36. and then shuts down the process when it's no longer needed or when the system must recover memory for other apps. \\
  37. \end{itemize}
  38. However, there are ways for an app to share data with other apps and for an app to access system services:\\
  39. \begin{itemize}
  40. \item It's possible to arrange for two apps to share the same Linux user ID, in which case they are able to access each other's files. \\
  41. To conserve system resources, apps with the same user ID can also arrange to run in the same Linux process and share the same VM. The apps must also be signed with the same certificate.\\
  42. \item An app can request permission to access device data such as the device's location, camera, and Bluetooth connection.\\
  43. The user has to explicitly grant these permissions. For more information, see Working with System Permissions.\\
  44. \end{itemize}
  45. \newpage
  46. There are four different types of app components:\\
  47. Activities\\
  48. Services\\
  49. Broadcast receivers\\
  50. Content providers\\
  51. \textbf{Activities}
  52. An activity is the entry point for interacting with the user. It represents a single screen with a user interface. For example, an email app might have one activity that shows a list of new emails,
  53. another activity to compose an email, and another activity for reading emails. Activities can be stopped and run again. And they can be started from other apps. \\
  54. An activity facilitates the following key interactions between system and app:\\
  55. \begin{itemize}
  56. \item Keeping track of what the user currently cares about (what is on screen) to ensure that the system keeps running the process that is hosting the activity.\\
  57. \item Knowing that previously used processes contain things the user may return to (stopped activities), and thus more highly prioritize keeping those processes around.\\
  58. \item Helping the app handle having its process killed so the user can return to activities with their previous state restored.\\
  59. \item Providing a way for apps to implement user flows between each other, and for the system to coordinate these flows. (The most classic example here being share.)\\
  60. \end{itemize}
  61. \textbf{Services}
  62. A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons.
  63. It is a component that runs in the background to perform long-running operations or to perform work for remote processes.
  64. A service does not provide a user interface. \\
  65. For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with an activity.
  66. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it.\\
  67. \newpage
  68. Syncing data in the background or playing music also represent two different types of started services that modify how the system handles them:\\
  69. \begin{itemize}
  70. \item Music playback is something the user is directly aware of, so the app tells the system this by saying it wants to be foreground with a notification to tell the user about it; \\
  71. in this case the system knows that it should try really hard to keep that service's process running, because the user will be unhappy if it goes away.\\\\
  72. \item A regular background service is not something the user is directly aware as running, so the system has more freedom in managing its process. \\
  73. It may allow it to be killed (and then restarting the service sometime later) if it needs RAM for things that are of more immediate concern to the user.\\
  74. \end{itemize}
  75. Bound services run because some other app (or the system) has said that it wants to make use of the service. This is basically the service providing an API to another process.
  76. If one service is importent the bound service will also be important.\\
  77. \textbf{Broadcast receivers}
  78. A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements. \\
  79. Because broadcast receivers are another well-defined entry into the app, the system can deliver broadcasts even to apps that aren't currently running.\\
  80. Apps can kinda communicate with broadcast reciever.\\
  81. More commonly, though, a broadcast receiver is just a gateway to other components and is intended to do a very minimal amount of work. \\
  82. For instance, it might schedule a JobService to perform some work based on the event with JobScheduler\\
  83. \textbf{Content provider}
  84. A content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access.
  85. Through the content provider, other apps can query or modify the data if the content provider allows it.\\
  86. To the system, a content provider is an entry point into an app for publishing named data items, identified by a URI scheme.
  87. Thus an app can decide how it wants to map the data it contains to a URI namespace, handing out those URIs to other entities which can in turn use them to access the data.
  88. There are a few particular things this allows the system to do in managing an app:
  89. \begin{itemize}
  90. \item Assigning a URI doesn't require that the app remain running, so URIs can persist after their owning apps have exited.
  91. The system only needs to make sure that an owning app is still running when it has to retrieve the app's data from the corresponding URI.
  92. \item These URIs also provide an important fine-grained security model.
  93. For example, an app can place the URI for an image it has on the clipboard, but leave its content provider locked up so that other apps cannot freely access it.
  94. When a second app attempts to access that URI on the clipboard,
  95. the system can allow that app to access the data via a temporary URI permission grant so that it is allowed to access the data only behind that URI, but nothing else in the second app.
  96. \end{itemize}
  97. Content providers are also useful for reading and writing data that is private to your app and not shared.\\
  98. A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other apps to perform transactions.
  99. For more information, see the Content Providers developer guide.\\\\
  100. %=============================================================================================================================================
  101. A unique aspect of the Android system design is that any app can start another app’s component.
  102. For example, if you want the user to capture a photo with the device camera,
  103. there's probably another app that does that and your app can use it instead of developing an activity to capture a photo yourself.
  104. You don't need to incorporate or even link to the code from the camera app.
  105. Instead, you can simply start the activity in the camera app that captures a photo.
  106. When complete, the photo is even returned to your app so you can use it. To the user, it seems as if the camera is actually a part of your app.\\
  107. When the system starts a component, it starts the process for that app if it's not already running and instantiates the classes needed for the component.
  108. For example, if your app starts the activity in the camera app that captures a photo, that activity runs in the process that belongs to the camera app, not in your app's process.
  109. Therefore, unlike apps on most other systems, Android apps don't have a single entry point (there's no main() function).\\
  110. Because the system runs each app in a separate process with file permissions that restrict access to other apps, your app cannot directly activate a component from another app.
  111. However, the Android system can. To activate a component in another app, deliver a message to the system that specifies your intent to start a particular component.
  112. The system then activates the component for you.
  113. \def\day{\textit{April 5st, 2021}}
  114. \def\weekday{\textit{Thursday}}
  115. \subsection*{\weekday, \day}
  116. I started a dictionary
  117. \def\day{\textit{April 11st, 2021}}
  118. \def\weekday{\textit{Thursday}}
  119. \subsection*{\weekday, \day}
  120. I'm imforming myself about git.
  121. https://www.youtube.com/watch?v=2sjqTHE0zok
  122. \newpage
  123. \def\day{\textit{April 12st, 2021}}
  124. \def\weekday{\textit{Thursday}}
  125. \subsection*{\weekday, \day}
  126. So right now i'm kindy angry at my self because I didn't look up what I have to learn to programm a App. Like i have to know the basics of Android UI and Android (I guess its a Ligary.)\\
  127. So now i'm on \\
  128. for a complete tutorial how to make a app\\
  129. https://abhiandroid.com/createandroidapp/ \\
  130. for a quick tutorial how to make a calculater\\
  131. https://abhiandroid.com/createandroidapp/create-calculator-app \\
  132. i just played around a little bit and relized XML is not that hard, just I just have to remeber alot \\
  133. /home/liquid/AndroidStudioProjects/calculater\\\\
  134. learning Android \\
  135. https://abhiandroid.com/programming/ \\
  136. Android UI,Layout and Material Design Tutorial, Examples And Code\\
  137. https://abhiandroid.com/ui/
  138. \def\day{\textit{April 13st, 2021}}
  139. \def\weekday{\textit{Thursday Simon}}
  140. \subsection*{\weekday, \day}
  141. We arranged that we work independent till Sunday (18.4.21) on research for the GUI. So that in the end we can exchange our knowlege.
  142. and we arranged that we work on Hello world
  143. \includegraphics[width=.8\textwidth]{media/WochenPlan13.4.jpeg}
  144. \def\day{\textit{April 13st Noah, 2021}}
  145. \def\weekday{\textit{Thursday}}
  146. \subsection*{\weekday, \day}
  147. I successfully installed both NDK and SDK on my Arch Linux Desktop PC. Now Android Studio won't crash on startup.
  148. \def\day{\textit{April 14st Simon, 2021}}
  149. \def\weekday{\textit{Thursday}}
  150. \subsection*{\weekday, \day}
  151. Apps provide multiple entry points
  152. The "main" activity starts when the user taps your app's icon. You can also direct the user to an activity from elsewhere, such as from a notification or even from a different app.
  153. Other components, such as broadcast receivers and services, allow your app to perform background tasks without a UI.
  154. After you build your first app, you can learn more about the other app components at Application fundamentals.
  155. Apps adapt to different devices
  156. Android allows you to provide different resources for different devices. For example, you can create different layouts for different screen sizes. The system determines which layout to use based on the screen size of the current device.
  157. If any of your app's features need specific hardware, such as a camera, you can query at runtime whether the device has that hardware or not, and then disable the corresponding features if it doesn't. You can specify that your app requires certain hardware so that Google Play won't allow the app to be installed on devices without them.
  158. After you build your first app, learn more about device configurations at Device compatibility overview.
  159. https://developer.android.com/training/basics/firstapp
  160. Installed java 8 so i can compile the build.gradle file but for this wasn't enough time
  161. \def\day{\textit{April 14st Noah, 2021}}
  162. \def\weekday{\textit{Wednesday}}
  163. \subsection*{\weekday, \day}
  164. I sucessfully managed to compile the app \url{https://github.com/aario/snotepad} on Arch Linux using the \texttt{jdk8-openjdk} package.\\
  165. Also I installed Ubuntu, so I could use the same environment as Simon.\\
  166. I wrote the adb guide \url{https://noahvogt.com/resources/adb-guide.html} and corrected all the errors Simon pointed out to me.
  167. \def\day{\textit{April 15st Simon, 2021}}
  168. \def\weekday{\textit{Thursday}}
  169. \subsection*{\weekday, \day}
  170. I finally could compile the testapp to an apk file.
  171. \newpage
  172. \def\day{\textit{April 19st Noah, 2021}}
  173. \def\weekday{\textit{Monday}}
  174. \subsection*{\weekday, \day}
  175. \begingroup
  176. \setlength{\intextsep}{10pt}
  177. \setlength{\columnsep}{15pt}
  178. \begin{wrapfigure}{l}{8cm}
  179. \centering
  180. \includegraphics[scale=.15]{media/hello-world-app-noah-screenshot}
  181. \caption{Hello World}
  182. \end{wrapfigure}
  183. I updated the adb guide as requested from Simon to include the Activation of the Android USB Debbing. I also made some additional changes.\\
  184. I made a Hello World Program, installed it via adb on my phone and captured this screenshot of it also using adb.\\
  185. Also, I made a private github repo \url{https://github.com/noahvogt/mini-project}.\\
  186. On there it is planned to work on features in seperate branches that will only be merged into the master branch, when they are in a usable state.
  187. \endgroup
  188. \vspace{4cm}
  189. \begingroup
  190. \setlength{\intextsep}{10pt}
  191. \setlength{\columnsep}{15pt}
  192. \begin{wrapfigure}{r}{8cm}
  193. \centering
  194. \includegraphics[scale=.15]{media/drawer}
  195. \caption{Drawer Navigation Menu}
  196. \end{wrapfigure}
  197. I then made the app more functional, so that you have a base GUI with a drawer, a menu in the bottom and in the drawer navigation menu you can tap on the «Add Email» Button and a popup window will come up asking you for name, email and password. Even the save and cancel button work. Now we only need a functionality to save this information to a string somewhere in the main activity.\\
  198. For this I created a new branch called \texttt{newemail-popup}.
  199. \endgroup
  200. \newpage
  201. \def\day{\textit{April 19st Simon, 2021}}
  202. \def\weekday{\textit{Monday}}
  203. \subsection*{\weekday, \day}
  204. Interfaces specify what a class must do and not how. It is the blueprint of the class.
  205. An Interface is about capabilities like a Player may be an interface and any class implementing Player must be able to (or must implement) move(). So it specifies a set of methods that the class has to implement.
  206. If a class implements an interface and does not provide method bodies for all functions specified in the interface, then the class must be declared abstract.
  207. A Java library example is Comparator Interface. If a class implements this interface, then it can be used to sort a collection.
  208. \includegraphics[width=.4\textwidth]{media/SyntactsInterface.png}
  209. \def\day{\textit{April 20st Simon, 2021}}
  210. \def\weekday{\textit{Thursday}}
  211. \subsection*{\weekday, \day}
  212. I'm working on a searchbutton and found a nice website with tutorials
  213. https://www.tutorialkart.com/kotlin-android/android-text-to-speech-kotlin-example/
  214. I found a tutorial for the searchbutton and function
  215. https://developer.android.com/guide/topics/search/search-dialog
  216. For the mail list
  217. https://developer.android.com/guide/topics/ui/layout/recyclerview
  218. I downloaded a Programm from git that is an example for a RecycleView
  219. ~/schulmaterial/matur/flowerPoject/
  220. \def\day{\textit{April 21st Simon, 2021}}
  221. \def\weekday{\textit{Thursday}}
  222. \subsection*{\weekday, \day}
  223. 1- The RecyclerView object: The overall container for your user interface is a RecylerView object that you add to your layout(You can add this object to your layout after adding its dependency to your build.gradle file).
  224. 2- Layout manager: The RecyclerView fills itself with views provided by a layout manager. There are 3 different types of layout managers that can be used:
  225. LinearLayoutManager which lays out items vertically or horizontally
  226. GridLayoutManager that lays out items in a grid
  227. StaggeredGridLayoutManager which lays out items in a staggered grid formation
  228. Also, we can implement our own layout manager
  229. 3- ViewHolder: The views in the list are represented by the view holder. Each view holder is in charge of displaying a single item with a view. We create a view holder object by extending our class from ReclerView.ViewHolder.
  230. 4- Adapter: An adapter manages the ViewHolder objects. It creates not only ViewHolders as needed, but also binds the ViewHolders with their data. We create an adapter by extending our class from RecyclerView.Adapter.
  231. 5- List of datasets: A list of datasets that we want to show in our RecyclerView. In this tutorial, we use a list of Strings.
  232. I tried to add some tutorials in the emailprogramm for the recycleView but nothing worked
  233. https://tutorial.eyehunts.com/android/create-cardview-list-with-recyclerview-android-example/
  234. mostly i tried this one but the implitation of 'com.android.support:design:28.0.0-alpha1' in build.gradle (:app) didn't work even when i search on google docs like it say in the tutorial.
  235. https://developer.android.com/codelabs/basic-android-kotlin-training-affirmations-app?hl=en\#1
  236. was my triy with the impementation
  237. https://medium.com/swlh/android-recyclerview-part-1-creating-a-simple-list-d84392c268b0
  238. from there i got a lot of information.
  239. I "Played" alot with ~/schulmaterial/matur/flowerPoject/views-widgets-samples/RecyclerView/
  240. but I was not able to take Program into the right parts. But now at 9:30 a clock I se a RecyclerViewSimple folder. So maybe tomorrow i my day.
  241. \def\day{\textit{April 20 Noah, 2021}}
  242. \def\weekday{\textit{Wednesday}}
  243. \subsection*{\weekday, \day}
  244. I continued my work on \texttt{newemail-popup} and looked up more ways how we could implement this. I am not sure yet, what we will go for right now.\\
  245. I also applied the GNU General Public License v3 on all upstream branches. I think it is useful to choose a free license right away, instead of waiting too long.
  246. \def\day{\textit{April 21 Noah, 2021}}
  247. \def\weekday{\textit{Wednesday}}
  248. \subsection*{\weekday, \day}
  249. After Simon mentioned to me that he couldn't install the unsigned release apk from our build, I tried it myself. It turned out you would have to sign this jar/apk, before your android phone will accept to install it.\\
  250. So I searched ways how to do it outside of anroid studio, just on the command line. I did try out some software projects and shell scripts, but none of them worked. ADB told me now, that instead of no certificates, I would have inconsistent ones.\\
  251. So I have successfully wasted 1 - 3 hours on finding out how to sign a apk. But I consider this issue not relevant right now, and in the worst case will be solvable by just using android studio. So I decided to ignore this issue for now and just use the debug apk for now.
  252. \def\day{\textit{April 26st Simon, 2021}}
  253. \def\weekday{\textit{Thursday}}
  254. \subsection*{\weekday, \day}
  255. I deleted the miniProjekt folder and installed the github files again.
  256. Also I puted the RecycleViewSimple in the programm but it is not finished yet.
  257. The List of the emails starts under the app bar and i think it is not interactive.
  258. \def\day{\textit{April 28st Simon, 2021}}
  259. \def\weekday{\textit{Thursday}}
  260. \subsection*{\weekday, \day}
  261. I'm stil trying to make the RecycleView work. It cannot find the Adapter but i'm working on it. But what came in my mind is that
  262. this Recycleviewer is not interactive. So it would just be a list where you can't click anything so I look in the other examples and found
  263. DataBindingDataBoundRecyclerView/ and that might be what we are looking for. Not exactly but there are buttons.
  264. \def\day{\textit{April 29st Simon, 2021}}
  265. \def\weekday{\textit{Thursday}}
  266. \subsection*{\weekday, \day}
  267. implementation "com.android.support:cardview-v7:28.0.0"
  268. implementation "com.android.support:appcompat-v7:28.0.0"
  269. I copied this into the build.gradle file for this classes
  270. import android.support.v7.widget.GridLayoutManager;
  271. import android.support.v7.widget.LinearLayoutManager;
  272. import android.support.v7.widget.RecyclerView;
  273. \def\day{\textit{May 2st Simon, 2021}}
  274. \def\weekday{\textit{Thursday}}
  275. \subsection*{\weekday, \day}
  276. I saw we have alot of androidx in our programm and I hope everything works with that.
  277. minSdkVersion 16 \\
  278. targetSdkVersion 30 \\
  279. \\
  280. these are the versions of our programm. minSdkVersion tells googleplay wich version is as minimum required and tergetSdkVersion is the version we use to programm in. I think thats a little high
  281. but it is a little bit late to change that now. But when we want to upload the programm to googleplay we need to have this version. \\
  282. https://www.c-sharpcorner.com/article/recyclerview-in-andriod-with-java/
  283. I finally unterstand how the important things like CustomAdapter or the data insert works with this example programm. And I now know how the
  284. RecyclerView example programm works. \\
  285. What I didn't had in mind was that it is java and I know how java works and I don't have to find a example to put in. I just have to unterstand
  286. how the classes works and where they are going to be used. I was confuced from the form of coding and the libarys.
  287. \\
  288. I made a new xml file called recycler\_view\_frag.xml with some things from activity\_main in it.
  289. \newpage
  290. \begin{lstlisting}
  291. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  292. xmlns:app="http://schemas.android.com/apk/res-auto"
  293. android:orientation="vertical"
  294. android:layout_width="match_parent"
  295. android:layout_height="match_parent"
  296. android:id="@+id/sample_main_layout">
  297. <FrameLayout
  298. android:layout_width="match_parent"
  299. android:layout_height="match_parent">
  300. <!--android:layout_marginLeft="@dimen/margin_medium"
  301. android:layout_marginRight="@dimen/margin_medium"
  302. android:gravity="center_vertical"-->
  303. <androidx.recyclerview.widget.RecyclerView
  304. android:id="@+id/recyclerView"
  305. android:layout_width="wrap_content"
  306. android:layout_height="wrap_content"
  307. app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" />
  308. <!--android:text="@string/element_text"-->
  309. </FrameLayout><!--RelativeLayout from https://www.c-sharpcorner.com/article/recyclerview-in-andriod-with-java/
  310. and FrameLayout was befor from https://developer.android.com/guide/topics/ui/layout/recyclerview#java-->
  311. </LinearLayout><!-- -->
  312. \end{lstlisting}
  313. this is what i added to MainActivity.java
  314. \\
  315. The second block is the important one
  316. \begin{lstlisting}
  317. protected String[] data;
  318. private static final int DATASET_COUNT = 60; //declares how far recyclerview count
  319. //imported by simon 2.mai
  320. //idk realy but it kinda uses the adapter
  321. RecyclerView recyclerView = findViewById(R.id.recyclerView);
  322. CustomAdapter adapter = new CustomAdapter(data);
  323. recyclerView.setAdapter(adapter);
  324. recyclerView.setLayoutManager(new LinearLayoutManager(this));
  325. /**
  326. * Generates Strings for RecyclerView's adapter. This data would usually come
  327. * from a local content provider or remote server.
  328. * implemented from simon 2.may
  329. */
  330. private void initDataset() {
  331. data = new String[DATASET_COUNT];
  332. for (int i = 0; i < DATASET_COUNT; i++) {
  333. data[i] = "This is element #" + i;
  334. }
  335. }
  336. \end{lstlisting}
  337. The problem right now at 23:46 is that the app crashes all the time
  338. I found some things that made the programm crash. \\
  339. \begin{enumerate}
  340. \item initialing the data maybe has to be done in a finished overitten method
  341. \item all the important things like Adapter defining has to be done in onCreateView and not onCreate.
  342. \end{enumerate}
  343. \def\day{\textit{May 5st Simon, 2021}}
  344. \def\weekday{\textit{Thursday}}
  345. \subsection*{\weekday, \day}
  346. I tried to fix the crash problem in the MainAktivity.java file and the cause for that was that the data variable wasen't detected because the onCreate() method was just protected
  347. and not public. But now it crashes without an error message so idk what the problem is.