Mobile Apps 2023W Lecture 14

From Soma-notes
Revision as of 15:02, 8 March 2023 by Soma (talk | contribs) (Created page with "==Notes== <pre> March 3 ------- I want to build a browser history viewer. It will allow surfing history to be viewed in a few ways: - list of pages visited (easy, dump stored history) - list "sessions" - group by what is first entered in the URL bar, whether it be a search or a direct entry of a URL - show as a grouped list (with each session collapsable) - show time of start of session, time of each subsequent request (potentially hide times)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Notes

March 3
-------

I want to build a browser history viewer.  It will allow surfing history to be viewed in a few ways:
 - list of pages visited (easy, dump stored history)
 - list "sessions"
    - group by what is first entered in the URL bar, whether it be a
      search or a direct entry of a URL
    - show as a grouped list (with each session collapsable)
    - show time of start of session, time of each subsequent request
      (potentially hide times)
 - What "places" I visit
    - can group by hostname
    - but sometimes hostname is too specific
      (subdomains can get added in weird ways)
    - maybe make it multilevel?

For example, consider the place "carleton.ca"
 - I visit many other places inside of Carleton
 - some are in SCS: openstack.scs.carleton.ca, homeostasis.scs.carleton.ca
 - so maybe make a hierarchical grouping of hostnames?


Collapsed view:
 - google.com +
 - carleton.ca +

Expanded view:
 - google.com
   - mail.google.com
   - sheets.google.com
 - carleton.ca
   - scs.carleton.ca
   - brightspace.carleton.ca

So we want a data structure that extracts the tree inherent in hostnames

Do you all know how DNS works?

Remember that DNS is a distributed hierarchical fault-tolerant database for mapping hostnames to IP addresses and other info

While there is lots of caching, basic lookup works like this:

* look up root server (.)
* ask root server for first component (end of URL)
   (.com)
* go to that server, ask for next component
   (ask .com server for google)
* continue recursively until you fully resolve host (e.g., www.google.com)



So we need to split up the hostname into its components, and build a tree of those components.

Linear time tree generation
 - you do this in 2402

But...we want to display this, so we don't want a data structure that is just for us.  We need to understand what data structure our display widget wants!

We can just make a simple lazy scrollable list that we can interact with to expand as needed

So we have a tree data structure, and for each node we have a property which says whether it is expanded or not
  - if it is expanded, we display the children.  If not, we don't.


                        .ca

    .carleton                       .google

  www  brightspace                www   mail   sheets

So our initial view would just show .ca, or it would show carleton.ca and google.ca

If we tap any of these, the node gets marked to expanded.  Then the list will automatically expand to show the nodes under that current one.


So how should we make a tree in Kotlin?

We'll have to specify the class of the node elements

class HostPart {
   value: String,
   expanded: bool,
   higher: HostPart?,   /* can be undefined */
   lower: HostPart?
}

Each level of tree is a List<<HostPart>>

Need to figure out how to react to tap events so we can expand and shrink our displayed list