repo
string
commit
string
message
string
diff
string
fujisho/meshdump
7642abf4ee8cfe8d5d821e77113d3ebc81033ea3
supported frame filter in the kernel. fixed a bug related to nfds of select(). added FD_ZERO() before select().
diff --git a/Makefile b/Makefile index 35153a6..ae99d28 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CFLAGS=-g meshdump: main.o $(CC) -o meshdump main.o -lpcap clean: - $(RM) meshdump *.o *~ \ No newline at end of file + $(RM) meshdump *.o *.dump *~ diff --git a/main.c b/main.c index 34977c9..5b2adb4 100644 --- a/main.c +++ b/main.c @@ -1,197 +1,232 @@ #include <pcap.h> #include "meshdump.h" /* Standard Libraries */ #include <assert.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include <sys/select.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> int running = 1; struct meshdump *alloc_dumps(int dump_nr) { struct meshdump *dumps = (struct meshdump*) malloc(dump_nr * sizeof(*dumps)); memset(dumps, 0, sizeof(*dumps) * dump_nr); return dumps; } void free_dumps(struct meshdump *dumps) { free(dumps); } +struct bpf_insn filter_insns[] = { + { 0x28, 0, 0, 0x00000002 }, + { 0x15, 0, 1, 0x00001700 }, + { 0x6, 0, 0, 0x00000057 }, + { 0x6, 0, 0, 0x0000005a }, +}; + int open_dumps(struct meshdump *dumps, int dump_nr, char **ifnames) { - int i, err; + int i; char filename[128]; char errbuf[PCAP_ERRBUF_SIZE]; + struct bpf_program filter; + + /* setup filter program */ + memset(&filter, 0, sizeof(filter)); + filter.bf_len = sizeof(filter_insns)/sizeof(filter_insns[0]); + filter.bf_insns = (struct bpf_insn*)malloc(sizeof(filter_insns)); + memcpy(filter.bf_insns, &filter_insns, sizeof(filter_insns)); + /* loop to initialize dumps */ for (i = 0; i < dump_nr; ++i) { dumps[i].ifname = ifnames[i]; dumps[i].pcap = pcap_open_live(dumps[i].ifname, 128, 1, 0, errbuf); - /* pcap_dispatch() is used later */ - err = pcap_setnonblock(dumps[i].pcap, 1, errbuf); - if (err) { + if (dumps[i].pcap == 0) { fprintf(stderr, "%s\n", errbuf); return -1; } - if (dumps[i].pcap == 0) { + + /* this is a kind of optimization.. */ + if (pcap_setfilter(dumps[i].pcap, &filter)) { + perror("pcap_setfilter"); + return -1; + } + + /* pcap_dispatch() is used later */ + if (pcap_setnonblock(dumps[i].pcap, 1, errbuf)) { fprintf(stderr, "%s\n", errbuf); return -1; } /* open dumper */ /* filename is automatically derived from ifname */ snprintf(filename, 128, "%s.dump", dumps[i].ifname); dumps[i].dumper = pcap_dump_open(dumps[i].pcap, filename); if (dumps[i].dumper == 0) { return -1; } } return 0; } +void print_stats(struct meshdump *dump) +{ + struct pcap_stat ps; + pcap_stats(dump->pcap, &ps); + + printf("%s: received %d, dropped %d\n", dump->ifname, ps.ps_recv, ps.ps_drop); +} + void close_dumps(struct meshdump *dumps, int dump_nr) { int i; for (i = 0; i < dump_nr; ++i) { /* close dumper first */ if (dumps[i].dumper) { pcap_dump_flush(dumps[i].dumper); pcap_dump_close(dumps[i].dumper); } /* close pcap */ - if (dumps[i].pcap) + if (dumps[i].pcap) { + print_stats(&dumps[i]); pcap_close(dumps[i].pcap); + } } } void process_dumps(struct meshdump *dumps, int dump_nr) { int i, nfds = -1; int *fds = (int*)malloc(dump_nr * sizeof(int)); char buf[4096]; for (i = 0; i < dump_nr; ++i) { fds[i] = pcap_fileno(dumps[i].pcap); - if (fds[i] - 1 > nfds) - nfds = fds[i] - 1; + if (fds[i] + 1 > nfds) + nfds = fds[i] + 1; } while (running) { fd_set readfds; int err; + + /* initialization */ + FD_ZERO(&readfds); for (i = 0; i < dump_nr; ++i) { FD_SET(fds[i], &readfds); } + err = select(nfds, &readfds, NULL, NULL, NULL); if (err < 0) break; for (i = 0; i < dump_nr; ++i) { if (FD_ISSET(fds[i], &readfds)) { /* dump frames as many as possible */ err = pcap_dispatch(dumps[i].pcap, -1, pcap_dump, (u_char*)dumps[i].dumper); if (err < 0) - break; + continue; } } } free(fds); } void print_usage(char *arg0) { printf("%s [-d] <iface> [<iface> ..]\n", arg0); } void stop_dumps(int signal) { assert(signal == SIGINT); running = 0; } int main(int argc, char **argv) { int i; struct meshdump *dumps; /* variables for getopt */ int c; int digit_optind = 0; int debug = 0; /* loop for getopt */ while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"help", 0, 0, 'h'}, {"debug", 0, 0, 'd'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "dh", long_options, &option_index); if (c == -1) break; switch (c) { case 'h': print_usage(argv[0]); return EXIT_SUCCESS; case 'd': debug = 1; break; default: printf("?? getopt returned character code 0%o ??\n", c); } } /* no iface specified */ if (argc < 2) { print_usage(argv[0]); return EXIT_SUCCESS; } if (signal(SIGINT, stop_dumps)) { perror("signal"); return EXIT_FAILURE; } dumps = alloc_dumps(argc - 1); if (open_dumps(dumps, argc - 1, &argv[1]) < 0) goto error; process_dumps(dumps, argc - 1); /* clean up */ close_dumps(dumps, argc - 1); error: free_dumps(dumps); return EXIT_SUCCESS; }
fujisho/meshdump
23222407a5b35c80e921eaa4855a2e0cc2e0821f
implemented basic functionalities.
diff --git a/Makefile b/Makefile index ca1eb7c..35153a6 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,6 @@ +CFLAGS=-g + meshdump: main.o - $(CC) -o maindump main.o -lpcap + $(CC) -o meshdump main.o -lpcap +clean: + $(RM) meshdump *.o *~ \ No newline at end of file diff --git a/main.c b/main.c index 8c667b9..34977c9 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,197 @@ #include <pcap.h> +#include "meshdump.h" -int main() +/* Standard Libraries */ +#include <assert.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <getopt.h> + +#include <sys/select.h> +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> + +int running = 1; + +struct meshdump *alloc_dumps(int dump_nr) { - return 0; -} \ No newline at end of file + struct meshdump *dumps = (struct meshdump*) malloc(dump_nr * sizeof(*dumps)); + memset(dumps, 0, sizeof(*dumps) * dump_nr); + + return dumps; +} + +void free_dumps(struct meshdump *dumps) +{ + free(dumps); +} + +int open_dumps(struct meshdump *dumps, int dump_nr, char **ifnames) +{ + int i, err; + char filename[128]; + char errbuf[PCAP_ERRBUF_SIZE]; + + for (i = 0; i < dump_nr; ++i) { + + dumps[i].ifname = ifnames[i]; + dumps[i].pcap = pcap_open_live(dumps[i].ifname, + 128, + 1, + 0, + errbuf); + /* pcap_dispatch() is used later */ + err = pcap_setnonblock(dumps[i].pcap, 1, errbuf); + if (err) { + fprintf(stderr, "%s\n", errbuf); + return -1; + } + if (dumps[i].pcap == 0) { + fprintf(stderr, "%s\n", errbuf); + return -1; + } + + /* open dumper */ + /* filename is automatically derived from ifname */ + snprintf(filename, 128, "%s.dump", dumps[i].ifname); + dumps[i].dumper = pcap_dump_open(dumps[i].pcap, filename); + if (dumps[i].dumper == 0) { + return -1; + } + } + + return 0; +} + +void close_dumps(struct meshdump *dumps, int dump_nr) +{ + int i; + for (i = 0; i < dump_nr; ++i) { + /* close dumper first */ + if (dumps[i].dumper) { + pcap_dump_flush(dumps[i].dumper); + pcap_dump_close(dumps[i].dumper); + } + /* close pcap */ + if (dumps[i].pcap) + pcap_close(dumps[i].pcap); + } +} + +void process_dumps(struct meshdump *dumps, int dump_nr) +{ + int i, nfds = -1; + int *fds = (int*)malloc(dump_nr * sizeof(int)); + char buf[4096]; + + for (i = 0; i < dump_nr; ++i) { + fds[i] = pcap_fileno(dumps[i].pcap); + if (fds[i] - 1 > nfds) + nfds = fds[i] - 1; + } + + while (running) { + fd_set readfds; + int err; + for (i = 0; i < dump_nr; ++i) { + FD_SET(fds[i], &readfds); + } + err = select(nfds, &readfds, NULL, NULL, NULL); + if (err < 0) + break; + + for (i = 0; i < dump_nr; ++i) { + if (FD_ISSET(fds[i], &readfds)) { + /* dump frames as many as possible */ + err = pcap_dispatch(dumps[i].pcap, + -1, + pcap_dump, + (u_char*)dumps[i].dumper); + if (err < 0) + break; + + } + } + } + + free(fds); +} + +void print_usage(char *arg0) +{ + printf("%s [-d] <iface> [<iface> ..]\n", arg0); +} + +void stop_dumps(int signal) +{ + assert(signal == SIGINT); + running = 0; +} + +int main(int argc, char **argv) +{ + int i; + struct meshdump *dumps; + + /* variables for getopt */ + int c; + int digit_optind = 0; + int debug = 0; + + /* loop for getopt */ + while (1) { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"debug", 0, 0, 'd'}, + {0, 0, 0, 0} + }; + c = getopt_long(argc, argv, "dh", + long_options, &option_index); + + if (c == -1) break; + + switch (c) { + case 'h': + print_usage(argv[0]); + return EXIT_SUCCESS; + + case 'd': + debug = 1; + break; + + default: + printf("?? getopt returned character code 0%o ??\n", c); + } + } + /* no iface specified */ + if (argc < 2) { + print_usage(argv[0]); + + return EXIT_SUCCESS; + } + + if (signal(SIGINT, stop_dumps)) { + perror("signal"); + return EXIT_FAILURE; + } + + + dumps = alloc_dumps(argc - 1); + + if (open_dumps(dumps, argc - 1, &argv[1]) < 0) + goto error; + + process_dumps(dumps, argc - 1); + + /* clean up */ + close_dumps(dumps, argc - 1); +error: + free_dumps(dumps); + + return EXIT_SUCCESS; +}
fujisho/meshdump
f2e5265833bc723075199682339fccf92cd8719a
added meshdump.h. implemented outline of program.
diff --git a/meshdump.h b/meshdump.h new file mode 100644 index 0000000..8ca6986 --- /dev/null +++ b/meshdump.h @@ -0,0 +1,12 @@ +#ifndef MESHDUMP_H +#define MESHDUMP_H + +#include <pcap.h> + +struct meshdump { + const char *ifname; + pcap_t *pcap; + pcap_dumper_t *dumper; +}; + +#endif
fujisho/meshdump
82543fe58b7bc333e10357f7204a373c676779e1
added Makefile.
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ca1eb7c --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +meshdump: main.o + $(CC) -o maindump main.o -lpcap
fujisho/meshdump
3780c9ece036587a6e2fc86459b7ee740ca6f56f
added main.c.
diff --git a/main.c b/main.c new file mode 100644 index 0000000..8c667b9 --- /dev/null +++ b/main.c @@ -0,0 +1,6 @@ +#include <pcap.h> + +int main() +{ + return 0; +} \ No newline at end of file
davcaffa/Mootools-Edit-In-Place
192b74e2eb4162ae64c4a1f87ec34965fa839d98
github generated gh-pages branch
diff --git a/index.html b/index.html new file mode 100644 index 0000000..74cab8f --- /dev/null +++ b/index.html @@ -0,0 +1,110 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + + <title>davcaffa/Mootools-Edit-In-Place @ GitHub</title> + + <style type="text/css"> + body { + margin-top: 1.0em; + background-color: #f8d112; + font-family: "Helvetica,Arial,FreeSans"; + color: #000000; + } + #container { + margin: 0 auto; + width: 700px; + } + h1 { font-size: 3.8em; color: #072eed; margin-bottom: 3px; } + h1 .small { font-size: 0.4em; } + h1 a { text-decoration: none } + h2 { font-size: 1.5em; color: #072eed; } + h3 { text-align: center; color: #072eed; } + a { color: #072eed; } + .description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;} + .download { float: right; } + pre { background: #000; color: #fff; padding: 15px;} + hr { border: 0; width: 80%; border-bottom: 1px solid #aaa} + .footer { text-align:center; padding-top:30px; font-style: italic; } + </style> + +</head> + +<body> + <a href="http://github.com/davcaffa/Mootools-Edit-In-Place"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a> + + <div id="container"> + + <div class="download"> + <a href="http://github.com/davcaffa/Mootools-Edit-In-Place/zipball/master"> + <img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a> + <a href="http://github.com/davcaffa/Mootools-Edit-In-Place/tarball/master"> + <img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a> + </div> + + <h1><a href="http://github.com/davcaffa/Mootools-Edit-In-Place">Mootools-Edit-In-Place</a> + <span class="small">by <a href="http://github.com/davcaffa">davcaffa</a></span></h1> + + <div class="description"> + Simple class for make edit in place text + </div> + + <h2>Dependencies</h2> +<p>core 1.2.1:*</p> +<h2>Install</h2> +<p><script src="js/mootools-1.2.3-core.js" type="text/javascript" charset="utf-8"></script> +<script src="js/moo-eip-min.js" type="text/javascript" charset="utf-8"></script> + +<script type="text/javascript" charset="utf-8"> +//<![CDATA[ +window.addEvent('domready', function() { + var eip = new MooEip('edit.php'); +}); +//]]> +</script> + +<!-- style for moo-eip --> +<link rel="stylesheet" type="text/css" href="css/style.css" /> +<!-- /style for moo-eip --> + +* See "manager.php" or "edit.php" for serverside integration +</p> +<h2>License</h2> +<p>MIT-style license</p> +<h2>Authors</h2> +<p>Davide Caffaratti</p> +<h2>Contact</h2> +<p> ([email protected]) <br/> </p> + + + <h2>Download</h2> + <p> + You can download this project in either + <a href="http://github.com/davcaffa/Mootools-Edit-In-Place/zipball/master">zip</a> or + <a href="http://github.com/davcaffa/Mootools-Edit-In-Place/tarball/master">tar</a> formats. + </p> + <p>You can also clone the project with <a href="http://git-scm.com">Git</a> + by running: + <pre>$ git clone git://github.com/davcaffa/Mootools-Edit-In-Place</pre> + </p> + + <div class="footer"> + get the source code on GitHub : <a href="http://github.com/davcaffa/Mootools-Edit-In-Place">davcaffa/Mootools-Edit-In-Place</a> + </div> + + </div> + + <script type="text/javascript"> +var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); +document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +</script> +<script type="text/javascript"> +try { +var pageTracker = _gat._getTracker("UA-2186929-1"); +pageTracker._trackPageview(); +} catch(err) {}</script> +</body> +</html>
basecode/Sketches
da713a9f1c839d4d28ef040263449b4372298a58
- undo needs less memory and is faster, - added rubber functionality (without icon), - some minor changes
diff --git a/Sketches.html b/Sketches.html index 813ec5f..74d853f 100644 --- a/Sketches.html +++ b/Sketches.html @@ -1,169 +1,242 @@ <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sketches</title> <meta name="viewport" content="width=device-width; height=device-height; initial-scale=1; maximum-scale=1; user-scalable=0;"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <style type="text/css"> body { background:#000; margin:0; font:12px Thonburi; } header, footer { - padding:1% 0.5%; + padding:1em 0.5em; overflow:auto; width:99%; height:4%; } header { border-bottom:2px dotted #444; position:absolute; top:0; left:0; } footer { border-top:2px dotted #444; position:absolute; bottom:0; left:0; } a { text-decoration:none; } a.button { color:#ddd; font-weight:bold; padding:0.5% 0.7%; border:1px solid #ddd; border-radius:5px; margin:0 0.5em; } a.button+a.color { padding:0.5%; } .left { float:left; } .right { float:right; } a.button+a.color div { padding:0 0.6em; border-radius:2px; } #canvasContainer { position:absolute; top:8%; left:0; width:100%; height:84%; } </style> </head> <body> <header> <a class="button left" href="">My Sketches</a> <a class="button left" href="">Share</a> - <a id="red" class="button color right" href=""><div style="background:red;">&nbsp;</div></a> - <a id="white" class="button color right" href=""><div style="background:white;">&nbsp;</div></a> + <a settings='{"lineWidth":30,"strokeStyle":"black"}' class="button color right" href=""><div style="background:black;">&nbsp;</div></a> + <a settings='{"strokeStyle":"red"}' class="button color right" href=""><div style="background:red;">&nbsp;</div></a> + <a settings='{"strokeStyle":"white"}' class="button color right" href=""><div style="background:white;">&nbsp;</div></a> </header> - <div id="canvasContainer"></div> + <div id="canvasContainer"> + <canvas id="drawingArea"></canvas> + </div> <footer> <a id="clear" class="button left" href="">Clear</a> - <a id="undo" class="button left" href="">Undo</a> - <a class="button color right" href="">+ New</a> + <a id="undo" class="button left" href=""><img style="vertical-align:middle;padding-right:5px;" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMTVweCIgaGVpZ2h0PSIxNXB4IiB2aWV3Qm94PSIwIDEgMTAgMTAiPjxwYXRoIHN0eWxlPSJmaWxsOiNGRkY7c3Ryb2tlOiNGRkY7c3Ryb2tlLXdpZHRoOjAuNDsiIGQ9Ik00LjQ3LDEuMDRDNS41NiwwLjgsNi41NywwLjk5LDcuNTEsMS42czEuNTMsMS40NiwxLjc2LDIuNTVjMC4yNCwxLjEsMC4wNSwyLjExLTAuNTUsMy4wNUM4LjExLDguMTQsNy4yNyw4LjczLDYuMTgsOC45N0M1LjEzLDkuMTksNC4xMSw5LjAxLDMuMTMsOC40MWwwLjQzLTAuNjhjMC43OSwwLjQ4LDEuNiwwLjYyLDIuNDQsMC40NGMwLjg3LTAuMTksMS41NS0wLjY2LDIuMDMtLjQxQzguNTIsNi4wMSw4LjY3LDUuMiw4LjQ4LDQuMzJDOC4yOSwzLjQ1LDcuODIsMi43Nyw3LjA3LDIuMjhTNS41MSwxLjY0LDQuNjQsMS44M0MzLjc3LDIuMDIsMy4wOCwyLjUyLDIuNTcsMy4zMkwzLjkzLDQuMkwxLjE0LDQuOEwwLjUzLDJsMS4zNiwwLjg4QzIuNTEsMS44OSwzLjM3LDEuMjcsNC40NywxLjA0eiIvPjwvc3ZnPg==">Undo</a> + <a id="new" class="button right" href="">+ New</a> </footer> <script type="text/javascript"> - window.addEventListener('load', function() { + NodeList.prototype.addEventListener = function(type, listener, useCapture) { + for (var i = 0; i < this.length; i++) { + this[i].addEventListener(type, listener, useCapture); + } + } + + /*var cmdPressed = 0; + window.addEventListener('keydown', function(e){ + if (cmdPressed && e.keyCode == 90 && !!document.getElementById('undo')) { + e.preventDefault(); + document.getElementById('undo').click(); + } + if(e.keyCode == 91) { + cmdPressed = 1; + } + }); + window.addEventListener('keyup', function(e){ + if(e.keyCode == 91) { + cmdPressed = 0; + } + });*/ + document.addEventListener('DOMContentLoaded', function() { + var container = document.getElementById('canvasContainer'), - settings = {lineWidth:7, lineCap:'round', lineJoin:'round', strokeStyle:'white'}; + canvas = document.getElementById('drawingArea'), + settings = { + s:{}, + init:function() { + this.reset(); + }, + reset:function() { + this.s = {lineWidth:7, lineCap:'round', lineJoin:'round', strokeStyle:'white'}; + }, + setter:function(newSettings) { + this.reset(); + for (var i in newSettings) { + this.s[i] = newSettings[i]; + } + } + }, + history = { + stack:window['sessionStorage'], + pop:function() { + var name = 'layer'+(this.stack.length-1), + value = this.stack.getItem(name); + this.stack.removeItem(name); + return value; + }, + push:function(value) { + this.stack.setItem('layer'+this.stack.length, value); + }, + purge:function() { + this.stack.clear(); + } + }; + + canvas.ctx = canvas.getContext('2d'); + - container.setCanvasFrame = function(canvasElement) { - canvasElement.setAttribute("width", this.clientWidth + "px"); - canvasElement.setAttribute("height", this.clientHeight + "px"); + history.purge(); + settings.init(); + + canvas.setFrame = function(container) { + this.setAttribute("width", container.clientWidth + "px"); + this.setAttribute("height", container.clientHeight + "px"); return this; } - container.setCanvasZIndex = function(canvasElement) { - canvasElement.setAttribute("style", "position:absolute;z-index:"+this.childNodes.length+";"); + canvas.setZIndex = function(container) { + this.setAttribute("style", "position:absolute;z-index:"+container.childNodes.length+";"); + return this; + } + canvas.fillRect = function(color) { + this.ctx.fillStyle = color; + this.ctx.fillRect(0, 0, this.width, this.height); return this; } container.getXPosition = function(event) { return (event.touches) ? event.touches[0].pageX-this.offsetLeft : event.clientX-this.offsetLeft; } container.getYPosition = function(event) { return (event.touches) ? event.touches[0].pageY-this.offsetTop : event.clientY-this.offsetTop; } container.onmousedown = container.ontouchstart = function(event) { event.preventDefault(); - var canvas = document.createElement('canvas'); - this.setCanvasFrame(canvas).setCanvasZIndex(canvas).appendChild(canvas); - + history.push(canvas.toDataURL('image/jpeg')); + canvas.draw = true; - canvas.ctx = canvas.getContext('2d'); - canvas.ctx.lineWidth = ""+settings.lineWidth; - canvas.ctx.lineCap = ""+settings.lineCap; - canvas.ctx.lineJoin = ""+settings.lineJoin; - canvas.ctx.strokeStyle = ""+settings.strokeStyle; + canvas.ctx.lineWidth = ""+settings.s.lineWidth; + canvas.ctx.lineCap = ""+settings.s.lineCap; + canvas.ctx.lineJoin = ""+settings.s.lineJoin; + canvas.ctx.strokeStyle = ""+settings.s.strokeStyle; canvas.ctx.beginPath(); canvas.ctx.moveTo(this.getXPosition(event), this.getYPosition(event)); canvas.ctx.lineTo(this.getXPosition(event), this.getYPosition(event)); canvas.ctx.stroke(); canvas.onmousemove = canvas.ontouchmove = function(event) { event.preventDefault(); if (!this.draw) return; canvas.ctx.lineTo(container.getXPosition(event), container.getYPosition(event)); canvas.ctx.stroke(); } canvas.onmouseup = canvas.ontouchcancel = canvas.ontouchend = function(event) { event.preventDefault(); canvas.ctx.closePath(); this.draw = false; } } document.getElementById('clear').addEventListener('click', function(event) { event.preventDefault(); - if (!container.hasChildNodes()) return; - while (container.hasChildNodes()) { - container.removeChild(container.lastChild); - } + history.push(canvas.toDataURL('image/jpeg')); + canvas.ctx.clearRect(0, 0, canvas.width, canvas.height); + }, false); document.getElementById('undo').addEventListener('click', function(event) { event.preventDefault(); - if (!container.hasChildNodes()) return; - container.removeChild(container.lastChild); + var dataUrl = history.pop(), + image = new Image(); + image.src = dataUrl; + image.width = canvas.width; + image.height = canvas.height; + image.onload = function(){ + canvas.ctx.drawImage(image,0,0); + } }, false); - document.getElementById('red').addEventListener('click', function(event) { + document.getElementById('new').addEventListener('click', function(event) { event.preventDefault(); - settings.strokeStyle = 'red'; + history.purge(); + canvas.ctx.clearRect(0, 0, canvas.width, canvas.height); + }, false); - - document.getElementById('white').addEventListener('click', function(event) { + + document.querySelectorAll('a.button.color').addEventListener('click', function(event) { event.preventDefault(); - settings.strokeStyle = 'white'; + settings.setter(JSON.parse(this.getAttribute('settings'))); }, false); + + canvas.setFrame(container).fillRect('#000'); }, true); </script> </body> </html> \ No newline at end of file
basecode/Sketches
a77b873e46dcb9d8763405fe16092a19fac0ec18
main html file
diff --git a/Sketches.html b/Sketches.html new file mode 100644 index 0000000..813ec5f --- /dev/null +++ b/Sketches.html @@ -0,0 +1,169 @@ +<!DOCTYPE html> +<html> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Sketches</title> + <meta name="viewport" content="width=device-width; height=device-height; initial-scale=1; maximum-scale=1; user-scalable=0;"> + <meta name="apple-mobile-web-app-capable" content="yes"> + <meta name="apple-mobile-web-app-status-bar-style" content="black"> + + <style type="text/css"> + body { + background:#000; + margin:0; + font:12px Thonburi; + } + header, footer { + padding:1% 0.5%; + overflow:auto; + width:99%; + height:4%; + } + header { + border-bottom:2px dotted #444; + position:absolute; + top:0; + left:0; + } + footer { + border-top:2px dotted #444; + position:absolute; + bottom:0; + left:0; + } + a { + text-decoration:none; + } + a.button { + color:#ddd; + font-weight:bold; + padding:0.5% 0.7%; + border:1px solid #ddd; + border-radius:5px; + margin:0 0.5em; + } + a.button+a.color { + padding:0.5%; + } + .left { + float:left; + } + .right { + float:right; + } + a.button+a.color div { + padding:0 0.6em; + border-radius:2px; + } + #canvasContainer { + position:absolute; + top:8%; + left:0; + width:100%; + height:84%; + } + </style> +</head> + +<body> + + <header> + <a class="button left" href="">My Sketches</a> + <a class="button left" href="">Share</a> + <a id="red" class="button color right" href=""><div style="background:red;">&nbsp;</div></a> + <a id="white" class="button color right" href=""><div style="background:white;">&nbsp;</div></a> + </header> + + <div id="canvasContainer"></div> + + <footer> + <a id="clear" class="button left" href="">Clear</a> + <a id="undo" class="button left" href="">Undo</a> + <a class="button color right" href="">+ New</a> + </footer> + + <script type="text/javascript"> + + window.addEventListener('load', function() { + + var container = document.getElementById('canvasContainer'), + settings = {lineWidth:7, lineCap:'round', lineJoin:'round', strokeStyle:'white'}; + + container.setCanvasFrame = function(canvasElement) { + canvasElement.setAttribute("width", this.clientWidth + "px"); + canvasElement.setAttribute("height", this.clientHeight + "px"); + return this; + } + container.setCanvasZIndex = function(canvasElement) { + canvasElement.setAttribute("style", "position:absolute;z-index:"+this.childNodes.length+";"); + return this; + } + container.getXPosition = function(event) { + return (event.touches) ? event.touches[0].pageX-this.offsetLeft : event.clientX-this.offsetLeft; + } + container.getYPosition = function(event) { + return (event.touches) ? event.touches[0].pageY-this.offsetTop : event.clientY-this.offsetTop; + } + + container.onmousedown = container.ontouchstart = function(event) { + event.preventDefault(); + var canvas = document.createElement('canvas'); + this.setCanvasFrame(canvas).setCanvasZIndex(canvas).appendChild(canvas); + + canvas.draw = true; + canvas.ctx = canvas.getContext('2d'); + canvas.ctx.lineWidth = ""+settings.lineWidth; + canvas.ctx.lineCap = ""+settings.lineCap; + canvas.ctx.lineJoin = ""+settings.lineJoin; + canvas.ctx.strokeStyle = ""+settings.strokeStyle; + canvas.ctx.beginPath(); + canvas.ctx.moveTo(this.getXPosition(event), this.getYPosition(event)); + canvas.ctx.lineTo(this.getXPosition(event), this.getYPosition(event)); + canvas.ctx.stroke(); + canvas.onmousemove = canvas.ontouchmove = function(event) { + event.preventDefault(); + if (!this.draw) return; + canvas.ctx.lineTo(container.getXPosition(event), container.getYPosition(event)); + canvas.ctx.stroke(); + } + + canvas.onmouseup = canvas.ontouchcancel = canvas.ontouchend = function(event) { + event.preventDefault(); + canvas.ctx.closePath(); + this.draw = false; + } + } + + document.getElementById('clear').addEventListener('click', function(event) { + event.preventDefault(); + if (!container.hasChildNodes()) return; + while (container.hasChildNodes()) { + container.removeChild(container.lastChild); + } + }, false); + + document.getElementById('undo').addEventListener('click', function(event) { + event.preventDefault(); + if (!container.hasChildNodes()) return; + container.removeChild(container.lastChild); + }, false); + + document.getElementById('red').addEventListener('click', function(event) { + event.preventDefault(); + settings.strokeStyle = 'red'; + }, false); + + document.getElementById('white').addEventListener('click', function(event) { + event.preventDefault(); + settings.strokeStyle = 'white'; + }, false); + + }, true); + + + </script> + +</body> + +</html> \ No newline at end of file
kates/node-stomp
61ccd891263f07e763633eb38a6456acb26ce2dd
add ack call to example of ack usage
diff --git a/README.md b/README.md index b4a83ab..d48bfd1 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,43 @@ node-stomp ========== ## Overview A simple STOMP client. ## Usage ### Subscribing **Basic** var sys = require("sys"), stomp = require("./stomp"); var client = new stomp.Client("localhost", 61613); client.subscribe("/queue/news", function(data){ sys.puts(data.body); }); **ACK** var sys = require("sys"), stomp = require("./stomp"); var client = new stomp.Client("localhost", 61613); client.subscribe("/queue/news", {ack: "client"}, function(data){ sys.puts(data.body); + client.ack(data); }); ### Publishing var stomp = require("./stomp"); var client = new stomp.Client("localhost", 61613); client.publish("/queue/news", "Stomp for NodeJS!"); ## TODO * make durable * add SSL support ## License MIT License \ No newline at end of file
kates/node-stomp
3ac67632045a3038af5df73d60001b53782a5ffa
Added ability to callback when a message has been sent
diff --git a/stomp.js b/stomp.js index 3c7f41b..f2f3b58 100644 --- a/stomp.js +++ b/stomp.js @@ -1,228 +1,236 @@ var sys = require("sys"); var tcp = require("net"); function Connection(host, port, login, password){ sys.puts("host " + host + " port " + port); host = host || "127.0.0.1"; port = port || 61613; this.login = login || ""; this.password = password || ""; this.commands = []; this.subscriptions = []; this.buffer = []; this.regex = /^(CONNECTED|MESSAGE|RECEIPT|ERROR)\n([\s\S]*?)\n\n([\s\S]*?)\0\n$/; var self = this; var conn = tcp.createConnection(port, host); conn.setEncoding("ascii"); conn.setTimeout(0); conn.setNoDelay(true); conn.addListener("connect", function(){ this.write("CONNECT\nlogin:" + self.login + "\npassword:" + self.password + "\n\n\x00"); }); conn.addListener("end", function(){ if(this.readyState && this.readyState == "open"){ conn.close(); } }); conn.addListener("close", function(had_error){ this.close(); }); conn.addListener("drain", function(){ }); conn.addListener("data", function(data){ var frames = data.split("\0\n"); var frame = null; while(frame = frames.shift()){ self.processMessage(frame + "\0\n"); //self.buffer.push(frame + "\0\n"); } }); this.conn = conn; this.processCommands(); this.processMessages(); } -Connection.prototype.transmit = function(msg){ - this.conn.write(msg); +Connection.prototype.transmit = function(msg, callback){ + if (this.conn.write(msg)) { + if (typeof callback == 'function') callback(msg); + } else { + if (typeof callback == 'function') { + this.conn.on('drain', function() { + callback(msg); + }); + } + } }; Connection.prototype.prepareMessage = function(msg){ var body = (msg.data || ""); var headers = []; headers["content-length"] = body.length; for(h in msg.headers){ headers.push(h + ":" + msg.headers[h]); } return msg.command + "\n" + headers.join("\n") + "\n\n" + body + "\n\x00"; }; Connection.prototype.processCommands = function(){ if(this.conn.readyState == "open"){ var m = null; while(m = this.commands.shift()){ - this.transmit(this.prepareMessage(m)); + this.transmit(this.prepareMessage(m), m.callback); } } if(this.conn.readyState == "closed"){ return; } var self = this; setTimeout(function(){self.processCommands()}, 100); }; Connection.prototype.parseHeader = function(s){ var lines = s.split("\n"); var headers = {}; for(var i=0; i<lines.length; i++){ var header = lines[i].split(":"); var headerName = header.shift().trim(); headers[headerName] = header.join(':').trim(); } return headers; }; Connection.prototype.parse = function(data){ var fragment = data.match(this.regex); if(fragment){ var headers = this.parseHeader(fragment[2]); var body = fragment[3]; return {command: fragment[1], headers: headers, body: body, original: data}; } else { return {command: "", headers: [], body: "", original: data}; } } Connection.prototype.processMessages = function(){ var msg = null; while(msg = this.buffer.shift()){ this.processMessage(msg); } var self = this; setTimeout((function(){self.processMessages()}), 100); }; Connection.prototype.processMessage = function(data){ var message = this.parse(data); switch(message.command){ case "MESSAGE": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; case "CONNECTED": break; case "RECEIPT": break; case "ERROR": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; } }; -Connection.prototype.publish = function(destination, data, headers){ +Connection.prototype.publish = function(destination, data, headers, callback){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); - this.commands.push({command: "SEND", headers: headers, data: data}); + this.commands.push({command: "SEND", headers: headers, data: data, callback: callback}); }; Connection.prototype.subscribe = function(destination, headers, callback){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SUBSCRIBE", headers: headers}); this.subscriptions[destination] = callback; } Connection.prototype.ack = function(msg){ headers = {"message-id": msg.headers["message-id"]}; msg.headers["transaction"] && (headers["transaction"] = msg.headers["transaction"]); //this.commands.push(this.prepareMessage({command: "ACK", headers: headers})); this.transmit(this.prepareMessage({command: "ACK", headers: headers})); }; Connection.prototype.unsubscribe = function(destination){ this.commands.push({command: "UNSUBSCRIBE", headers: {"destination": destination}}); this.subscriptions[destination] = null; }; Connection.prototype.begin = function(transaction_id){ this.commands.push({command: "BEGIN", headers: {"transaction": transaction_id}}); }; Connection.prototype.commit = function(transaction_id){ this.commands.push({command: "COMMIT", headers: {"transaction": transaction_id}}); }; Connection.prototype.abort = function(transaction_id){ this.commands.push({command: "ABORT", headers: {"transaction": transaction_id}}); }; Connection.prototype.disconnect = function(){ this.commands.push({command: "DISCONNECT", headers: {}}); }; Connection.prototype.close = function(){ this.conn.close(); }; // Client // really just a thin wrapper for the Connection object. // defaults: localhost, 61613 function Client(host, port, login, password){ this.conn = new Connection(host, port, login, password); }; -Client.prototype.publish = function(destination, data, headers){ - this.conn.publish(destination, data, headers); +Client.prototype.publish = function(destination, data, headers, callback){ + this.conn.publish(destination, data, headers, callback); }; Client.prototype.subscribe = function(destination, headers, callback){ if(typeof headers == "function"){ new_headers = {}; callback = headers; headers = {}; } this.conn.subscribe(destination, headers, callback); }; Client.prototype.ack = function(msg){ this.conn.ack(msg); }; Client.prototype.unsubscribe = function(destination){ this.conn.unsubscribe(destination); }; Client.prototype.begin = function(transaction_id){ this.conn.begin(transaction_id); }; Client.prototype.commit = function(transaction_id){ this.conn.commit(transaction_id); }; Client.prototype.abort = function(transaction_id){ this.conn.abort(transaction_id); }; Client.prototype.disconnect = function(){ this.conn.disconnect(); }; Client.prototype.close = function(){ this.conn.close(); }; exports.Client = Client;
kates/node-stomp
0cbeeae80d3f88ae62e34602720b1a0a14e5168e
Corrected indentation whitespace
diff --git a/stomp.js b/stomp.js index 4bb1702..3c7f41b 100644 --- a/stomp.js +++ b/stomp.js @@ -1,228 +1,228 @@ var sys = require("sys"); var tcp = require("net"); function Connection(host, port, login, password){ sys.puts("host " + host + " port " + port); host = host || "127.0.0.1"; port = port || 61613; this.login = login || ""; this.password = password || ""; this.commands = []; this.subscriptions = []; this.buffer = []; this.regex = /^(CONNECTED|MESSAGE|RECEIPT|ERROR)\n([\s\S]*?)\n\n([\s\S]*?)\0\n$/; var self = this; var conn = tcp.createConnection(port, host); conn.setEncoding("ascii"); conn.setTimeout(0); conn.setNoDelay(true); conn.addListener("connect", function(){ this.write("CONNECT\nlogin:" + self.login + "\npassword:" + self.password + "\n\n\x00"); }); conn.addListener("end", function(){ if(this.readyState && this.readyState == "open"){ conn.close(); } }); conn.addListener("close", function(had_error){ this.close(); }); conn.addListener("drain", function(){ }); conn.addListener("data", function(data){ var frames = data.split("\0\n"); var frame = null; while(frame = frames.shift()){ self.processMessage(frame + "\0\n"); //self.buffer.push(frame + "\0\n"); } }); this.conn = conn; this.processCommands(); this.processMessages(); } Connection.prototype.transmit = function(msg){ this.conn.write(msg); }; Connection.prototype.prepareMessage = function(msg){ var body = (msg.data || ""); var headers = []; headers["content-length"] = body.length; for(h in msg.headers){ headers.push(h + ":" + msg.headers[h]); } return msg.command + "\n" + headers.join("\n") + "\n\n" + body + "\n\x00"; }; Connection.prototype.processCommands = function(){ if(this.conn.readyState == "open"){ var m = null; while(m = this.commands.shift()){ this.transmit(this.prepareMessage(m)); } } if(this.conn.readyState == "closed"){ return; } var self = this; setTimeout(function(){self.processCommands()}, 100); }; Connection.prototype.parseHeader = function(s){ var lines = s.split("\n"); var headers = {}; for(var i=0; i<lines.length; i++){ var header = lines[i].split(":"); - var headerName = header.shift().trim(); - headers[headerName] = header.join(':').trim(); + var headerName = header.shift().trim(); + headers[headerName] = header.join(':').trim(); } return headers; }; Connection.prototype.parse = function(data){ var fragment = data.match(this.regex); if(fragment){ var headers = this.parseHeader(fragment[2]); var body = fragment[3]; return {command: fragment[1], headers: headers, body: body, original: data}; } else { return {command: "", headers: [], body: "", original: data}; } } Connection.prototype.processMessages = function(){ var msg = null; while(msg = this.buffer.shift()){ this.processMessage(msg); } var self = this; setTimeout((function(){self.processMessages()}), 100); }; Connection.prototype.processMessage = function(data){ var message = this.parse(data); switch(message.command){ case "MESSAGE": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; case "CONNECTED": break; case "RECEIPT": break; case "ERROR": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; } }; Connection.prototype.publish = function(destination, data, headers){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SEND", headers: headers, data: data}); }; Connection.prototype.subscribe = function(destination, headers, callback){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SUBSCRIBE", headers: headers}); this.subscriptions[destination] = callback; } Connection.prototype.ack = function(msg){ headers = {"message-id": msg.headers["message-id"]}; msg.headers["transaction"] && (headers["transaction"] = msg.headers["transaction"]); //this.commands.push(this.prepareMessage({command: "ACK", headers: headers})); this.transmit(this.prepareMessage({command: "ACK", headers: headers})); }; Connection.prototype.unsubscribe = function(destination){ this.commands.push({command: "UNSUBSCRIBE", headers: {"destination": destination}}); this.subscriptions[destination] = null; }; Connection.prototype.begin = function(transaction_id){ this.commands.push({command: "BEGIN", headers: {"transaction": transaction_id}}); }; Connection.prototype.commit = function(transaction_id){ this.commands.push({command: "COMMIT", headers: {"transaction": transaction_id}}); }; Connection.prototype.abort = function(transaction_id){ this.commands.push({command: "ABORT", headers: {"transaction": transaction_id}}); }; Connection.prototype.disconnect = function(){ this.commands.push({command: "DISCONNECT", headers: {}}); }; Connection.prototype.close = function(){ this.conn.close(); }; // Client // really just a thin wrapper for the Connection object. // defaults: localhost, 61613 function Client(host, port, login, password){ this.conn = new Connection(host, port, login, password); }; Client.prototype.publish = function(destination, data, headers){ this.conn.publish(destination, data, headers); }; Client.prototype.subscribe = function(destination, headers, callback){ if(typeof headers == "function"){ new_headers = {}; callback = headers; headers = {}; } this.conn.subscribe(destination, headers, callback); }; Client.prototype.ack = function(msg){ this.conn.ack(msg); }; Client.prototype.unsubscribe = function(destination){ this.conn.unsubscribe(destination); }; Client.prototype.begin = function(transaction_id){ this.conn.begin(transaction_id); }; Client.prototype.commit = function(transaction_id){ this.conn.commit(transaction_id); }; Client.prototype.abort = function(transaction_id){ this.conn.abort(transaction_id); }; Client.prototype.disconnect = function(){ this.conn.disconnect(); }; Client.prototype.close = function(){ this.conn.close(); }; exports.Client = Client;
kates/node-stomp
f0963296545040de5ce200b6930871e546ea98e5
Allowed for headers with a : in them
diff --git a/stomp.js b/stomp.js index aef31f1..4bb1702 100644 --- a/stomp.js +++ b/stomp.js @@ -1,227 +1,228 @@ var sys = require("sys"); var tcp = require("net"); function Connection(host, port, login, password){ sys.puts("host " + host + " port " + port); host = host || "127.0.0.1"; port = port || 61613; this.login = login || ""; this.password = password || ""; this.commands = []; this.subscriptions = []; this.buffer = []; this.regex = /^(CONNECTED|MESSAGE|RECEIPT|ERROR)\n([\s\S]*?)\n\n([\s\S]*?)\0\n$/; var self = this; var conn = tcp.createConnection(port, host); conn.setEncoding("ascii"); conn.setTimeout(0); conn.setNoDelay(true); conn.addListener("connect", function(){ this.write("CONNECT\nlogin:" + self.login + "\npassword:" + self.password + "\n\n\x00"); }); conn.addListener("end", function(){ if(this.readyState && this.readyState == "open"){ conn.close(); } }); conn.addListener("close", function(had_error){ this.close(); }); conn.addListener("drain", function(){ }); conn.addListener("data", function(data){ var frames = data.split("\0\n"); var frame = null; while(frame = frames.shift()){ self.processMessage(frame + "\0\n"); //self.buffer.push(frame + "\0\n"); } }); this.conn = conn; this.processCommands(); this.processMessages(); } Connection.prototype.transmit = function(msg){ this.conn.write(msg); }; Connection.prototype.prepareMessage = function(msg){ var body = (msg.data || ""); var headers = []; headers["content-length"] = body.length; for(h in msg.headers){ headers.push(h + ":" + msg.headers[h]); } return msg.command + "\n" + headers.join("\n") + "\n\n" + body + "\n\x00"; }; Connection.prototype.processCommands = function(){ if(this.conn.readyState == "open"){ var m = null; while(m = this.commands.shift()){ this.transmit(this.prepareMessage(m)); } } if(this.conn.readyState == "closed"){ return; } var self = this; setTimeout(function(){self.processCommands()}, 100); }; Connection.prototype.parseHeader = function(s){ var lines = s.split("\n"); var headers = {}; for(var i=0; i<lines.length; i++){ var header = lines[i].split(":"); - headers[header[0].trim()] = header[1].trim(); + var headerName = header.shift().trim(); + headers[headerName] = header.join(':').trim(); } return headers; }; Connection.prototype.parse = function(data){ var fragment = data.match(this.regex); if(fragment){ var headers = this.parseHeader(fragment[2]); var body = fragment[3]; return {command: fragment[1], headers: headers, body: body, original: data}; } else { return {command: "", headers: [], body: "", original: data}; } } Connection.prototype.processMessages = function(){ var msg = null; while(msg = this.buffer.shift()){ this.processMessage(msg); } var self = this; setTimeout((function(){self.processMessages()}), 100); }; Connection.prototype.processMessage = function(data){ var message = this.parse(data); switch(message.command){ case "MESSAGE": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; case "CONNECTED": break; case "RECEIPT": break; case "ERROR": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; } }; Connection.prototype.publish = function(destination, data, headers){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SEND", headers: headers, data: data}); }; Connection.prototype.subscribe = function(destination, headers, callback){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SUBSCRIBE", headers: headers}); this.subscriptions[destination] = callback; } Connection.prototype.ack = function(msg){ headers = {"message-id": msg.headers["message-id"]}; msg.headers["transaction"] && (headers["transaction"] = msg.headers["transaction"]); //this.commands.push(this.prepareMessage({command: "ACK", headers: headers})); this.transmit(this.prepareMessage({command: "ACK", headers: headers})); }; Connection.prototype.unsubscribe = function(destination){ this.commands.push({command: "UNSUBSCRIBE", headers: {"destination": destination}}); this.subscriptions[destination] = null; }; Connection.prototype.begin = function(transaction_id){ this.commands.push({command: "BEGIN", headers: {"transaction": transaction_id}}); }; Connection.prototype.commit = function(transaction_id){ this.commands.push({command: "COMMIT", headers: {"transaction": transaction_id}}); }; Connection.prototype.abort = function(transaction_id){ this.commands.push({command: "ABORT", headers: {"transaction": transaction_id}}); }; Connection.prototype.disconnect = function(){ this.commands.push({command: "DISCONNECT", headers: {}}); }; Connection.prototype.close = function(){ this.conn.close(); }; // Client // really just a thin wrapper for the Connection object. // defaults: localhost, 61613 function Client(host, port, login, password){ this.conn = new Connection(host, port, login, password); }; Client.prototype.publish = function(destination, data, headers){ this.conn.publish(destination, data, headers); }; Client.prototype.subscribe = function(destination, headers, callback){ if(typeof headers == "function"){ new_headers = {}; callback = headers; headers = {}; } this.conn.subscribe(destination, headers, callback); }; Client.prototype.ack = function(msg){ this.conn.ack(msg); }; Client.prototype.unsubscribe = function(destination){ this.conn.unsubscribe(destination); }; Client.prototype.begin = function(transaction_id){ this.conn.begin(transaction_id); }; Client.prototype.commit = function(transaction_id){ this.conn.commit(transaction_id); }; Client.prototype.abort = function(transaction_id){ this.conn.abort(transaction_id); }; Client.prototype.disconnect = function(){ this.conn.disconnect(); }; Client.prototype.close = function(){ this.conn.close(); }; exports.Client = Client;
kates/node-stomp
d38e8eedb9332e1bd87d33c396cd817ed7aafa99
Enabled the message processing, not sure how else it was supposed to work
diff --git a/stomp.js b/stomp.js index 9cb6ce7..aef31f1 100644 --- a/stomp.js +++ b/stomp.js @@ -1,227 +1,227 @@ var sys = require("sys"); var tcp = require("net"); function Connection(host, port, login, password){ sys.puts("host " + host + " port " + port); host = host || "127.0.0.1"; port = port || 61613; this.login = login || ""; this.password = password || ""; this.commands = []; this.subscriptions = []; this.buffer = []; this.regex = /^(CONNECTED|MESSAGE|RECEIPT|ERROR)\n([\s\S]*?)\n\n([\s\S]*?)\0\n$/; var self = this; var conn = tcp.createConnection(port, host); conn.setEncoding("ascii"); conn.setTimeout(0); conn.setNoDelay(true); conn.addListener("connect", function(){ this.write("CONNECT\nlogin:" + self.login + "\npassword:" + self.password + "\n\n\x00"); }); conn.addListener("end", function(){ if(this.readyState && this.readyState == "open"){ conn.close(); } }); conn.addListener("close", function(had_error){ this.close(); }); conn.addListener("drain", function(){ }); conn.addListener("data", function(data){ var frames = data.split("\0\n"); var frame = null; while(frame = frames.shift()){ self.processMessage(frame + "\0\n"); //self.buffer.push(frame + "\0\n"); } }); this.conn = conn; this.processCommands(); - //this.processMessages(); + this.processMessages(); } Connection.prototype.transmit = function(msg){ this.conn.write(msg); }; Connection.prototype.prepareMessage = function(msg){ var body = (msg.data || ""); var headers = []; headers["content-length"] = body.length; for(h in msg.headers){ headers.push(h + ":" + msg.headers[h]); } return msg.command + "\n" + headers.join("\n") + "\n\n" + body + "\n\x00"; }; Connection.prototype.processCommands = function(){ if(this.conn.readyState == "open"){ var m = null; while(m = this.commands.shift()){ this.transmit(this.prepareMessage(m)); } } if(this.conn.readyState == "closed"){ return; } var self = this; setTimeout(function(){self.processCommands()}, 100); }; Connection.prototype.parseHeader = function(s){ var lines = s.split("\n"); var headers = {}; for(var i=0; i<lines.length; i++){ var header = lines[i].split(":"); headers[header[0].trim()] = header[1].trim(); } return headers; }; Connection.prototype.parse = function(data){ var fragment = data.match(this.regex); if(fragment){ var headers = this.parseHeader(fragment[2]); var body = fragment[3]; return {command: fragment[1], headers: headers, body: body, original: data}; } else { return {command: "", headers: [], body: "", original: data}; } } Connection.prototype.processMessages = function(){ var msg = null; while(msg = this.buffer.shift()){ this.processMessage(msg); } var self = this; setTimeout((function(){self.processMessages()}), 100); }; Connection.prototype.processMessage = function(data){ var message = this.parse(data); switch(message.command){ case "MESSAGE": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; case "CONNECTED": break; case "RECEIPT": break; case "ERROR": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; } }; Connection.prototype.publish = function(destination, data, headers){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SEND", headers: headers, data: data}); }; Connection.prototype.subscribe = function(destination, headers, callback){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SUBSCRIBE", headers: headers}); this.subscriptions[destination] = callback; } Connection.prototype.ack = function(msg){ headers = {"message-id": msg.headers["message-id"]}; msg.headers["transaction"] && (headers["transaction"] = msg.headers["transaction"]); //this.commands.push(this.prepareMessage({command: "ACK", headers: headers})); this.transmit(this.prepareMessage({command: "ACK", headers: headers})); }; Connection.prototype.unsubscribe = function(destination){ this.commands.push({command: "UNSUBSCRIBE", headers: {"destination": destination}}); this.subscriptions[destination] = null; }; Connection.prototype.begin = function(transaction_id){ this.commands.push({command: "BEGIN", headers: {"transaction": transaction_id}}); }; Connection.prototype.commit = function(transaction_id){ this.commands.push({command: "COMMIT", headers: {"transaction": transaction_id}}); }; Connection.prototype.abort = function(transaction_id){ this.commands.push({command: "ABORT", headers: {"transaction": transaction_id}}); }; Connection.prototype.disconnect = function(){ this.commands.push({command: "DISCONNECT", headers: {}}); }; Connection.prototype.close = function(){ this.conn.close(); }; // Client // really just a thin wrapper for the Connection object. // defaults: localhost, 61613 function Client(host, port, login, password){ this.conn = new Connection(host, port, login, password); }; Client.prototype.publish = function(destination, data, headers){ this.conn.publish(destination, data, headers); }; Client.prototype.subscribe = function(destination, headers, callback){ if(typeof headers == "function"){ new_headers = {}; callback = headers; headers = {}; } this.conn.subscribe(destination, headers, callback); }; Client.prototype.ack = function(msg){ this.conn.ack(msg); }; Client.prototype.unsubscribe = function(destination){ this.conn.unsubscribe(destination); }; Client.prototype.begin = function(transaction_id){ this.conn.begin(transaction_id); }; Client.prototype.commit = function(transaction_id){ this.conn.commit(transaction_id); }; Client.prototype.abort = function(transaction_id){ this.conn.abort(transaction_id); }; Client.prototype.disconnect = function(){ this.conn.disconnect(); }; Client.prototype.close = function(){ this.conn.close(); }; exports.Client = Client;
kates/node-stomp
086afc24905275cbf32adf4217263f7f21183aaa
Compatibility with node v0.3
diff --git a/stomp.js b/stomp.js index 80dc76c..9cb6ce7 100644 --- a/stomp.js +++ b/stomp.js @@ -1,227 +1,227 @@ var sys = require("sys"); -var tcp = require("tcp"); +var tcp = require("net"); function Connection(host, port, login, password){ sys.puts("host " + host + " port " + port); host = host || "127.0.0.1"; port = port || 61613; this.login = login || ""; this.password = password || ""; this.commands = []; this.subscriptions = []; this.buffer = []; this.regex = /^(CONNECTED|MESSAGE|RECEIPT|ERROR)\n([\s\S]*?)\n\n([\s\S]*?)\0\n$/; var self = this; var conn = tcp.createConnection(port, host); conn.setEncoding("ascii"); conn.setTimeout(0); conn.setNoDelay(true); conn.addListener("connect", function(){ this.write("CONNECT\nlogin:" + self.login + "\npassword:" + self.password + "\n\n\x00"); }); conn.addListener("end", function(){ if(this.readyState && this.readyState == "open"){ conn.close(); } }); conn.addListener("close", function(had_error){ this.close(); }); conn.addListener("drain", function(){ }); conn.addListener("data", function(data){ var frames = data.split("\0\n"); var frame = null; while(frame = frames.shift()){ self.processMessage(frame + "\0\n"); //self.buffer.push(frame + "\0\n"); } }); this.conn = conn; this.processCommands(); //this.processMessages(); } Connection.prototype.transmit = function(msg){ this.conn.write(msg); }; Connection.prototype.prepareMessage = function(msg){ var body = (msg.data || ""); var headers = []; headers["content-length"] = body.length; for(h in msg.headers){ headers.push(h + ":" + msg.headers[h]); } return msg.command + "\n" + headers.join("\n") + "\n\n" + body + "\n\x00"; }; Connection.prototype.processCommands = function(){ if(this.conn.readyState == "open"){ var m = null; while(m = this.commands.shift()){ this.transmit(this.prepareMessage(m)); } } if(this.conn.readyState == "closed"){ return; } var self = this; setTimeout(function(){self.processCommands()}, 100); }; Connection.prototype.parseHeader = function(s){ var lines = s.split("\n"); var headers = {}; for(var i=0; i<lines.length; i++){ var header = lines[i].split(":"); headers[header[0].trim()] = header[1].trim(); } return headers; }; Connection.prototype.parse = function(data){ var fragment = data.match(this.regex); if(fragment){ var headers = this.parseHeader(fragment[2]); var body = fragment[3]; return {command: fragment[1], headers: headers, body: body, original: data}; } else { return {command: "", headers: [], body: "", original: data}; } } Connection.prototype.processMessages = function(){ var msg = null; while(msg = this.buffer.shift()){ this.processMessage(msg); } var self = this; setTimeout((function(){self.processMessages()}), 100); }; Connection.prototype.processMessage = function(data){ var message = this.parse(data); switch(message.command){ case "MESSAGE": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; case "CONNECTED": break; case "RECEIPT": break; case "ERROR": var callable = this.subscriptions[message.headers["destination"]]; if(callable){ callable.call(this, message); } break; } }; Connection.prototype.publish = function(destination, data, headers){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SEND", headers: headers, data: data}); }; Connection.prototype.subscribe = function(destination, headers, callback){ headers && (headers["destination"] = destination) || (headers = {"destination": destination}); this.commands.push({command: "SUBSCRIBE", headers: headers}); this.subscriptions[destination] = callback; } Connection.prototype.ack = function(msg){ headers = {"message-id": msg.headers["message-id"]}; msg.headers["transaction"] && (headers["transaction"] = msg.headers["transaction"]); //this.commands.push(this.prepareMessage({command: "ACK", headers: headers})); this.transmit(this.prepareMessage({command: "ACK", headers: headers})); }; Connection.prototype.unsubscribe = function(destination){ this.commands.push({command: "UNSUBSCRIBE", headers: {"destination": destination}}); this.subscriptions[destination] = null; }; Connection.prototype.begin = function(transaction_id){ this.commands.push({command: "BEGIN", headers: {"transaction": transaction_id}}); }; Connection.prototype.commit = function(transaction_id){ this.commands.push({command: "COMMIT", headers: {"transaction": transaction_id}}); }; Connection.prototype.abort = function(transaction_id){ this.commands.push({command: "ABORT", headers: {"transaction": transaction_id}}); }; Connection.prototype.disconnect = function(){ this.commands.push({command: "DISCONNECT", headers: {}}); }; Connection.prototype.close = function(){ this.conn.close(); }; // Client // really just a thin wrapper for the Connection object. // defaults: localhost, 61613 function Client(host, port, login, password){ this.conn = new Connection(host, port, login, password); }; Client.prototype.publish = function(destination, data, headers){ this.conn.publish(destination, data, headers); }; Client.prototype.subscribe = function(destination, headers, callback){ if(typeof headers == "function"){ new_headers = {}; callback = headers; headers = {}; } this.conn.subscribe(destination, headers, callback); }; Client.prototype.ack = function(msg){ this.conn.ack(msg); }; Client.prototype.unsubscribe = function(destination){ this.conn.unsubscribe(destination); }; Client.prototype.begin = function(transaction_id){ this.conn.begin(transaction_id); }; Client.prototype.commit = function(transaction_id){ this.conn.commit(transaction_id); }; Client.prototype.abort = function(transaction_id){ this.conn.abort(transaction_id); }; Client.prototype.disconnect = function(){ this.conn.disconnect(); }; Client.prototype.close = function(){ this.conn.close(); }; -exports.Client = Client; \ No newline at end of file +exports.Client = Client;
timknip/papervision3d
a99cef602095c1ef66ab4acdf4f19abf61e58155
some updates
diff --git a/src/Main.as b/src/Main.as index de5921c..4d073cf 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,176 +1,176 @@ package { import flash.display.BitmapData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public var camera2 :Camera3D; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; viewport = new Viewport3D(0, 0, true); addChild(viewport); scene = new DisplayObject3D("Scene"); camera = new Camera3D(30, 400, 2300, "Camera01"); scene.addChild( camera ); camera.enableCulling = false camera.showFrustum = false; camera.z = 800; renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; var bmp:BitmapData = new BitmapData(256, 256); bmp.perlinNoise(256, 256, 2, 300, true, false); cube = new Cube(new BitmapMaterial(bmp), 100, "Cube"); //cube = new Cube(new WireframeMaterial(0xFF0000), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; cubeChild1.scaleX = 5; cubeChild1.scaleY = 5; cubeChild1.scaleZ = 0.1; scene.addChild( cube ); camera2 = new Camera3D(50, 50, 500); cube.addChild(camera2); camera2.showFrustum = true; - cube.scaleX = 2; + //cube.scaleX = 2; //var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); //scene.addChild(plane); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; - + private function render(event:Event=null):void { camera2.frustumGeometry.update(camera2); // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); //cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z--; cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/core/proto/Transform3D.as b/src/org/papervision3d/core/proto/Transform3D.as index 3a78703..226f155 100755 --- a/src/org/papervision3d/core/proto/Transform3D.as +++ b/src/org/papervision3d/core/proto/Transform3D.as @@ -1,355 +1,355 @@ package org.papervision3d.core.proto { import flash.geom.Matrix3D; import flash.geom.Vector3D; import org.papervision3d.core.math.Quaternion; import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; /** * Transform3D. * <p></p> * * @author Tim Knip / floorplanner.com */ public class Transform3D { use namespace pv3d; /** */ public static var DEFAULT_LOOKAT_UP :Vector3D = new Vector3D(0, -1, 0); /** */ public var worldTransform :Matrix3D; /** */ public var viewTransform :Matrix3D; /** */ public var screenTransform :Matrix3D; /** */ pv3d var scheduledLookAt :Transform3D; /** */ pv3d var scheduledLookAtUp :Vector3D; /** */ - private var _parent :Transform3D; + pv3d var _parent :Transform3D; /** The position of the transform in world space. */ - private var _position :Vector3D; + pv3d var _position :Vector3D; /** Position of the transform relative to the parent transform. */ - private var _localPosition :Vector3D; + pv3d var _localPosition :Vector3D; /** The rotation as Euler angles in degrees. */ - private var _eulerAngles :Vector3D; + pv3d var _eulerAngles :Vector3D; /** The rotation as Euler angles in degrees relative to the parent transform's rotation. */ - private var _localEulerAngles :Vector3D; + pv3d var _localEulerAngles :Vector3D; /** The X axis of the transform in world space */ - private var _right :Vector3D; + pv3d var _right :Vector3D; /** The Y axis of the transform in world space */ - private var _up :Vector3D; + pv3d var _up :Vector3D; /** The Z axis of the transform in world space */ - private var _forward :Vector3D; + pv3d var _forward :Vector3D; /** The rotation of the transform in world space stored as a Quaternion. */ - private var _rotation :Quaternion; + pv3d var _rotation :Quaternion; /** The rotation of the transform relative to the parent transform's rotation. */ - private var _localRotation :Quaternion; + pv3d var _localRotation :Quaternion; /** */ - private var _localScale :Vector3D; + pv3d var _localScale :Vector3D; - private var _transform :Matrix3D; - private var _localTransform :Matrix3D; + pv3d var _transform :Matrix3D; + pv3d var _localTransform :Matrix3D; - private var _dirty :Boolean; + pv3d var _dirty :Boolean; /** * */ public function Transform3D() { _position = new Vector3D(); _localPosition = new Vector3D(); _eulerAngles = new Vector3D(); _localEulerAngles = new Vector3D(); _right = new Vector3D(); _up = new Vector3D(); _forward = new Vector3D(); _rotation = new Quaternion(); _localRotation = new Quaternion(); _localScale = new Vector3D(1, 1, 1); _transform = new Matrix3D(); _localTransform = new Matrix3D(); this.worldTransform = new Matrix3D(); this.viewTransform = new Matrix3D(); this.screenTransform = new Matrix3D(); _dirty = true; } /** * Rotates the transform so the forward vector points at /target/'s current position. * <p>Then it rotates the transform to point its up direction vector in the direction hinted at by the * worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. * worldUp is only a hint vector. The up vector of the rotation will only match the worldUp vector if * the forward direction is perpendicular to worldUp</p> */ public function lookAt(target:Transform3D, worldUp:Vector3D=null):void { // actually, we only make note that a lookAt is scheduled. // its up to some higher level class to deal with it. scheduledLookAt = target; scheduledLookAtUp = worldUp || DEFAULT_LOOKAT_UP; _localEulerAngles.x = 0; _localEulerAngles.y = 0; _localEulerAngles.z = 0; var eye :Vector3D = _position; var center :Vector3D = target.position; //_lookAt = MatrixUtil.createLookAtMatrix(eye, center, DEFAULT_LOOKAT_UP); /* var q :Quaternion = Quaternion.createFromMatrix(_lookAt); var euler :Vector3D = q.toEuler(); euler.x *= MathUtil.TO_DEGREES; euler.y *= MathUtil.TO_DEGREES; euler.z *= MathUtil.TO_DEGREES; _eulerAngles.x = -euler.y; _eulerAngles.y = euler.x; _eulerAngles.z = euler.z; */ //_dirty = true; } private var _lookAt :Matrix3D; /** * Applies a rotation of eulerAngles.x degrees around the x axis, eulerAngles.y degrees around * the y axis and eulerAngles.z degrees around the z axis. * * @param eulerAngles * @param relativeToSelf */ public function rotate(eulerAngles:Vector3D, relativeToSelf:Boolean=true):void { if (relativeToSelf) { _localEulerAngles.x = eulerAngles.x % 360; _localEulerAngles.y = eulerAngles.y % 360; _localEulerAngles.z = eulerAngles.z % 360; _localRotation.setFromEuler( -_localEulerAngles.y * MathUtil.TO_RADIANS, _localEulerAngles.z * MathUtil.TO_RADIANS, _localEulerAngles.x * MathUtil.TO_RADIANS ); /* var euler :Vector3D = _localRotation.toEuler(); euler.x *= MathUtil.TO_DEGREES; euler.y *= MathUtil.TO_DEGREES; euler.z *= MathUtil.TO_DEGREES; _localEulerAngles.x = -euler.y; _localEulerAngles.y = euler.x; _localEulerAngles.z = euler.z; */ } else { _eulerAngles.x = eulerAngles.x % 360; _eulerAngles.y = eulerAngles.y % 360; _eulerAngles.z = eulerAngles.z % 360; _rotation.setFromEuler( -_eulerAngles.y * MathUtil.TO_RADIANS, _eulerAngles.z * MathUtil.TO_RADIANS, _eulerAngles.x * MathUtil.TO_RADIANS ); } _dirty = true; } /** * */ public function get dirty():Boolean { return _dirty; } public function set dirty(value:Boolean):void { _dirty = value; } /** * The rotation as Euler angles in degrees. */ public function get eulerAngles():Vector3D { return _eulerAngles; } public function set eulerAngles(value:Vector3D):void { _eulerAngles = value; _dirty = true; } /** * The rotation as Euler angles in degrees relative to the parent transform's rotation. */ public function get localEulerAngles():Vector3D { return _localEulerAngles; } public function set localEulerAngles(value:Vector3D):void { _localEulerAngles = value; _dirty = true; } /** * */ public function get localToWorldMatrix():Matrix3D { if (_dirty) { if (false) { _transform.rawData = _lookAt.rawData; //_transform.prependTranslation( -_localPosition.x, -_localPosition.y, -_localPosition.z); _transform.append(_localRotation.matrix); var euler :Vector3D = Quaternion.createFromMatrix(_transform).toEuler(); euler.x *= MathUtil.TO_DEGREES; euler.y *= MathUtil.TO_DEGREES; euler.z *= MathUtil.TO_DEGREES; //_localEulerAngles.x = -euler.y; //_localEulerAngles.y = euler.x; //_localEulerAngles.z = euler.z; _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); _lookAt = null; } else { rotate( _localEulerAngles, true ); _transform.rawData = _localRotation.matrix.rawData; _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); } rotate( _eulerAngles, false ); _transform.append( _rotation.matrix ); _transform.prependScale(_localScale.x, _localScale.y, _localScale.z); _dirty = false; } return _transform; } /** * The position of the transform in world space. */ public function get position():Vector3D { return _position; } public function set position(value:Vector3D):void { _position = value; _dirty = true; } /** * Position of the transform relative to the parent transform. */ public function get localPosition():Vector3D { return _localPosition; } public function set localPosition(value:Vector3D):void { _localPosition = value; _dirty = true; } /** * */ public function get rotation():Quaternion { return _rotation; } public function set rotation(value:Quaternion):void { _rotation = value; } /** * */ public function get localRotation():Quaternion { return _localRotation; } public function set localRotation(value:Quaternion):void { _localRotation = value; } /** * */ public function get localScale():Vector3D { return _localScale; } public function set localScale(value:Vector3D):void { _localScale = value; _dirty = true; } public function get parent():Transform3D { return _parent; } public function set parent(value:Transform3D):void { _parent = value; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as index 85a9c29..ebe53f4 100755 --- a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as +++ b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as @@ -1,175 +1,176 @@ package org.papervision3d.core.render.pipeline { import flash.geom.Matrix3D; import flash.geom.Rectangle; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.proto.Transform3D; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.objects.DisplayObject3D; /** * @author Tim Knip / floorplanner.com */ public class BasicPipeline implements IRenderPipeline { use namespace pv3d; private var _scheduledLookAt :Vector.<DisplayObject3D>; private var _lookAtMatrix :Matrix3D; private var _invWorldMatrix :Matrix3D; /** * */ public function BasicPipeline() { _scheduledLookAt = new Vector.<DisplayObject3D>(); _lookAtMatrix = new Matrix3D(); _invWorldMatrix = new Matrix3D(); } /** * */ public function execute(renderData:RenderData):void { var scene :DisplayObject3D = renderData.scene; var camera :Camera3D = renderData.camera; var rect :Rectangle = renderData.viewport.sizeRectangle; _scheduledLookAt.length = 0; transformToWorld(scene); // handle lookAt if (_scheduledLookAt.length) { handleLookAt(); } camera.update(rect); transformToView(camera, scene); } /** * Processes all scheduled lookAt's. */ protected function handleLookAt():void { while (_scheduledLookAt.length) { var object :DisplayObject3D = _scheduledLookAt.pop(); var parent :DisplayObject3D = object.parent as DisplayObject3D; var transform :Transform3D = object.transform; var eye :Vector3D = transform.position; var tgt :Vector3D = transform.scheduledLookAt.position; var up :Vector3D = transform.scheduledLookAtUp; - + var components :Vector.<Vector3D>; + // create the lookAt matrix MatrixUtil.createLookAtMatrix(eye, tgt, up, _lookAtMatrix); // prepend it to the world matrix object.transform.worldTransform.prepend(_lookAtMatrix); if (parent) { _invWorldMatrix.rawData = parent.transform.worldTransform.rawData; _invWorldMatrix.invert(); object.transform.worldTransform.append(_invWorldMatrix); } - var components :Vector.<Vector3D> = object.transform.worldTransform.decompose(); + components = object.transform.worldTransform.decompose(); var euler :Vector3D = components[1]; object.transform.localEulerAngles.x = -euler.x * MathUtil.TO_DEGREES; object.transform.localEulerAngles.y = euler.y * MathUtil.TO_DEGREES; object.transform.localEulerAngles.z = euler.z * MathUtil.TO_DEGREES; // clear object.transform.scheduledLookAt = null; } } /** * */ protected function transformToWorld(object:DisplayObject3D, parent:DisplayObject3D=null, processLookAt:Boolean=false):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; if (!processLookAt && object.transform.scheduledLookAt) { _scheduledLookAt.push( object ); } wt.rawData = object.transform.localToWorldMatrix.rawData; if (parent) { wt.append(parent.transform.worldTransform); } object.transform.position = wt.transformVector(object.transform.localPosition); for each (child in object._children) { transformToWorld(child, object, processLookAt); } } /** * */ protected function transformToView(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; var vt :Matrix3D = object.transform.viewTransform; vt.rawData = wt.rawData; vt.append(camera.viewMatrix); if (object.renderer.geometry is VertexGeometry) { projectVertices(camera, object); } for each (child in object._children) { transformToView(camera, child); } } /** * */ protected function projectVertices(camera:Camera3D, object:DisplayObject3D):void { var vt :Matrix3D = object.transform.viewTransform; var st :Matrix3D = object.transform.screenTransform; var renderer : ObjectRenderer = object.renderer; // move the vertices into view / camera space // we'll need the vertices in this space to check whether vertices are behind the camera. // if we move to screen space in one go, screen vertices could move to infinity. vt.transformVectors(renderer.geometry.vertexData, renderer.viewVertexData); // append the projection matrix to the object's view matrix st.rawData = vt.rawData; st.append(camera.projectionMatrix); // move the vertices to screen space. // AKA: the perspective divide // NOTE: some vertices may have moved to infinity, we need to check while processing triangles. // IF so we need to check whether we need to clip the triangles or disgard them. Utils3D.projectVectors(st, renderer.geometry.vertexData, renderer.screenVertexData, renderer.geometry.uvtData); } } } \ No newline at end of file
timknip/papervision3d
2731145290f81a681b6eb460cf82c75aa2d1e499
sorting for tris/lines
diff --git a/src/Main.as b/src/Main.as index de5921c..d811aa6 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,176 +1,181 @@ package { import flash.display.BitmapData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public var camera2 :Camera3D; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; viewport = new Viewport3D(0, 0, true); addChild(viewport); scene = new DisplayObject3D("Scene"); camera = new Camera3D(30, 400, 2300, "Camera01"); scene.addChild( camera ); camera.enableCulling = false camera.showFrustum = false; camera.z = 800; renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; var bmp:BitmapData = new BitmapData(256, 256); bmp.perlinNoise(256, 256, 2, 300, true, false); cube = new Cube(new BitmapMaterial(bmp), 100, "Cube"); + + + var cubeChildx : Cube = new Cube(new BitmapMaterial(new BitmapData(256, 256, true, 0x6600FFFF)), 100); + cubeChildx.x = 100; + cube.addChild(cubeChildx); //cube = new Cube(new WireframeMaterial(0xFF0000), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; cubeChild1.scaleX = 5; cubeChild1.scaleY = 5; cubeChild1.scaleZ = 0.1; scene.addChild( cube ); camera2 = new Camera3D(50, 50, 500); cube.addChild(camera2); camera2.showFrustum = true; - cube.scaleX = 2; + //cube.scaleX = 2; //var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); //scene.addChild(plane); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { camera2.frustumGeometry.update(camera2); // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); //cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z--; cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; - _r += Math.PI / 180; + _r += Math.PI / 180 * 0.25; _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/core/render/draw/items/AbstractDrawable.as b/src/org/papervision3d/core/render/draw/items/AbstractDrawable.as index 138e297..b75a752 100755 --- a/src/org/papervision3d/core/render/draw/items/AbstractDrawable.as +++ b/src/org/papervision3d/core/render/draw/items/AbstractDrawable.as @@ -1,15 +1,16 @@ package org.papervision3d.core.render.draw.items { import org.papervision3d.materials.AbstractMaterial; public class AbstractDrawable implements IDrawable { public var material :AbstractMaterial; + public var screenZ :Number; public function AbstractDrawable() { this.material = null; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as index 6f1d1b1..8371306 100755 --- a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as +++ b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as @@ -1,50 +1,50 @@ package org.papervision3d.core.render.draw.items { import __AS3__.vec.Vector; import flash.display.GraphicsTrianglePath; public class TriangleDrawable extends AbstractDrawable { - public var screenZ :Number; + public var x0 :Number; public var y0 :Number; public var x1 :Number; public var y1 :Number; public var x2 :Number; public var y2 :Number; public var uvtData :Vector.<Number>; private var _path:GraphicsTrianglePath; public function TriangleDrawable() { this.screenZ = 0; _path = new GraphicsTrianglePath(); _path.vertices = new Vector.<Number>(); _path.vertices.push(0, 0, 0, 0, 0, 0); } public function toViewportSpace(hw:Number, hh:Number):void{ x0 *= hw; y0 *= hh; x1 *= hw; y1 *= hh; x2 *= hw; y2 *= hh; } public function get path():GraphicsTrianglePath{ _path.vertices[0] = x0; _path.vertices[1] = y0; _path.vertices[2] = x1; _path.vertices[3] = y1; _path.vertices[4] = x2; _path.vertices[5] = y2; _path.uvtData = uvtData; return _path; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/list/AbstractDrawableList.as b/src/org/papervision3d/core/render/draw/list/AbstractDrawableList.as index e9f82ea..c24c6d0 100755 --- a/src/org/papervision3d/core/render/draw/list/AbstractDrawableList.as +++ b/src/org/papervision3d/core/render/draw/list/AbstractDrawableList.as @@ -1,25 +1,37 @@ package org.papervision3d.core.render.draw.list { - import org.papervision3d.core.render.draw.items.IDrawable; + import org.papervision3d.core.render.draw.items.AbstractDrawable; + import org.papervision3d.core.render.draw.sort.IDrawSorter; public class AbstractDrawableList implements IDrawableList { + protected var _sorter : IDrawSorter; + public function AbstractDrawableList() { } - public function addDrawable(drawable:IDrawable):void + public function addDrawable(drawable:AbstractDrawable):void { } public function clear():void { } - public function get drawables():Vector.<IDrawable> + public function get drawables():Vector.<AbstractDrawable> { return null; } + public function set sorter(sorter:IDrawSorter):void{ + _sorter = sorter; + _sorter.drawlist = this; + } + + public function get sorter():IDrawSorter{ + return _sorter; + } + } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/list/DrawableList.as b/src/org/papervision3d/core/render/draw/list/DrawableList.as index 2fa1b43..f6bb796 100755 --- a/src/org/papervision3d/core/render/draw/list/DrawableList.as +++ b/src/org/papervision3d/core/render/draw/list/DrawableList.as @@ -1,29 +1,32 @@ package org.papervision3d.core.render.draw.list { + import org.papervision3d.core.render.draw.items.AbstractDrawable; import org.papervision3d.core.render.draw.items.IDrawable; public class DrawableList extends AbstractDrawableList implements IDrawableList { - private var _drawables :Vector.<IDrawable>; + private var _drawables :Vector.<AbstractDrawable>; public function DrawableList() { - _drawables = new Vector.<IDrawable>(); + _drawables = new Vector.<AbstractDrawable>(); } - public override function addDrawable(drawable:IDrawable):void + public override function addDrawable(drawable:AbstractDrawable):void { _drawables.push(drawable); } public override function clear():void { _drawables.length = 0; } - public override function get drawables():Vector.<IDrawable> + public override function get drawables():Vector.<AbstractDrawable> { return _drawables; } + + } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/list/IDrawableList.as b/src/org/papervision3d/core/render/draw/list/IDrawableList.as index f7e070f..eb386af 100755 --- a/src/org/papervision3d/core/render/draw/list/IDrawableList.as +++ b/src/org/papervision3d/core/render/draw/list/IDrawableList.as @@ -1,11 +1,15 @@ package org.papervision3d.core.render.draw.list { - import org.papervision3d.core.render.draw.items.IDrawable; + import org.papervision3d.core.render.draw.items.AbstractDrawable; + import org.papervision3d.core.render.draw.sort.IDrawSorter; public interface IDrawableList { - function addDrawable(drawable:IDrawable):void; + function addDrawable(drawable:AbstractDrawable):void; function clear():void; - function get drawables():Vector.<IDrawable>; + function get drawables():Vector.<AbstractDrawable>; + function set sorter(sorter:IDrawSorter):void; + function get sorter():IDrawSorter; + } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/sort/DefaultDrawSorter.as b/src/org/papervision3d/core/render/draw/sort/DefaultDrawSorter.as new file mode 100644 index 0000000..1f517c3 --- /dev/null +++ b/src/org/papervision3d/core/render/draw/sort/DefaultDrawSorter.as @@ -0,0 +1,31 @@ +package org.papervision3d.core.render.draw.sort +{ + import __AS3__.vec.Vector; + + import org.papervision3d.core.render.draw.items.AbstractDrawable; + import org.papervision3d.core.render.draw.list.IDrawableList; + + public class DefaultDrawSorter implements IDrawSorter + { + protected var _drawList : IDrawableList; + public function DefaultDrawSorter() + { + } + + public function sort():void + { + var v:Vector.<AbstractDrawable> = _drawList.drawables; + v.sort(screenZCompare); + + } + + public function set drawlist(list:IDrawableList):void{ + _drawList = list; + } + + private function screenZCompare(x:AbstractDrawable, y:AbstractDrawable):Number{ + return x.screenZ-y.screenZ; + } + + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/sort/IDrawSorter.as b/src/org/papervision3d/core/render/draw/sort/IDrawSorter.as new file mode 100644 index 0000000..057ebec --- /dev/null +++ b/src/org/papervision3d/core/render/draw/sort/IDrawSorter.as @@ -0,0 +1,10 @@ +package org.papervision3d.core.render.draw.sort +{ + import org.papervision3d.core.render.draw.list.IDrawableList; + + public interface IDrawSorter + { + function sort():void; + function set drawlist(list:IDrawableList):void; + } +} \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 2f97f65..16284b7 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,455 +1,458 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.LineGeometry; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.LineDrawable; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; + import org.papervision3d.core.render.draw.sort.DefaultDrawSorter; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; - import org.papervision3d.objects.primitives.Frustum; import org.papervision3d.view.Viewport3D; /** * @author Tim Knip / floorplanner.com */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; public var renderer : ObjectRenderer; private var _clipFlags :uint; private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); + renderList.sorter = new DefaultDrawSorter(); + clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); _drawablePool.reset(); fillRenderList(camera, scene); - + renderList.sorter.sort(); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var sv0 :Vector3D = new Vector3D(); var sv1 :Vector3D = new Vector3D(); var sv2 :Vector3D = new Vector3D(); renderer = object.renderer; stats.totalObjects++; if (object.cullingState == 0 && object.renderer.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.renderer.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = renderer.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = renderer.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = renderer.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = renderer.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = renderer.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = renderer.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = renderer.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = renderer.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = renderer.viewVertexData[ triangle.v2.vectorIndexZ ]; // Setup clipflags for the triangle (detect whether the tri is in, out or straddling // the frustum). // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // passed the near test loosely, verts may have projected to infinity // we do it here, cause - paranoia - even these array accesses may cost us sv0.x = renderer.screenVertexData[ triangle.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ triangle.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ triangle.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ triangle.v1.screenIndexY ]; sv2.x = renderer.screenVertexData[ triangle.v2.screenIndexX ]; sv2.y = renderer.screenVertexData[ triangle.v2.screenIndexY ]; // When *not* straddling the near plane we can safely test for backfacing triangles // (as we're sure the infinity case is filtered out). // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } // Okay, all vertices are in front of the near plane and backfacing tris are gone. // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = sv0.x; drawable.y0 = sv0.y; drawable.x1 = sv1.x; drawable.y1 = sv1.y; drawable.x2 = sv2.x; drawable.y2 = sv2.y; drawable.uvtData = drawable.uvtData || new Vector.<Number>(9, true); drawable.uvtData[0] = triangle.uv0.u; drawable.uvtData[1] = triangle.uv0.v; drawable.uvtData[2] = renderer.geometry.uvtData[ triangle.v0.vectorIndexZ ]; drawable.uvtData[3] = triangle.uv1.u; drawable.uvtData[4] = triangle.uv1.v; drawable.uvtData[5] = renderer.geometry.uvtData[ triangle.v1.vectorIndexZ ]; drawable.uvtData[6] = triangle.uv2.u; drawable.uvtData[7] = triangle.uv2.v; drawable.uvtData[8] = renderer.geometry.uvtData[ triangle.v2.vectorIndexZ ]; drawable.material = triangle.material; //trace(renderer.geometry.uvtData); renderList.addDrawable(drawable); triangle.drawable = drawable; } else { // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } else if (object.cullingState == 0 && object.renderer.geometry is LineGeometry) { var lineGeometry:LineGeometry = LineGeometry(object.renderer.geometry); var line :Line; for each (line in lineGeometry.lines) { var lineDrawable :LineDrawable = line.drawable as LineDrawable || new LineDrawable(); sv0.x = renderer.screenVertexData[ line.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ line.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ line.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ line.v1.screenIndexY ]; lineDrawable.x0 = sv0.x; lineDrawable.y0 = sv0.y; lineDrawable.x1 = sv1.x; lineDrawable.y1 = sv1.y; + lineDrawable.screenZ = (renderer.viewVertexData[line.v0.vectorIndexZ]+renderer.viewVertexData[line.v1.vectorIndexZ])*0.5; lineDrawable.material = line.material; renderList.addDrawable(lineDrawable); } } // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); var uvtData :Vector.<Number> = renderer.geometry.uvtData; var inUVT :Vector.<Number> = Vector.<Number>([ triangle.uv0.u, triangle.uv0.v, 0, triangle.uv1.u, triangle.uv1.v, 0, triangle.uv2.u, triangle.uv2.v, 0 ]); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.uvtData = drawable.uvtData || new Vector.<Number>(9, true); drawable.uvtData[0] = inUVT[0]; drawable.uvtData[1] = inUVT[1]; drawable.uvtData[2] = inUVT[2]; drawable.uvtData[3] = inUVT[i3+3]; drawable.uvtData[4] = inUVT[i3+4]; drawable.uvtData[5] = inUVT[i3+5]; drawable.uvtData[6] = inUVT[i3+6]; drawable.uvtData[7] = inUVT[i3+7]; drawable.uvtData[8] = inUVT[i3+8]; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
1b7e23a93af7649a270ccfa79e116630b801efee
uvt fix
diff --git a/src/Main.as b/src/Main.as index 9412ad8..de5921c 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,173 +1,176 @@ package { import flash.display.BitmapData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public var camera2 :Camera3D; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; viewport = new Viewport3D(0, 0, true); addChild(viewport); scene = new DisplayObject3D("Scene"); camera = new Camera3D(30, 400, 2300, "Camera01"); scene.addChild( camera ); - camera.enableCulling = false; + camera.enableCulling = false + camera.showFrustum = false; camera.z = 800; renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; var bmp:BitmapData = new BitmapData(256, 256); bmp.perlinNoise(256, 256, 2, 300, true, false); cube = new Cube(new BitmapMaterial(bmp), 100, "Cube"); + //cube = new Cube(new WireframeMaterial(0xFF0000), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; cubeChild1.scaleX = 5; cubeChild1.scaleY = 5; cubeChild1.scaleZ = 0.1; scene.addChild( cube ); camera2 = new Camera3D(50, 50, 500); cube.addChild(camera2); - + camera2.showFrustum = true; + cube.scaleX = 2; //var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); //scene.addChild(plane); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { - //camera2.frustumGeometry.update(camera2); + camera2.frustumGeometry.update(camera2); // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); //cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z--; cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/cameras/Camera3D.as b/src/org/papervision3d/cameras/Camera3D.as index 753cab9..b1ecb67 100755 --- a/src/org/papervision3d/cameras/Camera3D.as +++ b/src/org/papervision3d/cameras/Camera3D.as @@ -1,253 +1,266 @@ package org.papervision3d.cameras { import flash.geom.Matrix3D; import flash.geom.Rectangle; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Frustum; /** * @author Tim Knip / floorplanner.com */ public class Camera3D extends DisplayObject3D { use namespace pv3d; public var projectionMatrix :Matrix3D; public var viewMatrix :Matrix3D; public var frustum :Frustum3D; private var _dirty:Boolean; private var _fov:Number; private var _far:Number; private var _near:Number; private var _ortho:Boolean; private var _orthoScale:Number; private var _aspectRatio :Number; private var _enableCulling :Boolean; private var _worldCullingMatrix :Matrix3D; private var _frustumGeometry :Frustum; - private var _showFrustumGeometry :Boolean; + private var _showFrustum :Boolean; /** * Constructor. * * @param fov * @param near * @param far * @param name */ public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, name:String=null) { super(name); _fov = fov; _near = near; _far = far; _dirty = true; _ortho = false; _orthoScale = 1; _enableCulling = false; _worldCullingMatrix = new Matrix3D(); _frustumGeometry = new Frustum(new WireframeMaterial(0x0000ff), "frustum-geometry"); - _showFrustumGeometry = false; + _showFrustum = false; frustum = new Frustum3D(this); viewMatrix = new Matrix3D(); } /** * */ public function update(viewport:Rectangle) : void { var aspect :Number = viewport.width / viewport.height; viewMatrix.rawData = transform.worldTransform.rawData; viewMatrix.invert(); if (_aspectRatio != aspect) { _aspectRatio = aspect; _dirty = true; } if(_dirty) { _dirty = false; if(_ortho) { projectionMatrix = MatrixUtil.createOrthoMatrix(-viewport.width, viewport.width, viewport.height, -viewport.height, _far, -_far); } else { projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); } // extract the view clipping planes frustum.extractPlanes(projectionMatrix, Frustum3D.VIEW_PLANES); - if (_showFrustumGeometry) + if (_showFrustum) { _frustumGeometry.update(this); } } // TODO: sniff whether our transform was dirty, no need to calc when camera didn't move. if (_enableCulling) { _worldCullingMatrix.rawData = viewMatrix.rawData; _worldCullingMatrix.append(projectionMatrix); // TODO: why this is needed is weird. If we don't the culling / clipping planes don't // seem to match. With this hack all ok... // Tim: Think its got to do with a discrepancy between GL viewport and // our draw-container sitting at center stage. _worldCullingMatrix.prependScale(0.5, 0.5, 0.5); // extract the world clipping planes frustum.extractPlanes(_worldCullingMatrix, Frustum3D.WORLD_PLANES, false); } } /** * */ public function get aspectRatio():Number { return _aspectRatio; } + /** + * + */ + public function get dirty():Boolean + { + return _dirty; + } + + public function set dirty(value:Boolean):void + { + _dirty = value; + } + /** * */ public function get enableCulling():Boolean { return _enableCulling; } public function set enableCulling(value:Boolean):void { _enableCulling = value; } /** * Distance to the far clipping plane. */ public function get far():Number { return _far; } public function set far(value:Number):void { if (value != _far && value > _near) { _far = value; _dirty = true; } } /** * Field of view (vertical) in degrees. */ public function get fov():Number { return _fov; } public function set fov(value:Number):void { if (value != _fov) { _fov = value; _dirty = true; } } /** * Distance to the near clipping plane. */ public function get near():Number { return _near; } public function set near(value:Number):void { if (value != _near && value > 0 && value < _far) { _near = value; _dirty = true; } } /** * Whether to use a orthogonal projection. */ public function get ortho():Boolean { return _ortho; } public function set ortho(value:Boolean):void { if (value != _ortho) { _ortho = value; _dirty = true; } } /** * Scale of the orthogonal projection. */ public function get orthoScale():Number { return _orthoScale; } public function set orthoScale(value:Number):void { if (value != _orthoScale) { _orthoScale = value; _dirty = true; } } public function get frustumGeometry():Frustum { return _frustumGeometry; } - public function get showFrustumGeometry():Boolean + public function get showFrustum():Boolean { - return _showFrustumGeometry; + return _showFrustum; } - public function set showFrustumGeometry(value:Boolean):void + public function set showFrustum(value:Boolean):void { if (value) { if (!findChild(_frustumGeometry)) { addChild(_frustumGeometry); } } else { removeChild(_frustumGeometry); } - _showFrustumGeometry = value; + _showFrustum = value; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/Triangle.as b/src/org/papervision3d/core/geom/Triangle.as index faace15..463dd03 100755 --- a/src/org/papervision3d/core/geom/Triangle.as +++ b/src/org/papervision3d/core/geom/Triangle.as @@ -1,65 +1,65 @@ package org.papervision3d.core.geom { import flash.geom.Vector3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.draw.items.IDrawable; import org.papervision3d.materials.AbstractMaterial; public class Triangle { use namespace pv3d; /** */ public var v0 :Vertex; /** */ public var v1 :Vertex; /** */ public var v2 :Vertex; /** */ public var normal :Vector3D; /** */ public var uv0 :UVCoord; /** */ public var uv1 :UVCoord; /** */ public var uv2 :UVCoord; /** */ public var visible :Boolean; /** */ public var material : AbstractMaterial; /** */ pv3d var clipFlags :int; /** */ pv3d var drawable :IDrawable; /** * Constructor * * @param * @param * @param */ public function Triangle(material:AbstractMaterial, v0:Vertex, v1:Vertex, v2:Vertex, uv0:UVCoord=null, uv1:UVCoord=null, uv2:UVCoord=null) { this.material = material; this.v0 = v0; this.v1 = v1; this.v2 = v2; - this.uv0 = new UVCoord(uv0.u, uv0.v) || new UVCoord(); - this.uv1 = new UVCoord(uv1.u, uv1.v) || new UVCoord(); - this.uv2 = new UVCoord(uv2.u, uv2.v) || new UVCoord(); + this.uv0 = uv0 || new UVCoord(); + this.uv1 = uv1 || new UVCoord(); + this.uv2 = uv2 || new UVCoord(); this.visible = true; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/provider/TriangleGeometry.as b/src/org/papervision3d/core/geom/provider/TriangleGeometry.as index 7c65af8..f7408a4 100755 --- a/src/org/papervision3d/core/geom/provider/TriangleGeometry.as +++ b/src/org/papervision3d/core/geom/provider/TriangleGeometry.as @@ -1,84 +1,72 @@ package org.papervision3d.core.geom.provider { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.Vertex; public class TriangleGeometry extends VertexGeometry { /** */ public var triangles :Vector.<Triangle>; /** * */ public function TriangleGeometry(name:String=null) { super(name); this.triangles = new Vector.<Triangle>(); } /** * Adds a triangle. * * @param triangle * * @return The added triangle. */ public function addTriangle(triangle:Triangle):Triangle { var index :int = triangles.indexOf(triangle); if (index < 0) { triangle.v0 = addVertex(triangle.v0); triangle.v1 = addVertex(triangle.v1); triangle.v2 = addVertex(triangle.v2); - uvtData[ triangle.v0.vectorIndexX ] = triangle.uv0.u; - uvtData[ triangle.v0.vectorIndexY ] = triangle.uv0.v; - uvtData[ triangle.v0.vectorIndexZ ] = 0; - - uvtData[ triangle.v1.vectorIndexX ] = triangle.uv1.u; - uvtData[ triangle.v1.vectorIndexY ] = triangle.uv1.v; - uvtData[ triangle.v1.vectorIndexZ ] = 0; - - uvtData[ triangle.v2.vectorIndexX ] = triangle.uv2.u; - uvtData[ triangle.v2.vectorIndexY ] = triangle.uv2.v; - uvtData[ triangle.v2.vectorIndexZ ] = 0; - triangles.push(triangle); - + return triangle; } else { return triangles[index]; } } /** * */ public function mergeVertices(treshold:Number=0.01):void { var triangle :Triangle; removeAllVertices(); for each (triangle in triangles) { var v0 :Vertex = findVertexInRange(triangle.v0, treshold); var v1 :Vertex = findVertexInRange(triangle.v1, treshold); var v2 :Vertex = findVertexInRange(triangle.v2, treshold); if (!v0) v0 = addVertex(triangle.v0); if (!v1) v1 = addVertex(triangle.v1); if (!v2) v2 = addVertex(triangle.v2); triangle.v0 = v0; triangle.v1 = v1; triangle.v2 = v2; } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/object/ObjectRenderer.as b/src/org/papervision3d/core/render/object/ObjectRenderer.as index d3590cc..62f2932 100644 --- a/src/org/papervision3d/core/render/object/ObjectRenderer.as +++ b/src/org/papervision3d/core/render/object/ObjectRenderer.as @@ -1,28 +1,25 @@ package org.papervision3d.core.render.object { - import __AS3__.vec.Vector; - import org.papervision3d.core.geom.provider.VertexGeometry; public class ObjectRenderer { public var geometry : VertexGeometry; public var viewVertexData :Vector.<Number>; public var screenVertexData :Vector.<Number>; public function ObjectRenderer() { viewVertexData = new Vector.<Number>(); screenVertexData = new Vector.<Number>(); - } public function updateIndices():void{ viewVertexData.length = geometry.viewVertexLength; screenVertexData.length = geometry.screenVertexLength; } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Cube.as b/src/org/papervision3d/objects/primitives/Cube.as index 6cc89a5..b512a16 100755 --- a/src/org/papervision3d/objects/primitives/Cube.as +++ b/src/org/papervision3d/objects/primitives/Cube.as @@ -1,83 +1,83 @@ package org.papervision3d.objects.primitives { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.UVCoord; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.materials.AbstractMaterial; /** * */ public class Cube extends DisplayObject3D { /** * */ private var triGeometry : TriangleGeometry; public function Cube(material:AbstractMaterial, size:Number = 100, name:String=null) { super(name); this.material = material; renderer.geometry = triGeometry = new TriangleGeometry(); create(size); } /** * */ protected function create(size:Number):void { var sz : Number = size / 2; var v :Array = [ new Vertex(-sz, sz, -sz), new Vertex(sz, sz, -sz), new Vertex(sz, -sz, -sz), new Vertex(-sz, -sz, -sz), new Vertex(-sz, sz, sz), new Vertex(sz, sz, sz), new Vertex(sz, -sz, sz), new Vertex(-sz, -sz, sz) ]; var vertex : Vertex; for each(vertex in v) { this.renderer.geometry.addVertex(vertex); } var uv0 :UVCoord = new UVCoord(0, 1); var uv1 :UVCoord = new UVCoord(0, 0); var uv2 :UVCoord = new UVCoord(1, 0); var uv3 :UVCoord = new UVCoord(1, 1); // top triGeometry.addTriangle(new Triangle(material, v[0], v[4], v[5], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(material, v[0], v[5], v[1], uv0, uv2, uv3) ); // bottom triGeometry.addTriangle(new Triangle(material, v[6], v[7], v[3], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(material, v[6], v[3], v[2], uv2, uv0, uv3) ); // left triGeometry.addTriangle(new Triangle(material, v[0], v[3], v[7], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(material, v[0], v[7], v[4], uv1, uv3, uv2) ); // right triGeometry.addTriangle(new Triangle(material, v[5], v[6], v[2], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(material, v[5], v[2], v[1], uv1, uv3, uv2) ); // front triGeometry.addTriangle(new Triangle(material, v[0], v[1], v[2], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(material, v[0], v[2], v[3], uv2, uv0, uv3) ); // back triGeometry.addTriangle(new Triangle(material, v[6], v[5], v[4], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(material, v[6], v[4], v[7], uv0, uv2, uv3) ); - renderer.updateIndices(); + // renderer.updateIndices(); } } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 7494fc9..2f97f65 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,449 +1,455 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.LineGeometry; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.LineDrawable; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Frustum; import org.papervision3d.view.Viewport3D; /** * @author Tim Knip / floorplanner.com */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; + public var renderer : ObjectRenderer; private var _clipFlags :uint; private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); _drawablePool.reset(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { - var renderer : ObjectRenderer = object.renderer; var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var sv0 :Vector3D = new Vector3D(); var sv1 :Vector3D = new Vector3D(); var sv2 :Vector3D = new Vector3D(); - + + renderer = object.renderer; stats.totalObjects++; if (object.cullingState == 0 && object.renderer.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.renderer.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = renderer.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = renderer.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = renderer.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = renderer.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = renderer.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = renderer.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = renderer.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = renderer.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = renderer.viewVertexData[ triangle.v2.vectorIndexZ ]; // Setup clipflags for the triangle (detect whether the tri is in, out or straddling // the frustum). // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // passed the near test loosely, verts may have projected to infinity // we do it here, cause - paranoia - even these array accesses may cost us sv0.x = renderer.screenVertexData[ triangle.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ triangle.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ triangle.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ triangle.v1.screenIndexY ]; sv2.x = renderer.screenVertexData[ triangle.v2.screenIndexX ]; sv2.y = renderer.screenVertexData[ triangle.v2.screenIndexY ]; // When *not* straddling the near plane we can safely test for backfacing triangles // (as we're sure the infinity case is filtered out). // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } // Okay, all vertices are in front of the near plane and backfacing tris are gone. // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = sv0.x; drawable.y0 = sv0.y; drawable.x1 = sv1.x; drawable.y1 = sv1.y; drawable.x2 = sv2.x; drawable.y2 = sv2.y; drawable.uvtData = drawable.uvtData || new Vector.<Number>(9, true); - drawable.uvtData[0] = renderer.geometry.uvtData[ triangle.v0.vectorIndexX ]; - drawable.uvtData[1] = renderer.geometry.uvtData[ triangle.v0.vectorIndexY ]; + drawable.uvtData[0] = triangle.uv0.u; + drawable.uvtData[1] = triangle.uv0.v; drawable.uvtData[2] = renderer.geometry.uvtData[ triangle.v0.vectorIndexZ ]; - drawable.uvtData[3] = renderer.geometry.uvtData[ triangle.v1.vectorIndexX ]; - drawable.uvtData[4] = renderer.geometry.uvtData[ triangle.v1.vectorIndexY ]; + drawable.uvtData[3] = triangle.uv1.u; + drawable.uvtData[4] = triangle.uv1.v; drawable.uvtData[5] = renderer.geometry.uvtData[ triangle.v1.vectorIndexZ ]; - drawable.uvtData[6] = renderer.geometry.uvtData[ triangle.v2.vectorIndexX ]; - drawable.uvtData[7] = renderer.geometry.uvtData[ triangle.v2.vectorIndexY ]; + drawable.uvtData[6] = triangle.uv2.u; + drawable.uvtData[7] = triangle.uv2.v; drawable.uvtData[8] = renderer.geometry.uvtData[ triangle.v2.vectorIndexZ ]; drawable.material = triangle.material; - + //trace(renderer.geometry.uvtData); renderList.addDrawable(drawable); triangle.drawable = drawable; } else { // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } else if (object.cullingState == 0 && object.renderer.geometry is LineGeometry) { var lineGeometry:LineGeometry = LineGeometry(object.renderer.geometry); var line :Line; for each (line in lineGeometry.lines) { var lineDrawable :LineDrawable = line.drawable as LineDrawable || new LineDrawable(); sv0.x = renderer.screenVertexData[ line.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ line.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ line.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ line.v1.screenIndexY ]; lineDrawable.x0 = sv0.x; lineDrawable.y0 = sv0.y; lineDrawable.x1 = sv1.x; lineDrawable.y1 = sv1.y; lineDrawable.material = line.material; renderList.addDrawable(lineDrawable); } } // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); - var inUVT :Vector.<Number> = Vector.<Number>([triangle.uv0.u, triangle.uv0.v, 0, triangle.uv1.u, triangle.uv1.v, 0, triangle.uv2.u, triangle.uv2.v, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); + var uvtData :Vector.<Number> = renderer.geometry.uvtData; + var inUVT :Vector.<Number> = Vector.<Number>([ + triangle.uv0.u, triangle.uv0.v, 0, + triangle.uv1.u, triangle.uv1.v, 0, + triangle.uv2.u, triangle.uv2.v, 0 + ]); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.uvtData = drawable.uvtData || new Vector.<Number>(9, true); drawable.uvtData[0] = inUVT[0]; drawable.uvtData[1] = inUVT[1]; drawable.uvtData[2] = inUVT[2]; drawable.uvtData[3] = inUVT[i3+3]; drawable.uvtData[4] = inUVT[i3+4]; drawable.uvtData[5] = inUVT[i3+5]; drawable.uvtData[6] = inUVT[i3+6]; drawable.uvtData[7] = inUVT[i3+7]; drawable.uvtData[8] = inUVT[i3+8]; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
f10e2099cf458560e639340c7586d757e72e3ac2
not sure what i did :-)
diff --git a/src/org/papervision3d/core/geom/Triangle.as b/src/org/papervision3d/core/geom/Triangle.as index 463dd03..faace15 100755 --- a/src/org/papervision3d/core/geom/Triangle.as +++ b/src/org/papervision3d/core/geom/Triangle.as @@ -1,65 +1,65 @@ package org.papervision3d.core.geom { import flash.geom.Vector3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.draw.items.IDrawable; import org.papervision3d.materials.AbstractMaterial; public class Triangle { use namespace pv3d; /** */ public var v0 :Vertex; /** */ public var v1 :Vertex; /** */ public var v2 :Vertex; /** */ public var normal :Vector3D; /** */ public var uv0 :UVCoord; /** */ public var uv1 :UVCoord; /** */ public var uv2 :UVCoord; /** */ public var visible :Boolean; /** */ public var material : AbstractMaterial; /** */ pv3d var clipFlags :int; /** */ pv3d var drawable :IDrawable; /** * Constructor * * @param * @param * @param */ public function Triangle(material:AbstractMaterial, v0:Vertex, v1:Vertex, v2:Vertex, uv0:UVCoord=null, uv1:UVCoord=null, uv2:UVCoord=null) { this.material = material; this.v0 = v0; this.v1 = v1; this.v2 = v2; - this.uv0 = uv0 || new UVCoord(); - this.uv1 = uv1 || new UVCoord(); - this.uv2 = uv2 || new UVCoord(); + this.uv0 = new UVCoord(uv0.u, uv0.v) || new UVCoord(); + this.uv1 = new UVCoord(uv1.u, uv1.v) || new UVCoord(); + this.uv2 = new UVCoord(uv2.u, uv2.v) || new UVCoord(); this.visible = true; } } } \ No newline at end of file
timknip/papervision3d
82480a5dd99985d7e2b71101a6951d6af6216651
bitmap texture
diff --git a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as index 833811e..6f1d1b1 100755 --- a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as +++ b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as @@ -1,49 +1,50 @@ package org.papervision3d.core.render.draw.items { import __AS3__.vec.Vector; import flash.display.GraphicsTrianglePath; public class TriangleDrawable extends AbstractDrawable { public var screenZ :Number; public var x0 :Number; public var y0 :Number; public var x1 :Number; public var y1 :Number; public var x2 :Number; public var y2 :Number; public var uvtData :Vector.<Number>; private var _path:GraphicsTrianglePath; public function TriangleDrawable() { this.screenZ = 0; _path = new GraphicsTrianglePath(); _path.vertices = new Vector.<Number>(); _path.vertices.push(0, 0, 0, 0, 0, 0); } public function toViewportSpace(hw:Number, hh:Number):void{ x0 *= hw; y0 *= hh; x1 *= hw; y1 *= hh; x2 *= hw; y2 *= hh; } public function get path():GraphicsTrianglePath{ _path.vertices[0] = x0; _path.vertices[1] = y0; _path.vertices[2] = x1; _path.vertices[3] = y1; _path.vertices[4] = x2; _path.vertices[5] = y2; + _path.uvtData = uvtData; return _path; } } } \ No newline at end of file
timknip/papervision3d
824bccc4ff3fab9cc0e9ecce396e0ceea686bb5e
bitmap texture
diff --git a/src/Main.as b/src/Main.as index 81669d3..9412ad8 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,169 +1,173 @@ package { + import flash.display.BitmapData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; + import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; - import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public var camera2 :Camera3D; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; viewport = new Viewport3D(0, 0, true); addChild(viewport); scene = new DisplayObject3D("Scene"); camera = new Camera3D(30, 400, 2300, "Camera01"); scene.addChild( camera ); camera.enableCulling = false; camera.z = 800; renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; - cube = new Cube(new WireframeMaterial(), 100, "Cube"); + var bmp:BitmapData = new BitmapData(256, 256); + bmp.perlinNoise(256, 256, 2, 300, true, false); + + cube = new Cube(new BitmapMaterial(bmp), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; cubeChild1.scaleX = 5; cubeChild1.scaleY = 5; cubeChild1.scaleZ = 0.1; scene.addChild( cube ); camera2 = new Camera3D(50, 50, 500); cube.addChild(camera2); //var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); //scene.addChild(plane); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { //camera2.frustumGeometry.update(camera2); // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); //cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z--; cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/materials/BitmapMaterial.as b/src/org/papervision3d/materials/BitmapMaterial.as new file mode 100644 index 0000000..73a9848 --- /dev/null +++ b/src/org/papervision3d/materials/BitmapMaterial.as @@ -0,0 +1,19 @@ +package org.papervision3d.materials +{ + import flash.display.BitmapData; + import flash.display.GraphicsBitmapFill; + import flash.display.GraphicsEndFill; + + public class BitmapMaterial extends AbstractMaterial + { + public function BitmapMaterial(bitmapData:BitmapData) + { + super(); + + var graphicsFill : GraphicsBitmapFill = new GraphicsBitmapFill(bitmapData); + this.drawProperties = graphicsFill; + this.clear = new GraphicsEndFill(); + } + + } +} \ No newline at end of file
timknip/papervision3d
e2d57a80152a63cc85fef2597d6ce5d62b4bfdca
prepping UVT
diff --git a/src/Main.as b/src/Main.as index 967575e..81669d3 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,169 +1,169 @@ package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public var camera2 :Camera3D; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; viewport = new Viewport3D(0, 0, true); addChild(viewport); scene = new DisplayObject3D("Scene"); camera = new Camera3D(30, 400, 2300, "Camera01"); scene.addChild( camera ); camera.enableCulling = false; camera.z = 800; renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; cubeChild1.scaleX = 5; cubeChild1.scaleY = 5; cubeChild1.scaleZ = 0.1; scene.addChild( cube ); camera2 = new Camera3D(50, 50, 500); cube.addChild(camera2); - var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); - scene.addChild(plane); + //var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); + //scene.addChild(plane); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { - camera2.frustumGeometry.update(camera2); + //camera2.frustumGeometry.update(camera2); // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); //cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z--; cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/cameras/Camera3D.as b/src/org/papervision3d/cameras/Camera3D.as index ed4be49..753cab9 100755 --- a/src/org/papervision3d/cameras/Camera3D.as +++ b/src/org/papervision3d/cameras/Camera3D.as @@ -1,228 +1,253 @@ package org.papervision3d.cameras { import flash.geom.Matrix3D; import flash.geom.Rectangle; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Frustum; /** * @author Tim Knip / floorplanner.com */ public class Camera3D extends DisplayObject3D { use namespace pv3d; public var projectionMatrix :Matrix3D; public var viewMatrix :Matrix3D; public var frustum :Frustum3D; private var _dirty:Boolean; private var _fov:Number; private var _far:Number; private var _near:Number; private var _ortho:Boolean; private var _orthoScale:Number; private var _aspectRatio :Number; private var _enableCulling :Boolean; private var _worldCullingMatrix :Matrix3D; private var _frustumGeometry :Frustum; + private var _showFrustumGeometry :Boolean; /** * Constructor. * * @param fov * @param near * @param far * @param name */ public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, name:String=null) { super(name); _fov = fov; _near = near; _far = far; _dirty = true; _ortho = false; _orthoScale = 1; _enableCulling = false; _worldCullingMatrix = new Matrix3D(); _frustumGeometry = new Frustum(new WireframeMaterial(0x0000ff), "frustum-geometry"); - - addChild(_frustumGeometry); - + _showFrustumGeometry = false; + frustum = new Frustum3D(this); viewMatrix = new Matrix3D(); } /** * */ public function update(viewport:Rectangle) : void { var aspect :Number = viewport.width / viewport.height; viewMatrix.rawData = transform.worldTransform.rawData; viewMatrix.invert(); if (_aspectRatio != aspect) { _aspectRatio = aspect; _dirty = true; } if(_dirty) { _dirty = false; if(_ortho) { projectionMatrix = MatrixUtil.createOrthoMatrix(-viewport.width, viewport.width, viewport.height, -viewport.height, _far, -_far); } else { projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); } // extract the view clipping planes frustum.extractPlanes(projectionMatrix, Frustum3D.VIEW_PLANES); - _frustumGeometry.update(this); + if (_showFrustumGeometry) + { + _frustumGeometry.update(this); + } } // TODO: sniff whether our transform was dirty, no need to calc when camera didn't move. if (_enableCulling) { _worldCullingMatrix.rawData = viewMatrix.rawData; _worldCullingMatrix.append(projectionMatrix); // TODO: why this is needed is weird. If we don't the culling / clipping planes don't // seem to match. With this hack all ok... // Tim: Think its got to do with a discrepancy between GL viewport and // our draw-container sitting at center stage. _worldCullingMatrix.prependScale(0.5, 0.5, 0.5); // extract the world clipping planes frustum.extractPlanes(_worldCullingMatrix, Frustum3D.WORLD_PLANES, false); } } /** * */ public function get aspectRatio():Number { return _aspectRatio; } /** * */ public function get enableCulling():Boolean { return _enableCulling; } public function set enableCulling(value:Boolean):void { _enableCulling = value; } /** * Distance to the far clipping plane. */ public function get far():Number { return _far; } public function set far(value:Number):void { if (value != _far && value > _near) { _far = value; _dirty = true; } } /** * Field of view (vertical) in degrees. */ public function get fov():Number { return _fov; } public function set fov(value:Number):void { if (value != _fov) { _fov = value; _dirty = true; } } /** * Distance to the near clipping plane. */ public function get near():Number { return _near; } public function set near(value:Number):void { if (value != _near && value > 0 && value < _far) { _near = value; _dirty = true; } } /** * Whether to use a orthogonal projection. */ public function get ortho():Boolean { return _ortho; } public function set ortho(value:Boolean):void { if (value != _ortho) { _ortho = value; _dirty = true; } } /** * Scale of the orthogonal projection. */ public function get orthoScale():Number { return _orthoScale; } public function set orthoScale(value:Number):void { if (value != _orthoScale) { _orthoScale = value; _dirty = true; } } public function get frustumGeometry():Frustum { return _frustumGeometry; } + + public function get showFrustumGeometry():Boolean + { + return _showFrustumGeometry; + } + + public function set showFrustumGeometry(value:Boolean):void + { + if (value) + { + if (!findChild(_frustumGeometry)) + { + addChild(_frustumGeometry); + } + } + else + { + removeChild(_frustumGeometry); + } + + _showFrustumGeometry = value; + } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/provider/TriangleGeometry.as b/src/org/papervision3d/core/geom/provider/TriangleGeometry.as index b71d63e..7c65af8 100755 --- a/src/org/papervision3d/core/geom/provider/TriangleGeometry.as +++ b/src/org/papervision3d/core/geom/provider/TriangleGeometry.as @@ -1,72 +1,84 @@ package org.papervision3d.core.geom.provider { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.Vertex; public class TriangleGeometry extends VertexGeometry { /** */ public var triangles :Vector.<Triangle>; /** * */ public function TriangleGeometry(name:String=null) { super(name); this.triangles = new Vector.<Triangle>(); } /** * Adds a triangle. * * @param triangle * * @return The added triangle. */ public function addTriangle(triangle:Triangle):Triangle { var index :int = triangles.indexOf(triangle); if (index < 0) { triangle.v0 = addVertex(triangle.v0); triangle.v1 = addVertex(triangle.v1); triangle.v2 = addVertex(triangle.v2); + uvtData[ triangle.v0.vectorIndexX ] = triangle.uv0.u; + uvtData[ triangle.v0.vectorIndexY ] = triangle.uv0.v; + uvtData[ triangle.v0.vectorIndexZ ] = 0; + + uvtData[ triangle.v1.vectorIndexX ] = triangle.uv1.u; + uvtData[ triangle.v1.vectorIndexY ] = triangle.uv1.v; + uvtData[ triangle.v1.vectorIndexZ ] = 0; + + uvtData[ triangle.v2.vectorIndexX ] = triangle.uv2.u; + uvtData[ triangle.v2.vectorIndexY ] = triangle.uv2.v; + uvtData[ triangle.v2.vectorIndexZ ] = 0; + triangles.push(triangle); return triangle; } else { return triangles[index]; } } /** * */ public function mergeVertices(treshold:Number=0.01):void { var triangle :Triangle; removeAllVertices(); for each (triangle in triangles) { var v0 :Vertex = findVertexInRange(triangle.v0, treshold); var v1 :Vertex = findVertexInRange(triangle.v1, treshold); var v2 :Vertex = findVertexInRange(triangle.v2, treshold); if (!v0) v0 = addVertex(triangle.v0); if (!v1) v1 = addVertex(triangle.v1); if (!v2) v2 = addVertex(triangle.v2); triangle.v0 = v0; triangle.v1 = v1; triangle.v2 = v2; } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/provider/VertexGeometry.as b/src/org/papervision3d/core/geom/provider/VertexGeometry.as index da732a6..a711ab7 100755 --- a/src/org/papervision3d/core/geom/provider/VertexGeometry.as +++ b/src/org/papervision3d/core/geom/provider/VertexGeometry.as @@ -1,164 +1,159 @@ package org.papervision3d.core.geom.provider { import org.papervision3d.core.geom.Geometry; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.ns.pv3d; public class VertexGeometry extends Geometry { - - - public var vertices :Vector.<Vertex>; - + public var vertices :Vector.<Vertex>; public var uvtData :Vector.<Number>; public var vertexData :Vector.<Number>; - - public var screenVertexLength : int = 0; - public var viewVertexLength : int = 0; + public var viewVertexLength : int = 0; /** * Constructor */ public function VertexGeometry(name:String=null) { super(); vertices = new Vector.<Vertex>(); vertexData = new Vector.<Number>(); uvtData = new Vector.<Number>(); } /** * Adds a new Vertex. * * @param vertex * * @return The added vertex. * * @see org.papervision3d.core.geom.Vertex */ public function addVertex(vertex:Vertex):Vertex { var index :int = vertices.indexOf(vertex); if (index >= 0) { return vertices[index]; } else { vertex.vertexGeometry = this; vertex.vectorIndexX = vertexData.push(vertex.x) - 1; vertex.vectorIndexY = vertexData.push(vertex.y) - 1; vertex.vectorIndexZ = vertexData.push(vertex.z) - 1; viewVertexLength += 3; vertex.screenIndexX = screenVertexLength; vertex.screenIndexY = screenVertexLength+1; screenVertexLength += 2; uvtData.push(0, 0, 0); vertices.push(vertex); return vertex; } } /** * Finds a vertex within the specified range. * * @param vertex * @param range * * @return The found vertex or null if not found. */ public function findVertexInRange(vertex:Vertex, range:Number=0.01):Vertex { var v :Vertex; for each (v in vertices) { if (vertex.x > v.x - range && vertex.x < v.x + range && vertex.y > v.y - range && vertex.y < v.y + range && vertex.z > v.z - range && vertex.z < v.z + range) { return v; } } return null; } /** * Removes a new Vertex. * * @param vertex The vertex to remove. * * @return The removed vertex or null on failure. * * @see org.papervision3d.core.geom.Vertex */ public function removeVertex(vertex:Vertex):Vertex { var index :int = vertices.indexOf(vertex); if (index < 0) { return null; } else { vertices.splice(index, 1); vertex.vertexGeometry = null; vertex.vectorIndexX = vertex.vectorIndexY = vertex.vectorIndexZ = -1; vertex.screenIndexX = vertex.screenIndexY = -1; updateIndices(); return vertex; } } /** * */ public function removeAllVertices():void { this.vertices.length = 0; updateIndices(); } /** * */ public function updateIndices():void { var vertex :Vertex; vertexData.length = 0; viewVertexLength = 0; screenVertexLength = 0; uvtData.length = 0; for each (vertex in vertices) { vertex.vectorIndexX = vertexData.push(vertex.x) - 1; vertex.vectorIndexY = vertexData.push(vertex.y) - 1; vertex.vectorIndexZ = vertexData.push(vertex.z) - 1; viewVertexLength += 3; vertex.screenIndexX = screenVertexLength; vertex.screenIndexY = screenVertexLength+1; screenVertexLength += 2; uvtData.push(0, 0, 0); } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as index 1494f57..833811e 100755 --- a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as +++ b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as @@ -1,43 +1,49 @@ package org.papervision3d.core.render.draw.items { import __AS3__.vec.Vector; import flash.display.GraphicsTrianglePath; public class TriangleDrawable extends AbstractDrawable { public var screenZ :Number; public var x0 :Number; public var y0 :Number; public var x1 :Number; public var y1 :Number; public var x2 :Number; public var y2 :Number; - + public var uvtData :Vector.<Number>; + private var _path:GraphicsTrianglePath; public function TriangleDrawable() { this.screenZ = 0; - _path = new GraphicsTrianglePath() - + _path = new GraphicsTrianglePath(); + _path.vertices = new Vector.<Number>(); + _path.vertices.push(0, 0, 0, 0, 0, 0); } public function toViewportSpace(hw:Number, hh:Number):void{ x0 *= hw; y0 *= hh; x1 *= hw; y1 *= hh; x2 *= hw; y2 *= hh; } public function get path():GraphicsTrianglePath{ - _path.vertices = new Vector.<Number>(); - _path.vertices.push(x0, y0, x1, y1, x2, y2); + _path.vertices[0] = x0; + _path.vertices[1] = y0; + _path.vertices[2] = x1; + _path.vertices[3] = y1; + _path.vertices[4] = x2; + _path.vertices[5] = y2; return _path; } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/DisplayObject3D.as b/src/org/papervision3d/objects/DisplayObject3D.as index 22d274f..fab39ab 100755 --- a/src/org/papervision3d/objects/DisplayObject3D.as +++ b/src/org/papervision3d/objects/DisplayObject3D.as @@ -1,31 +1,35 @@ package org.papervision3d.objects { import __AS3__.vec.Vector; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.proto.DisplayObjectContainer3D; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.materials.AbstractMaterial; /** * */ public class DisplayObject3D extends DisplayObjectContainer3D { /** * */ - public var material:AbstractMaterial; + + /** + * + */ public var renderer:ObjectRenderer; - + + /** + * + */ public function DisplayObject3D(name:String=null) { super(name); + renderer = new ObjectRenderer(); - } - - } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index b373cab..7494fc9 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,425 +1,449 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.LineGeometry; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.LineDrawable; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Frustum; import org.papervision3d.view.Viewport3D; /** * @author Tim Knip / floorplanner.com */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); _drawablePool.reset(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var renderer : ObjectRenderer = object.renderer; var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var sv0 :Vector3D = new Vector3D(); var sv1 :Vector3D = new Vector3D(); var sv2 :Vector3D = new Vector3D(); stats.totalObjects++; if (object.cullingState == 0 && object.renderer.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.renderer.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = renderer.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = renderer.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = renderer.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = renderer.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = renderer.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = renderer.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = renderer.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = renderer.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = renderer.viewVertexData[ triangle.v2.vectorIndexZ ]; // Setup clipflags for the triangle (detect whether the tri is in, out or straddling // the frustum). // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // passed the near test loosely, verts may have projected to infinity // we do it here, cause - paranoia - even these array accesses may cost us sv0.x = renderer.screenVertexData[ triangle.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ triangle.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ triangle.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ triangle.v1.screenIndexY ]; sv2.x = renderer.screenVertexData[ triangle.v2.screenIndexX ]; sv2.y = renderer.screenVertexData[ triangle.v2.screenIndexY ]; // When *not* straddling the near plane we can safely test for backfacing triangles // (as we're sure the infinity case is filtered out). // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } // Okay, all vertices are in front of the near plane and backfacing tris are gone. // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); + drawable.screenZ = (v0.z + v1.z + v2.z) / 3; + drawable.x0 = sv0.x; drawable.y0 = sv0.y; drawable.x1 = sv1.x; drawable.y1 = sv1.y; drawable.x2 = sv2.x; drawable.y2 = sv2.y; + + drawable.uvtData = drawable.uvtData || new Vector.<Number>(9, true); + drawable.uvtData[0] = renderer.geometry.uvtData[ triangle.v0.vectorIndexX ]; + drawable.uvtData[1] = renderer.geometry.uvtData[ triangle.v0.vectorIndexY ]; + drawable.uvtData[2] = renderer.geometry.uvtData[ triangle.v0.vectorIndexZ ]; + drawable.uvtData[3] = renderer.geometry.uvtData[ triangle.v1.vectorIndexX ]; + drawable.uvtData[4] = renderer.geometry.uvtData[ triangle.v1.vectorIndexY ]; + drawable.uvtData[5] = renderer.geometry.uvtData[ triangle.v1.vectorIndexZ ]; + drawable.uvtData[6] = renderer.geometry.uvtData[ triangle.v2.vectorIndexX ]; + drawable.uvtData[7] = renderer.geometry.uvtData[ triangle.v2.vectorIndexY ]; + drawable.uvtData[8] = renderer.geometry.uvtData[ triangle.v2.vectorIndexZ ]; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } else if (object.cullingState == 0 && object.renderer.geometry is LineGeometry) { var lineGeometry:LineGeometry = LineGeometry(object.renderer.geometry); var line :Line; for each (line in lineGeometry.lines) { var lineDrawable :LineDrawable = line.drawable as LineDrawable || new LineDrawable(); sv0.x = renderer.screenVertexData[ line.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ line.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ line.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ line.v1.screenIndexY ]; lineDrawable.x0 = sv0.x; lineDrawable.y0 = sv0.y; lineDrawable.x1 = sv1.x; lineDrawable.y1 = sv1.y; lineDrawable.material = line.material; renderList.addDrawable(lineDrawable); } } // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); - var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); + var inUVT :Vector.<Number> = Vector.<Number>([triangle.uv0.u, triangle.uv0.v, 0, triangle.uv1.u, triangle.uv1.v, 0, triangle.uv2.u, triangle.uv2.v, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; - drawable.x1 = v1.x; drawable.y1 = v1.y; - drawable.x2 = v2.x; - drawable.y2 = v2.y; + drawable.y2 = v2.y; + + drawable.uvtData = drawable.uvtData || new Vector.<Number>(9, true); + + drawable.uvtData[0] = inUVT[0]; + drawable.uvtData[1] = inUVT[1]; + drawable.uvtData[2] = inUVT[2]; + drawable.uvtData[3] = inUVT[i3+3]; + drawable.uvtData[4] = inUVT[i3+4]; + drawable.uvtData[5] = inUVT[i3+5]; + drawable.uvtData[6] = inUVT[i3+6]; + drawable.uvtData[7] = inUVT[i3+7]; + drawable.uvtData[8] = inUVT[i3+8]; + drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
244d18ecd17b62ee72a9c2ace75f58fdcda732a8
lines now work with azupko's merge
diff --git a/src/org/papervision3d/core/render/draw/items/LineDrawable.as b/src/org/papervision3d/core/render/draw/items/LineDrawable.as new file mode 100644 index 0000000..d1d85ce --- /dev/null +++ b/src/org/papervision3d/core/render/draw/items/LineDrawable.as @@ -0,0 +1,46 @@ +package org.papervision3d.core.render.draw.items +{ + import __AS3__.vec.Vector; + + import flash.display.GraphicsPath; + import flash.display.GraphicsPathCommand; + + public class LineDrawable extends AbstractDrawable + { + public var x0 :Number; + public var y0 :Number; + public var x1 :Number; + public var y1 :Number; + + private var _path :GraphicsPath; + + public function LineDrawable() + { + super(); + + _path = new GraphicsPath(); + _path.commands = new Vector.<int>(); + _path.data = new Vector.<Number>(); + + _path.commands.push( GraphicsPathCommand.MOVE_TO ); + _path.commands.push( GraphicsPathCommand.LINE_TO ); + _path.data.push(0, 0, 0, 0); + } + + public function toViewportSpace(hw:Number, hh:Number):void{ + x0 *= hw; + y0 *= hh; + x1 *= hw; + y1 *= hh; + } + + public function get path():GraphicsPath + { + _path.data[0] = x0; + _path.data[1] = y0; + _path.data[2] = x1; + _path.data[3] = y1; + return _path; + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/objects/DisplayObject3D.as b/src/org/papervision3d/objects/DisplayObject3D.as index 327ebde..22d274f 100755 --- a/src/org/papervision3d/objects/DisplayObject3D.as +++ b/src/org/papervision3d/objects/DisplayObject3D.as @@ -1,31 +1,31 @@ package org.papervision3d.objects { import __AS3__.vec.Vector; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.proto.DisplayObjectContainer3D; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.materials.AbstractMaterial; /** * */ public class DisplayObject3D extends DisplayObjectContainer3D { /** * */ - public var material:AbstractMaterial; - public var renderer:ObjectRenderer; + public var material:AbstractMaterial; + public var renderer:ObjectRenderer; public function DisplayObject3D(name:String=null) { super(name); renderer = new ObjectRenderer(); } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Cube.as b/src/org/papervision3d/objects/primitives/Cube.as index 6cd1d44..6cc89a5 100755 --- a/src/org/papervision3d/objects/primitives/Cube.as +++ b/src/org/papervision3d/objects/primitives/Cube.as @@ -1,86 +1,83 @@ package org.papervision3d.objects.primitives { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.UVCoord; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.materials.AbstractMaterial; /** * */ public class Cube extends DisplayObject3D { /** * */ - - private var triGeometry : TriangleGeometry; + private var triGeometry : TriangleGeometry; public function Cube(material:AbstractMaterial, size:Number = 100, name:String=null) { super(name); this.material = material; renderer.geometry = triGeometry = new TriangleGeometry(); create(size); } - - /** * */ protected function create(size:Number):void { var sz : Number = size / 2; var v :Array = [ new Vertex(-sz, sz, -sz), new Vertex(sz, sz, -sz), new Vertex(sz, -sz, -sz), new Vertex(-sz, -sz, -sz), new Vertex(-sz, sz, sz), new Vertex(sz, sz, sz), new Vertex(sz, -sz, sz), new Vertex(-sz, -sz, sz) ]; var vertex : Vertex; for each(vertex in v) { this.renderer.geometry.addVertex(vertex); } var uv0 :UVCoord = new UVCoord(0, 1); var uv1 :UVCoord = new UVCoord(0, 0); var uv2 :UVCoord = new UVCoord(1, 0); var uv3 :UVCoord = new UVCoord(1, 1); // top triGeometry.addTriangle(new Triangle(material, v[0], v[4], v[5], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(material, v[0], v[5], v[1], uv0, uv2, uv3) ); // bottom triGeometry.addTriangle(new Triangle(material, v[6], v[7], v[3], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(material, v[6], v[3], v[2], uv2, uv0, uv3) ); // left triGeometry.addTriangle(new Triangle(material, v[0], v[3], v[7], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(material, v[0], v[7], v[4], uv1, uv3, uv2) ); // right triGeometry.addTriangle(new Triangle(material, v[5], v[6], v[2], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(material, v[5], v[2], v[1], uv1, uv3, uv2) ); // front triGeometry.addTriangle(new Triangle(material, v[0], v[1], v[2], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(material, v[0], v[2], v[3], uv2, uv0, uv3) ); // back triGeometry.addTriangle(new Triangle(material, v[6], v[5], v[4], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(material, v[6], v[4], v[7], uv0, uv2, uv3) ); renderer.updateIndices(); } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Frustum.as b/src/org/papervision3d/objects/primitives/Frustum.as index c8ac4a6..ba3d8a6 100644 --- a/src/org/papervision3d/objects/primitives/Frustum.as +++ b/src/org/papervision3d/objects/primitives/Frustum.as @@ -1,137 +1,141 @@ package org.papervision3d.objects.primitives { import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.LineGeometry; + import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.materials.AbstractMaterial; import org.papervision3d.objects.DisplayObject3D; /** * */ public class Frustum extends DisplayObject3D { public var nc :Vertex; public var fc :Vertex; public var ntl :Vertex; public var nbl :Vertex; public var nbr :Vertex; public var ntr :Vertex; public var ftl :Vertex; public var fbl :Vertex; public var fbr :Vertex; public var ftr :Vertex; /** * */ public function Frustum(material:AbstractMaterial, name:String=null) { super(name); this.material = material; - this.geometry = new LineGeometry(); + this.renderer.geometry = new LineGeometry(); init(); } /** * */ protected function init():void { - var lineGeometry :LineGeometry = LineGeometry(this.geometry); + var geometry :VertexGeometry = renderer.geometry; + + var lineGeometry :LineGeometry = LineGeometry(renderer.geometry); nc = geometry.addVertex(new Vertex()); fc = geometry.addVertex(new Vertex()); ntl = geometry.addVertex(new Vertex()); nbl = geometry.addVertex(new Vertex()); nbr = geometry.addVertex(new Vertex()); ntr = geometry.addVertex(new Vertex()); ftl = geometry.addVertex(new Vertex()); fbl = geometry.addVertex(new Vertex()); fbr = geometry.addVertex(new Vertex()); ftr = geometry.addVertex(new Vertex()); lineGeometry.addLine( new Line(material, ntl, nbl), false ); lineGeometry.addLine( new Line(material, nbl, nbr), false ); lineGeometry.addLine( new Line(material, nbr, ntr), false ); lineGeometry.addLine( new Line(material, ntr, ntl), false ); lineGeometry.addLine( new Line(material, ftl, fbl), false ); lineGeometry.addLine( new Line(material, fbl, fbr), false ); lineGeometry.addLine( new Line(material, fbr, ftr), false ); lineGeometry.addLine( new Line(material, ftr, ftl), false ); lineGeometry.addLine( new Line(material, ntl, ftl), false ); lineGeometry.addLine( new Line(material, nbl, fbl), false ); lineGeometry.addLine( new Line(material, nbr, fbr), false ); lineGeometry.addLine( new Line(material, ntr, ftr), false ); } /** * */ public function update(camera:Camera3D):void { + var geometry :VertexGeometry = renderer.geometry; var fov :Number = camera.fov; var near :Number = camera.near; var far :Number = camera.far; var ratio :Number = 1.33; //camera.aspectRatio; // compute width and height of the near and far section var angle : Number = MathUtil.TO_RADIANS * fov * 0.5; var tang :Number = Math.tan(angle); var nh :Number = near * tang; var nw :Number = nh * ratio; var fh :Number = far * tang; var fw :Number = fh * ratio; nc.x = 0; nc.y = 0; nc.z = -near; fc.x = 0; fc.y = 0; fc.z = -far; ntl.x = -nw * 0.5; ntl.y = nh * 0.5; ntl.z = -near; nbl.x = -nw * 0.5; nbl.y = -nh * 0.5; nbl.z = -near; nbr.x = nw * 0.5; nbr.y = -nh * 0.5; nbr.z = -near; ntr.x = nw * 0.5; ntr.y = nh * 0.5; ntr.z = -near; ftl.x = -fw * 0.5; ftl.y = fh * 0.5; ftl.z = -far; fbl.x = -fw * 0.5; fbl.y = -fh * 0.5; fbl.z = -far; fbr.x = fw * 0.5; fbr.y = -fh * 0.5; fbr.z = -far; ftr.x = fw * 0.5; ftr.y = fh * 0.5; ftr.z = -far; geometry.updateIndices(); } } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 9b2ed00..b373cab 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,425 +1,425 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.LineGeometry; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.LineDrawable; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Frustum; import org.papervision3d.view.Viewport3D; /** * @author Tim Knip / floorplanner.com */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); _drawablePool.reset(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { + var renderer : ObjectRenderer = object.renderer; var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var sv0 :Vector3D = new Vector3D(); var sv1 :Vector3D = new Vector3D(); var sv2 :Vector3D = new Vector3D(); stats.totalObjects++; if (object.cullingState == 0 && object.renderer.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.renderer.geometry as TriangleGeometry; - var renderer : ObjectRenderer = object.renderer; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = renderer.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = renderer.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = renderer.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = renderer.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = renderer.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = renderer.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = renderer.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = renderer.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = renderer.viewVertexData[ triangle.v2.vectorIndexZ ]; // Setup clipflags for the triangle (detect whether the tri is in, out or straddling // the frustum). // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // passed the near test loosely, verts may have projected to infinity // we do it here, cause - paranoia - even these array accesses may cost us sv0.x = renderer.screenVertexData[ triangle.v0.screenIndexX ]; sv0.y = renderer.screenVertexData[ triangle.v0.screenIndexY ]; sv1.x = renderer.screenVertexData[ triangle.v1.screenIndexX ]; sv1.y = renderer.screenVertexData[ triangle.v1.screenIndexY ]; sv2.x = renderer.screenVertexData[ triangle.v2.screenIndexX ]; sv2.y = renderer.screenVertexData[ triangle.v2.screenIndexY ]; // When *not* straddling the near plane we can safely test for backfacing triangles // (as we're sure the infinity case is filtered out). // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } // Okay, all vertices are in front of the near plane and backfacing tris are gone. // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = sv0.x; drawable.y0 = sv0.y; drawable.x1 = sv1.x; drawable.y1 = sv1.y; drawable.x2 = sv2.x; drawable.y2 = sv2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } - else if (object.cullingState == 0 && object.geometry is LineGeometry) + else if (object.cullingState == 0 && object.renderer.geometry is LineGeometry) { - var lineGeometry:LineGeometry = LineGeometry(object.geometry); + var lineGeometry:LineGeometry = LineGeometry(object.renderer.geometry); var line :Line; for each (line in lineGeometry.lines) { var lineDrawable :LineDrawable = line.drawable as LineDrawable || new LineDrawable(); - sv0.x = lineGeometry.screenVertexData[ line.v0.screenIndexX ]; - sv0.y = lineGeometry.screenVertexData[ line.v0.screenIndexY ]; - sv1.x = lineGeometry.screenVertexData[ line.v1.screenIndexX ]; - sv1.y = lineGeometry.screenVertexData[ line.v1.screenIndexY ]; + sv0.x = renderer.screenVertexData[ line.v0.screenIndexX ]; + sv0.y = renderer.screenVertexData[ line.v0.screenIndexY ]; + sv1.x = renderer.screenVertexData[ line.v1.screenIndexX ]; + sv1.y = renderer.screenVertexData[ line.v1.screenIndexY ]; lineDrawable.x0 = sv0.x; lineDrawable.y0 = sv0.y; lineDrawable.x1 = sv1.x; lineDrawable.y1 = sv1.y; lineDrawable.material = line.material; renderList.addDrawable(lineDrawable); } } // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
bd7e2eb830a74f64e98f84657171f457b15552c6
prepping merge
diff --git a/src/Main.as b/src/Main.as index 6237524..967575e 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,161 +1,169 @@ package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; + public var camera2 :Camera3D; + public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; viewport = new Viewport3D(0, 0, true); addChild(viewport); scene = new DisplayObject3D("Scene"); camera = new Camera3D(30, 400, 2300, "Camera01"); scene.addChild( camera ); camera.enableCulling = false; camera.z = 800; renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; + var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; cubeChild1.scaleX = 5; cubeChild1.scaleY = 5; cubeChild1.scaleZ = 0.1; scene.addChild( cube ); + + camera2 = new Camera3D(50, 50, 500); + cube.addChild(camera2); var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); scene.addChild(plane); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { + camera2.frustumGeometry.update(camera2); + // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); - cube.lookAt(cube.getChildByName("blue")); + //cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z--; cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/cameras/Camera3D.as b/src/org/papervision3d/cameras/Camera3D.as index f341e65..ed4be49 100755 --- a/src/org/papervision3d/cameras/Camera3D.as +++ b/src/org/papervision3d/cameras/Camera3D.as @@ -1,215 +1,228 @@ package org.papervision3d.cameras { import flash.geom.Matrix3D; import flash.geom.Rectangle; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; + import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; + import org.papervision3d.objects.primitives.Frustum; /** * @author Tim Knip / floorplanner.com */ public class Camera3D extends DisplayObject3D { use namespace pv3d; public var projectionMatrix :Matrix3D; public var viewMatrix :Matrix3D; public var frustum :Frustum3D; private var _dirty:Boolean; private var _fov:Number; private var _far:Number; private var _near:Number; private var _ortho:Boolean; private var _orthoScale:Number; private var _aspectRatio :Number; private var _enableCulling :Boolean; private var _worldCullingMatrix :Matrix3D; + private var _frustumGeometry :Frustum; /** * Constructor. * * @param fov * @param near * @param far * @param name */ public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, name:String=null) { super(name); _fov = fov; _near = near; _far = far; _dirty = true; _ortho = false; _orthoScale = 1; _enableCulling = false; _worldCullingMatrix = new Matrix3D(); - + _frustumGeometry = new Frustum(new WireframeMaterial(0x0000ff), "frustum-geometry"); + + addChild(_frustumGeometry); + frustum = new Frustum3D(this); viewMatrix = new Matrix3D(); } /** * */ public function update(viewport:Rectangle) : void { var aspect :Number = viewport.width / viewport.height; viewMatrix.rawData = transform.worldTransform.rawData; viewMatrix.invert(); if (_aspectRatio != aspect) { _aspectRatio = aspect; _dirty = true; } if(_dirty) { _dirty = false; if(_ortho) { projectionMatrix = MatrixUtil.createOrthoMatrix(-viewport.width, viewport.width, viewport.height, -viewport.height, _far, -_far); } else { projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); } // extract the view clipping planes frustum.extractPlanes(projectionMatrix, Frustum3D.VIEW_PLANES); + + _frustumGeometry.update(this); } // TODO: sniff whether our transform was dirty, no need to calc when camera didn't move. if (_enableCulling) { _worldCullingMatrix.rawData = viewMatrix.rawData; _worldCullingMatrix.append(projectionMatrix); // TODO: why this is needed is weird. If we don't the culling / clipping planes don't // seem to match. With this hack all ok... // Tim: Think its got to do with a discrepancy between GL viewport and // our draw-container sitting at center stage. _worldCullingMatrix.prependScale(0.5, 0.5, 0.5); // extract the world clipping planes frustum.extractPlanes(_worldCullingMatrix, Frustum3D.WORLD_PLANES, false); } } /** * */ public function get aspectRatio():Number { return _aspectRatio; } /** * */ public function get enableCulling():Boolean { return _enableCulling; } public function set enableCulling(value:Boolean):void { _enableCulling = value; } /** * Distance to the far clipping plane. */ public function get far():Number { return _far; } public function set far(value:Number):void { if (value != _far && value > _near) { _far = value; _dirty = true; } } /** * Field of view (vertical) in degrees. */ public function get fov():Number { return _fov; } public function set fov(value:Number):void { if (value != _fov) { _fov = value; _dirty = true; } } /** * Distance to the near clipping plane. */ public function get near():Number { return _near; } public function set near(value:Number):void { if (value != _near && value > 0 && value < _far) { _near = value; _dirty = true; } } /** * Whether to use a orthogonal projection. */ public function get ortho():Boolean { return _ortho; } public function set ortho(value:Boolean):void { if (value != _ortho) { _ortho = value; _dirty = true; } } /** * Scale of the orthogonal projection. */ public function get orthoScale():Number { return _orthoScale; } public function set orthoScale(value:Number):void { if (value != _orthoScale) { _orthoScale = value; _dirty = true; } } + + public function get frustumGeometry():Frustum + { + return _frustumGeometry; + } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/Line.as b/src/org/papervision3d/core/geom/Line.as index fa2e608..dabe205 100644 --- a/src/org/papervision3d/core/geom/Line.as +++ b/src/org/papervision3d/core/geom/Line.as @@ -1,30 +1,34 @@ package org.papervision3d.core.geom { + import org.papervision3d.core.render.draw.items.IDrawable; import org.papervision3d.materials.AbstractMaterial; public class Line { /** Start point of line. */ public var v0 :Vertex; /** End point of line. */ public var v1 :Vertex; /** First control point. */ public var cv0 :Vertex; /** */ public var material :AbstractMaterial; + /** */ + public var drawable :IDrawable; + /** * */ public function Line(material:AbstractMaterial, v0:Vertex, v1:Vertex, cv0:Vertex=null) { this.material = material; this.v0 = v0; this.v1 = v1; this.cv0 = cv0; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/provider/LineGeometry.as b/src/org/papervision3d/core/geom/provider/LineGeometry.as index 20b86fe..e2089b9 100644 --- a/src/org/papervision3d/core/geom/provider/LineGeometry.as +++ b/src/org/papervision3d/core/geom/provider/LineGeometry.as @@ -1,45 +1,48 @@ package org.papervision3d.core.geom.provider { import org.papervision3d.core.geom.Line; /** * */ public class LineGeometry extends VertexGeometry { public var lines :Vector.<Line>; /** * */ public function LineGeometry(name:String=null) { super(name); this.lines = new Vector.<Line>(); } /** * */ - public function addLine(line:Line):Line + public function addLine(line:Line, addVertices:Boolean=true):Line { var index :int = lines.indexOf(line); if (index < 0) { - line.v0 = addVertex(line.v0); - line.v1 = addVertex(line.v1); - if (line.cv0) + if (addVertices) { - line.cv0 = addVertex(line.cv0); + line.v0 = addVertex(line.v0); + line.v1 = addVertex(line.v1); + if (line.cv0) + { + line.cv0 = addVertex(line.cv0); + } } lines.push(line); return line; } else { return lines[index]; } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as index 4a5d2ac..1494f57 100755 --- a/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as +++ b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as @@ -1,45 +1,43 @@ package org.papervision3d.core.render.draw.items { import __AS3__.vec.Vector; import flash.display.GraphicsTrianglePath; public class TriangleDrawable extends AbstractDrawable { public var screenZ :Number; public var x0 :Number; public var y0 :Number; public var x1 :Number; public var y1 :Number; public var x2 :Number; public var y2 :Number; private var _path:GraphicsTrianglePath; public function TriangleDrawable() { this.screenZ = 0; _path = new GraphicsTrianglePath() } public function toViewportSpace(hw:Number, hh:Number):void{ x0 *= hw; y0 *= hh; x1 *= hw; y1 *= hh; x2 *= hw; y2 *= hh; - } public function get path():GraphicsTrianglePath{ _path.vertices = new Vector.<Number>(); _path.vertices.push(x0, y0, x1, y1, x2, y2); return _path; - } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/raster/DefaultRasterizer.as b/src/org/papervision3d/core/render/raster/DefaultRasterizer.as index f690da1..a467479 100755 --- a/src/org/papervision3d/core/render/raster/DefaultRasterizer.as +++ b/src/org/papervision3d/core/render/raster/DefaultRasterizer.as @@ -1,38 +1,52 @@ package org.papervision3d.core.render.raster { import __AS3__.vec.Vector; import flash.display.IGraphicsData; + import org.papervision3d.core.render.draw.items.IDrawable; + import org.papervision3d.core.render.draw.items.LineDrawable; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.view.Viewport3D; public class DefaultRasterizer implements IRasterizer { public var drawArray:Vector.<IGraphicsData> = new Vector.<IGraphicsData>(); public function DefaultRasterizer() { } public function rasterize(renderList:IDrawableList, viewport:Viewport3D):void{ var hw :Number = viewport.viewportWidth / 2; var hh :Number = viewport.viewportHeight / 2; + var drawable :IDrawable; + var triangle :TriangleDrawable; + var line :LineDrawable; + drawArray.length = 0; viewport.containerSprite.graphics.clear(); - for each (var drawable :TriangleDrawable in renderList.drawables) + for each (drawable in renderList.drawables) + { + if (drawable is TriangleDrawable) { - - drawable.toViewportSpace(hw, -hh); - drawArray.push(drawable.material.drawProperties, drawable.path, drawable.material.clear); - + triangle = drawable as TriangleDrawable; + triangle.toViewportSpace(hw, -hh); + drawArray.push(triangle.material.drawProperties, triangle.path, triangle.material.clear); + } + else if (drawable is LineDrawable) + { + line = drawable as LineDrawable; + line.toViewportSpace(hw, -hh); + drawArray.push(line.material.drawProperties, line.path, line.material.clear); } + } viewport.containerSprite.graphics.drawGraphicsData(drawArray); } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Frustum.as b/src/org/papervision3d/objects/primitives/Frustum.as index be7b613..c8ac4a6 100644 --- a/src/org/papervision3d/objects/primitives/Frustum.as +++ b/src/org/papervision3d/objects/primitives/Frustum.as @@ -1,73 +1,137 @@ package org.papervision3d.objects.primitives { + import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.LineGeometry; + import org.papervision3d.core.math.utils.MathUtil; + import org.papervision3d.materials.AbstractMaterial; import org.papervision3d.objects.DisplayObject3D; /** * */ public class Frustum extends DisplayObject3D { public var nc :Vertex; public var fc :Vertex; public var ntl :Vertex; public var nbl :Vertex; public var nbr :Vertex; public var ntr :Vertex; public var ftl :Vertex; public var fbl :Vertex; public var fbr :Vertex; public var ftr :Vertex; /** * */ public function Frustum(material:AbstractMaterial, name:String=null) { super(name); this.material = material; this.geometry = new LineGeometry(); init(); } /** * */ protected function init():void { - var lineGeometry :LineGeometry = geometry as lineGeometry; + var lineGeometry :LineGeometry = LineGeometry(this.geometry); nc = geometry.addVertex(new Vertex()); fc = geometry.addVertex(new Vertex()); ntl = geometry.addVertex(new Vertex()); nbl = geometry.addVertex(new Vertex()); nbr = geometry.addVertex(new Vertex()); ntr = geometry.addVertex(new Vertex()); ftl = geometry.addVertex(new Vertex()); fbl = geometry.addVertex(new Vertex()); fbr = geometry.addVertex(new Vertex()); ftr = geometry.addVertex(new Vertex()); - lineGeometry.addLine( new Line(material, ntl, nbl) ); - lineGeometry.addLine( new Line(material, nbl, nbr) ); - lineGeometry.addLine( new Line(material, nbr, ntr) ); - lineGeometry.addLine( new Line(material, ntr, ntl) ); + lineGeometry.addLine( new Line(material, ntl, nbl), false ); + lineGeometry.addLine( new Line(material, nbl, nbr), false ); + lineGeometry.addLine( new Line(material, nbr, ntr), false ); + lineGeometry.addLine( new Line(material, ntr, ntl), false ); - lineGeometry.addLine( new Line(material, ftl, fbl) ); - lineGeometry.addLine( new Line(material, fbl, fbr) ); - lineGeometry.addLine( new Line(material, fbr, ftr) ); - lineGeometry.addLine( new Line(material, ftr, ftl) ); + lineGeometry.addLine( new Line(material, ftl, fbl), false ); + lineGeometry.addLine( new Line(material, fbl, fbr), false ); + lineGeometry.addLine( new Line(material, fbr, ftr), false ); + lineGeometry.addLine( new Line(material, ftr, ftl), false ); - lineGeometry.addLine( new Line(material, ntl, ftl) ); - lineGeometry.addLine( new Line(material, nbl, fbl) ); - lineGeometry.addLine( new Line(material, nbr, fbr) ); - lineGeometry.addLine( new Line(material, ntr, ftr) ); + lineGeometry.addLine( new Line(material, ntl, ftl), false ); + lineGeometry.addLine( new Line(material, nbl, fbl), false ); + lineGeometry.addLine( new Line(material, nbr, fbr), false ); + lineGeometry.addLine( new Line(material, ntr, ftr), false ); } + + /** + * + */ + public function update(camera:Camera3D):void + { + var fov :Number = camera.fov; + var near :Number = camera.near; + var far :Number = camera.far; + var ratio :Number = 1.33; //camera.aspectRatio; + + // compute width and height of the near and far section + var angle : Number = MathUtil.TO_RADIANS * fov * 0.5; + var tang :Number = Math.tan(angle); + var nh :Number = near * tang; + var nw :Number = nh * ratio; + var fh :Number = far * tang; + var fw :Number = fh * ratio; + + nc.x = 0; + nc.y = 0; + nc.z = -near; + + fc.x = 0; + fc.y = 0; + fc.z = -far; + + ntl.x = -nw * 0.5; + ntl.y = nh * 0.5; + ntl.z = -near; + + nbl.x = -nw * 0.5; + nbl.y = -nh * 0.5; + nbl.z = -near; + + nbr.x = nw * 0.5; + nbr.y = -nh * 0.5; + nbr.z = -near; + + ntr.x = nw * 0.5; + ntr.y = nh * 0.5; + ntr.z = -near; + + ftl.x = -fw * 0.5; + ftl.y = fh * 0.5; + ftl.z = -far; + + fbl.x = -fw * 0.5; + fbl.y = -fh * 0.5; + fbl.z = -far; + + fbr.x = fw * 0.5; + fbr.y = -fh * 0.5; + fbr.z = -far; + + ftr.x = fw * 0.5; + ftr.y = fh * 0.5; + ftr.z = -far; + + geometry.updateIndices(); + } } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index b134188..20df68b 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,395 +1,422 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; + import org.papervision3d.core.geom.Line; import org.papervision3d.core.geom.Triangle; + import org.papervision3d.core.geom.provider.LineGeometry; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; + import org.papervision3d.core.render.draw.items.LineDrawable; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; + import org.papervision3d.objects.primitives.Frustum; import org.papervision3d.view.Viewport3D; /** * @author Tim Knip / floorplanner.com */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); _drawablePool.reset(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var sv0 :Vector3D = new Vector3D(); var sv1 :Vector3D = new Vector3D(); var sv2 :Vector3D = new Vector3D(); stats.totalObjects++; if (object.cullingState == 0 && object.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; // Setup clipflags for the triangle (detect whether the tri is in, out or straddling // the frustum). // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // Grab the screem vertices sv0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; sv0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; sv1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; sv1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; sv2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; sv2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; // When *not* straddling the near plane we can safely test for backfacing triangles // (as we're sure the infinity case is filtered out). // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } // Okay, all vertices are in front of the near plane and backfacing tris are gone. // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = sv0.x; drawable.y0 = sv0.y; drawable.x1 = sv1.x; drawable.y1 = sv1.y; drawable.x2 = sv2.x; drawable.y2 = sv2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } - + else if (object.cullingState == 0 && object.geometry is LineGeometry) + { + var lineGeometry:LineGeometry = LineGeometry(object.geometry); + var line :Line; + + for each (line in lineGeometry.lines) + { + var lineDrawable :LineDrawable = line.drawable as LineDrawable || new LineDrawable(); + + sv0.x = lineGeometry.screenVertexData[ line.v0.screenIndexX ]; + sv0.y = lineGeometry.screenVertexData[ line.v0.screenIndexY ]; + sv1.x = lineGeometry.screenVertexData[ line.v1.screenIndexX ]; + sv1.y = lineGeometry.screenVertexData[ line.v1.screenIndexY ]; + + lineDrawable.x0 = sv0.x; + lineDrawable.y0 = sv0.y; + lineDrawable.x1 = sv1.x; + lineDrawable.y1 = sv1.y; + lineDrawable.material = line.material; + + renderList.addDrawable(lineDrawable); + } + } + // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
87f9dbdba0913aa508f85e9a84598bc649892f6a
culling beginnings
diff --git a/src/Main.as b/src/Main.as index 80a7e23..6237524 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,169 +1,161 @@ -package { +package +{ import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; - var aspect :Number = stage.stageWidth / stage.stageHeight; - - container = new Sprite(); - addChild(container); - container.x = stage.stageWidth / 2; - container.y = stage.stageHeight / 2; - + // Thanks doob! addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; + viewport = new Viewport3D(0, 0, true); + addChild(viewport); + + scene = new DisplayObject3D("Scene"); + camera = new Camera3D(30, 400, 2300, "Camera01"); - pipeline = new BasicPipeline(); + scene.addChild( camera ); + camera.enableCulling = false; + camera.z = 800; + + renderer = new BasicRenderEngine(); + renderer.clipFlags = ClipFlags.ALL; cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); - cubeChild1.z = 200; + cubeChild1.z = 100; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; + cubeChild1.scaleX = 5; + cubeChild1.scaleY = 5; + cubeChild1.scaleZ = 0.1; - scene = new DisplayObject3D("Scene"); - scene.addChild( camera ); scene.addChild( cube ); - camera.z = 800; - - viewport = new Viewport3D(0, 0, true); - - renderer = new BasicRenderEngine(); - renderer.clipFlags = ClipFlags.ALL; - - addChild(viewport); - var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); scene.addChild(plane); - // render(); - camera.y = 500; - camera.lookAt(cube.getChildByName("red")); - render(); - //camera.lookAt(cube.getChildByName("red")); - render(); - render(); + addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); - cube.getChildByName("blue").rotationZ += 4; + cube.getChildByName("blue").rotationZ += 0.1; cube.getChildByName("blue").transform.eulerAngles.y--; - cube.getChildByName("green").lookAt( cube.getChildByName("blue") ); + cube.getChildByName("green").lookAt( cube.getChildByName("red") ); cube.lookAt(cube.getChildByName("blue")); - cube.getChildByName("red").transform.eulerAngles.z++; - // cube.getChildByName("red").transform.eulerAngles.y--; + cube.getChildByName("red").transform.eulerAngles.z--; + cube.getChildByName("red").transform.eulerAngles.y += 4; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; + _r = _r > Math.PI * 2 ? 0 : _r; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/cameras/Camera3D.as b/src/org/papervision3d/cameras/Camera3D.as index 45c6f4a..f341e65 100755 --- a/src/org/papervision3d/cameras/Camera3D.as +++ b/src/org/papervision3d/cameras/Camera3D.as @@ -1,215 +1,215 @@ package org.papervision3d.cameras { import flash.geom.Matrix3D; import flash.geom.Rectangle; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.objects.DisplayObject3D; /** - * + * @author Tim Knip / floorplanner.com */ public class Camera3D extends DisplayObject3D { use namespace pv3d; public var projectionMatrix :Matrix3D; public var viewMatrix :Matrix3D; public var frustum :Frustum3D; private var _dirty:Boolean; private var _fov:Number; private var _far:Number; private var _near:Number; private var _ortho:Boolean; private var _orthoScale:Number; private var _aspectRatio :Number; private var _enableCulling :Boolean; private var _worldCullingMatrix :Matrix3D; /** * Constructor. * * @param fov * @param near * @param far * @param name */ public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, name:String=null) { super(name); _fov = fov; _near = near; _far = far; _dirty = true; _ortho = false; _orthoScale = 1; _enableCulling = false; _worldCullingMatrix = new Matrix3D(); frustum = new Frustum3D(this); viewMatrix = new Matrix3D(); } /** * */ public function update(viewport:Rectangle) : void { var aspect :Number = viewport.width / viewport.height; viewMatrix.rawData = transform.worldTransform.rawData; viewMatrix.invert(); if (_aspectRatio != aspect) { _aspectRatio = aspect; _dirty = true; } if(_dirty) { _dirty = false; if(_ortho) { projectionMatrix = MatrixUtil.createOrthoMatrix(-viewport.width, viewport.width, viewport.height, -viewport.height, _far, -_far); } else { projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); } // extract the view clipping planes - frustum.extractPlanes(projectionMatrix, frustum.viewClippingPlanes); + frustum.extractPlanes(projectionMatrix, Frustum3D.VIEW_PLANES); } // TODO: sniff whether our transform was dirty, no need to calc when camera didn't move. if (_enableCulling) { _worldCullingMatrix.rawData = viewMatrix.rawData; _worldCullingMatrix.append(projectionMatrix); // TODO: why this is needed is weird. If we don't the culling / clipping planes don't // seem to match. With this hack all ok... // Tim: Think its got to do with a discrepancy between GL viewport and // our draw-container sitting at center stage. _worldCullingMatrix.prependScale(0.5, 0.5, 0.5); // extract the world clipping planes - frustum.extractPlanes(_worldCullingMatrix, frustum.worldClippingPlanes, false); + frustum.extractPlanes(_worldCullingMatrix, Frustum3D.WORLD_PLANES, false); } } /** * */ public function get aspectRatio():Number { return _aspectRatio; } /** * */ public function get enableCulling():Boolean { return _enableCulling; } public function set enableCulling(value:Boolean):void { _enableCulling = value; } /** * Distance to the far clipping plane. */ public function get far():Number { return _far; } public function set far(value:Number):void { if (value != _far && value > _near) { _far = value; _dirty = true; } } /** * Field of view (vertical) in degrees. */ public function get fov():Number { return _fov; } public function set fov(value:Number):void { if (value != _fov) { _fov = value; _dirty = true; } } /** * Distance to the near clipping plane. */ public function get near():Number { return _near; } public function set near(value:Number):void { if (value != _near && value > 0 && value < _far) { _near = value; _dirty = true; } } /** * Whether to use a orthogonal projection. */ public function get ortho():Boolean { return _ortho; } public function set ortho(value:Boolean):void { if (value != _ortho) { _ortho = value; _dirty = true; } } /** * Scale of the orthogonal projection. */ public function get orthoScale():Number { return _orthoScale; } public function set orthoScale(value:Number):void { if (value != _orthoScale) { _orthoScale = value; _dirty = true; } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/Line.as b/src/org/papervision3d/core/geom/Line.as new file mode 100644 index 0000000..fa2e608 --- /dev/null +++ b/src/org/papervision3d/core/geom/Line.as @@ -0,0 +1,30 @@ +package org.papervision3d.core.geom +{ + import org.papervision3d.materials.AbstractMaterial; + + public class Line + { + /** Start point of line. */ + public var v0 :Vertex; + + /** End point of line. */ + public var v1 :Vertex; + + /** First control point. */ + public var cv0 :Vertex; + + /** */ + public var material :AbstractMaterial; + + /** + * + */ + public function Line(material:AbstractMaterial, v0:Vertex, v1:Vertex, cv0:Vertex=null) + { + this.material = material; + this.v0 = v0; + this.v1 = v1; + this.cv0 = cv0; + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/geom/provider/LineGeometry.as b/src/org/papervision3d/core/geom/provider/LineGeometry.as new file mode 100644 index 0000000..20b86fe --- /dev/null +++ b/src/org/papervision3d/core/geom/provider/LineGeometry.as @@ -0,0 +1,45 @@ +package org.papervision3d.core.geom.provider +{ + import org.papervision3d.core.geom.Line; + + /** + * + */ + public class LineGeometry extends VertexGeometry + { + public var lines :Vector.<Line>; + + /** + * + */ + public function LineGeometry(name:String=null) + { + super(name); + this.lines = new Vector.<Line>(); + } + + /** + * + */ + public function addLine(line:Line):Line + { + var index :int = lines.indexOf(line); + + if (index < 0) + { + line.v0 = addVertex(line.v0); + line.v1 = addVertex(line.v1); + if (line.cv0) + { + line.cv0 = addVertex(line.cv0); + } + lines.push(line); + return line; + } + else + { + return lines[index]; + } + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/math/Frustum3D.as b/src/org/papervision3d/core/math/Frustum3D.as index 9308eef..767ae4a 100644 --- a/src/org/papervision3d/core/math/Frustum3D.as +++ b/src/org/papervision3d/core/math/Frustum3D.as @@ -1,138 +1,193 @@ package org.papervision3d.core.math { import flash.geom.Matrix3D; - import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; + import org.papervision3d.core.geom.Vertex; + import org.papervision3d.core.math.utils.MathUtil; + /** + * Frustum3D. + * + * @author Tim Knip / floorplanner.com + */ public class Frustum3D { public static const WORLD_PLANES :uint = 0; public static const VIEW_PLANES :uint = 1; public static const SCREEN_PLANES :uint = 2; public static const NEAR :uint = 0; public static const FAR :uint = 1; public static const LEFT :uint = 2; public static const RIGHT :uint = 3; public static const TOP :uint = 4; public static const BOTTOM :uint = 5; public var camera :Camera3D; public var screenClippingPlanes :Vector.<Plane3D>; public var viewClippingPlanes :Vector.<Plane3D>; public var worldClippingPlanes :Vector.<Plane3D>; public var worldBoundingSphere :BoundingSphere3D; /** - * + * Constructor. */ - public function Frustum3D(camera:Camera3D) + public function Frustum3D(camera:Camera3D=null) { this.camera = camera; this.worldBoundingSphere = new BoundingSphere3D(); initPlanes(); } /** * */ protected function initPlanes():void { var i :int; this.screenClippingPlanes = new Vector.<Plane3D>(6, true); this.viewClippingPlanes = new Vector.<Plane3D>(6, true); this.worldClippingPlanes = new Vector.<Plane3D>(6, true); for (i = 0; i < 6; i++) { this.screenClippingPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); this.viewClippingPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); this.worldClippingPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); } this.screenClippingPlanes[ NEAR ].setCoefficients(0, 0, -1, 1); this.screenClippingPlanes[ FAR ].setCoefficients(0, 0, 1, 1); this.screenClippingPlanes[ LEFT ].setCoefficients(1, 0, 0, 1); this.screenClippingPlanes[ RIGHT ].setCoefficients(-1, 0, 0, 1); this.screenClippingPlanes[ TOP ].setCoefficients(0, -1, 0, 1); this.screenClippingPlanes[ BOTTOM ].setCoefficients(0, 1, 0, 1); } + /** + * + */ + public function calcFrustumVertices(camera:Camera3D):void + { + var vertices :Vector.<Vertex> = new Vector.<Vertex>(10, true); + var fov :Number = camera.fov; + var near :Number = camera.near; + var far :Number = camera.far; + var ratio :Number = camera.aspectRatio; + + // compute width and height of the near and far section + var angle : Number = MathUtil.TO_RADIANS * fov * 0.5; + var tang :Number = Math.tan(angle); + var nh :Number = near * tang; + var nw :Number = nh * ratio; + var fh :Number = far * tang; + var fw :Number = fh * ratio; + + var nc :Vertex = new Vertex(0, 0, -near); + var fc :Vertex = new Vertex(0, 0, -far); + + var ntl :Vertex = new Vertex(-nw * 0.5, nh * 0.5, -near); + var nbl :Vertex = new Vertex(-nw * 0.5, -nh * 0.5, -near); + var nbr :Vertex = new Vertex( nw * 0.5, -nh * 0.5, -near); + var ntr :Vertex = new Vertex( nw * 0.5, nh * 0.5, -near); + + var ftl :Vertex = new Vertex(-fw * 0.5, fh * 0.5, -far); + var fbl :Vertex = new Vertex(-fw * 0.5, -fh * 0.5, -far); + var fbr :Vertex = new Vertex( fw * 0.5, -fh * 0.5, -far); + var ftr :Vertex = new Vertex( fw * 0.5, fh * 0.5, -far); + } + /** * Extract frustum planes. * * @param matrix The matrix to extract the planes from (P for eye-space, M*P for world-space). - * @param planes The planes to extract to. + * @param which Which planes to extract. Valid values are VIEW_PLANES, WORLD_PLANES or SCREEN_PLANES. * @param normalize Whether to normalize the planes. Default is true. - * @param flipNormals Whether to flip the plane normals. Default is true. - * NDC is lefthanded (looking down +Z), eye-space is righthanded (looking down -Z). - * Setting @flipNormals to true makes the frustum looking down +Z. + * @param flipNormals Whether to flip the plane normals. + * + * @see #VIEW_PLANES + * @see #WORLD_PLANES + * @see #SCREEN_PLANES */ - public function extractPlanes(matrix:Matrix3D, planes:Vector.<Plane3D>, normalize:Boolean=true, - flipNormals:Boolean=false) : void { + public function extractPlanes(matrix:Matrix3D, which:int, normalize:Boolean=true, flipNormals:Boolean=false) : void + { var m :Vector.<Number> = matrix.rawData; + var planes :Vector.<Plane3D>; var i :int; + switch( which ) + { + case SCREEN_PLANES: + return; + case WORLD_PLANES: + planes = this.worldClippingPlanes; + break; + case VIEW_PLANES: + default: + planes = this.viewClippingPlanes; + break; + } + planes[TOP].setCoefficients( -m[1] + m[3], -m[5] + m[7], -m[9] + m[11], -m[13] + m[15] ); planes[BOTTOM].setCoefficients( m[1] + m[3], m[5] + m[7], m[9] + m[11], m[13] + m[15] ); planes[LEFT].setCoefficients( m[0] + m[3], m[4] + m[7], m[8] + m[11], m[12] + m[15] ); planes[RIGHT].setCoefficients( -m[0] + m[3], -m[4] + m[7], -m[8] + m[11], -m[12] + m[15] ); planes[NEAR].setCoefficients( m[2] + m[3], m[6] + m[7], m[10] + m[11], m[14] + m[15] ); planes[FAR].setCoefficients( -m[2] + m[3], -m[6] + m[7], -m[10] + m[11], -m[14] + m[15] ); if(normalize) { for (i = 0; i < 6; i++) { planes[i].normalize(); } } if(flipNormals) { for (i = 0; i < 6; i++) { planes[i].normal.negate(); } } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/math/utils/MatrixUtil.as b/src/org/papervision3d/core/math/utils/MatrixUtil.as index c53b15f..73927b2 100755 --- a/src/org/papervision3d/core/math/utils/MatrixUtil.as +++ b/src/org/papervision3d/core/math/utils/MatrixUtil.as @@ -1,188 +1,188 @@ package org.papervision3d.core.math.utils { import flash.geom.Matrix3D; import flash.geom.Vector3D; public class MatrixUtil { private static var _f :Vector3D = new Vector3D(); private static var _s :Vector3D = new Vector3D(); private static var _u :Vector3D = new Vector3D(); /** - * + * @author Tim Knip / floorplanner.com */ public static function createLookAtMatrix(eye:Vector3D, target:Vector3D, up:Vector3D, resultMatrix:Matrix3D=null):Matrix3D { resultMatrix = resultMatrix || new Matrix3D(); _f.x = target.x - eye.x; _f.y = target.y - eye.y; _f.z = target.z - eye.z; _f.normalize(); // f x up _s.x = (up.y * _f.z) - (up.z * _f.y); _s.y = (up.z * _f.x) - (up.x * _f.z); _s.z = (up.x * _f.y) - (up.y * _f.x); _s.normalize(); // f x s _u.x = (_s.y * _f.z) - (_s.z * _f.y); _u.y = (_s.z * _f.x) - (_s.x * _f.z); _u.z = (_s.x * _f.y) - (_s.y * _f.x); _u.normalize(); resultMatrix.rawData = Vector.<Number>([ _s.x, _s.y, _s.z, 0, _u.x, _u.y, _u.z, 0, -_f.x, -_f.y, -_f.z, 0, 0, 0, 0, 1 ]); return resultMatrix; } /** * Creates a projection matrix. * * @param fovY * @param aspectRatio * @param near * @param far */ public static function createProjectionMatrix(fovy:Number, aspect:Number, zNear:Number, zFar:Number):Matrix3D { var sine :Number, cotangent :Number, deltaZ :Number; var radians :Number = (fovy / 2) * (Math.PI / 180); deltaZ = zFar - zNear; sine = Math.sin(radians); if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) { return null; } cotangent = Math.cos(radians) / sine; var v:Vector.<Number> = Vector.<Number>([ cotangent / aspect, 0, 0, 0, 0, cotangent, 0, 0, 0, 0, -(zFar + zNear) / deltaZ, -1, 0, 0, -(2 * zFar * zNear) / deltaZ, 0 ]); return new Matrix3D(v); } /** * */ public static function createOrthoMatrix(left:Number, right:Number, top:Number, bottom:Number, zNear:Number, zFar:Number) : Matrix3D { var tx :Number = (right + left) / (right - left); var ty :Number = (top + bottom) / (top - bottom); var tz :Number = (zFar+zNear) / (zFar-zNear); var v:Vector.<Number> = Vector.<Number>([ 2 / (right - left), 0, 0, 0, 0, 2 / (top - bottom), 0, 0, 0, 0, -2 / (zFar-zNear), 0, tx, ty, tz, 1 ]); return new Matrix3D(v); } public static function __gluMakeIdentityd(m : Vector.<Number>) :void { m[0+4*0] = 1; m[0+4*1] = 0; m[0+4*2] = 0; m[0+4*3] = 0; m[1+4*0] = 0; m[1+4*1] = 1; m[1+4*2] = 0; m[1+4*3] = 0; m[2+4*0] = 0; m[2+4*1] = 0; m[2+4*2] = 1; m[2+4*3] = 0; m[3+4*0] = 0; m[3+4*1] = 0; m[3+4*2] = 0; m[3+4*3] = 1; } public static function __gluMultMatricesd(a:Vector.<Number>, b:Vector.<Number>, r:Vector.<Number>):void { var i :int, j :int; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { r[int(i*4+j)] = a[int(i*4+0)]*b[int(0*4+j)] + a[int(i*4+1)]*b[int(1*4+j)] + a[int(i*4+2)]*b[int(2*4+j)] + a[int(i*4+3)]*b[int(3*4+j)]; } } } public static function __gluMultMatrixVecd(matrix : Vector.<Number>, a : Vector.<Number> , out : Vector.<Number>) : void { var i :int; for (i=0; i<4; i++) { out[i] = a[0] * matrix[int(0*4+i)] + a[1] * matrix[int(1*4+i)] + a[2] * matrix[int(2*4+i)] + a[3] * matrix[int(3*4+i)]; } } public static function __gluInvertMatrixd(src : Vector.<Number>, inverse : Vector.<Number>):Boolean { var i :int, j :int, k :int, swap :int; var t :Number; var temp :Vector.<Vector.<Number>> = new Vector.<Vector.<Number>>(4); for (i=0; i<4; i++) { temp[i] = new Vector.<Number>(4, true); for (j=0; j<4; j++) { temp[i][j] = src[i*4+j]; } } __gluMakeIdentityd(inverse); for (i = 0; i < 4; i++) { /* ** Look for largest element in column */ swap = i; for (j = i + 1; j < 4; j++) { if (Math.abs(temp[j][i]) > Math.abs(temp[i][i])) { swap = j; } } if (swap != i) { /* ** Swap rows. */ for (k = 0; k < 4; k++) { t = temp[i][k]; temp[i][k] = temp[swap][k]; temp[swap][k] = t; t = inverse[i*4+k]; inverse[i*4+k] = inverse[swap*4+k]; inverse[swap*4+k] = t; } } if (temp[i][i] == 0) { /* ** No non-zero pivot. The matrix is singular, which shouldn't ** happen. This means the user gave us a bad matrix. */ return false; } t = temp[i][i]; for (k = 0; k < 4; k++) { temp[i][k] /= t; inverse[i*4+k] /= t; } for (j = 0; j < 4; j++) { if (j != i) { t = temp[j][i]; for (k = 0; k < 4; k++) { temp[j][k] -= temp[i][k]*t; inverse[j*4+k] -= inverse[i*4+k]*t; } } } } return true; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/memory/pool/DrawablePool.as b/src/org/papervision3d/core/memory/pool/DrawablePool.as index 1318541..47f3af8 100644 --- a/src/org/papervision3d/core/memory/pool/DrawablePool.as +++ b/src/org/papervision3d/core/memory/pool/DrawablePool.as @@ -1,62 +1,65 @@ package org.papervision3d.core.memory.pool { import org.papervision3d.core.render.draw.items.AbstractDrawable; + /** + * @author Tim Knip / floorplanner.com + */ public class DrawablePool { public var growSize :uint; protected var drawables :Vector.<AbstractDrawable>; private var _drawableClass :Class; private var _currentItem :uint; private var _numItems :uint; public function DrawablePool(drawableClass:Class=null, growSize:uint=20) { this.growSize = growSize; this.drawables = new Vector.<AbstractDrawable>(); _drawableClass = drawableClass; _currentItem = 0; _numItems = 0; grow(); } public function get drawable():AbstractDrawable { if (_currentItem < _numItems) { return drawables[ _currentItem++ ]; } else { _currentItem = drawables.length; grow(); return drawables[ _currentItem++ ]; } } public function reset():void { _currentItem = 0; } protected function grow():void { var i :int; for (i = 0; i < growSize; i++) { drawables.push( new _drawableClass() ); } _numItems = drawables.length; trace("[DrawablePool] grown to " + _numItems + " items of type " + _drawableClass); } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as b/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as index 3e65ff2..33d82e8 100755 --- a/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as +++ b/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as @@ -1,349 +1,352 @@ package org.papervision3d.core.proto { import flash.geom.Vector3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.objects.DisplayObject3D; + /** + * @author Tim Knip / floorplanner.com + */ public class DisplayObjectContainer3D { use namespace pv3d; /** */ public var name :String; /** */ public var parent :DisplayObjectContainer3D; /** */ public var transform :Transform3D; /** */ public var cullingState :int; /** */ pv3d var _children :Vector.<DisplayObject3D>; /** */ private static var _newID :int = 0; /** * */ public function DisplayObjectContainer3D(name:String=null) { this.name = name || "Object" + (_newID++); this.transform = new Transform3D(); this.cullingState = 0; _children = new Vector.<DisplayObject3D>(); } /** * */ public function addChild(child:DisplayObject3D):DisplayObject3D { var root :DisplayObjectContainer3D = this; while( root.parent ) root = root.parent; if (root.findChild(child, true) ) { throw new Error("This child was already added to the scene!"); } child.parent = this; child.transform.parent = this.transform; _children.push(child); return child; } /** * Find a child. * * @param child The child to find. * @param deep Whether to search recursivelly * * @return The found child or null on failure. */ public function findChild(child:DisplayObject3D, deep:Boolean=true):DisplayObject3D { var index :int = _children.indexOf(child); if (index < 0) { if (deep) { var object :DisplayObject3D; for each (object in _children) { var c :DisplayObject3D = object.findChild(child, true); if (c) return c; } } } else { return _children[index]; } return null; } /** * */ public function getChildAt(index:uint):DisplayObject3D { if (index < _children.length) { return _children[index]; } else { return null; } } /** * Gets a child by name. * * @param name Name of the DisplayObject3D to find. * @param deep Whether to perform a recursive search * * @return The found DisplayObject3D or null on failure. */ public function getChildByName(name:String, deep:Boolean=false):DisplayObject3D { var child :DisplayObject3D; for each (child in _children) { if (child.name == name) { return child; } if (deep) { var c :DisplayObject3D = child.getChildByName(name, true); if (c) return c; } } return null; } /** * */ public function lookAt(object:DisplayObject3D, up:Vector3D=null):void { transform.lookAt(object.transform, up); } /** * Removes a child. * * @param child The child to remove. * @param deep Whether to perform a recursive search. * * @return The removed child or null on failure. */ public function removeChild(child:DisplayObject3D, deep:Boolean=false):DisplayObject3D { var index :int = _children.indexOf(child); if (index < 0) { if (deep) { var object :DisplayObject3D; for each (object in _children) { var c :DisplayObject3D = object.removeChild(object, true); if (c) { c.parent = null; return c; } } } return null; } else { child = _children.splice(index, 1)[0]; child.parent = null; return child; } } /** * */ public function removeChildAt(index:int):DisplayObject3D { if (index < _children.length) { return _children.splice(index, 1)[0]; } else { return null; } } /** * */ public function rotateAround(degrees:Number, axis:Vector3D, pivot:*=null):void { pivot = pivot || this.parent; var pivotPoint :Vector3D; if (pivot === this.parent) { pivotPoint = this.parent.transform.localPosition; } else if (pivot is Vector3D) { pivotPoint = pivot as Vector3D; } if (pivotPoint) { transform.rotate(axis, false); } } /** * */ public function get x():Number { return transform.localPosition.x; } public function set x(value:Number):void { transform.localPosition.x = value; transform.dirty = true; } /** * */ public function get y():Number { return transform.localPosition.y; } public function set y(value:Number):void { transform.localPosition.y = value; transform.dirty = true; } /** * */ public function get z():Number { return transform.localPosition.z; } public function set z(value:Number):void { transform.localPosition.z = value; transform.dirty = true; } /** * */ public function get rotationX():Number { return transform.localEulerAngles.x; } public function set rotationX(value:Number):void { transform.localEulerAngles.x = value; transform.dirty = true; } /** * */ public function get rotationY():Number { return transform.localEulerAngles.y; } public function set rotationY(value:Number):void { transform.localEulerAngles.y = value transform.dirty = true; } /** * */ public function get rotationZ():Number { return transform.localEulerAngles.z; } public function set rotationZ(value:Number):void { transform.localEulerAngles.z = value; transform.dirty = true; } /** * */ public function get scaleX():Number { return transform.localScale.x; } public function set scaleX(value:Number):void { transform.localScale.x = value; transform.dirty = true; } /** * */ public function get scaleY():Number { return transform.localScale.y; } public function set scaleY(value:Number):void { transform.localScale.y = value; transform.dirty = true; } /** * */ public function get scaleZ():Number { return transform.localScale.z; } public function set scaleZ(value:Number):void { transform.localScale.z = value; transform.dirty = true; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/proto/Transform3D.as b/src/org/papervision3d/core/proto/Transform3D.as index 5582243..3a78703 100755 --- a/src/org/papervision3d/core/proto/Transform3D.as +++ b/src/org/papervision3d/core/proto/Transform3D.as @@ -1,355 +1,355 @@ package org.papervision3d.core.proto { import flash.geom.Matrix3D; import flash.geom.Vector3D; import org.papervision3d.core.math.Quaternion; import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; /** * Transform3D. * <p></p> * * @author Tim Knip / floorplanner.com */ public class Transform3D { use namespace pv3d; /** */ public static var DEFAULT_LOOKAT_UP :Vector3D = new Vector3D(0, -1, 0); /** */ public var worldTransform :Matrix3D; /** */ public var viewTransform :Matrix3D; /** */ public var screenTransform :Matrix3D; /** */ pv3d var scheduledLookAt :Transform3D; /** */ pv3d var scheduledLookAtUp :Vector3D; /** */ private var _parent :Transform3D; /** The position of the transform in world space. */ private var _position :Vector3D; /** Position of the transform relative to the parent transform. */ private var _localPosition :Vector3D; /** The rotation as Euler angles in degrees. */ private var _eulerAngles :Vector3D; /** The rotation as Euler angles in degrees relative to the parent transform's rotation. */ private var _localEulerAngles :Vector3D; /** The X axis of the transform in world space */ private var _right :Vector3D; /** The Y axis of the transform in world space */ private var _up :Vector3D; /** The Z axis of the transform in world space */ private var _forward :Vector3D; /** The rotation of the transform in world space stored as a Quaternion. */ private var _rotation :Quaternion; /** The rotation of the transform relative to the parent transform's rotation. */ private var _localRotation :Quaternion; /** */ private var _localScale :Vector3D; private var _transform :Matrix3D; private var _localTransform :Matrix3D; private var _dirty :Boolean; /** * */ public function Transform3D() { _position = new Vector3D(); _localPosition = new Vector3D(); _eulerAngles = new Vector3D(); _localEulerAngles = new Vector3D(); _right = new Vector3D(); _up = new Vector3D(); _forward = new Vector3D(); _rotation = new Quaternion(); _localRotation = new Quaternion(); _localScale = new Vector3D(1, 1, 1); _transform = new Matrix3D(); _localTransform = new Matrix3D(); this.worldTransform = new Matrix3D(); this.viewTransform = new Matrix3D(); this.screenTransform = new Matrix3D(); _dirty = true; } /** * Rotates the transform so the forward vector points at /target/'s current position. * <p>Then it rotates the transform to point its up direction vector in the direction hinted at by the * worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. * worldUp is only a hint vector. The up vector of the rotation will only match the worldUp vector if * the forward direction is perpendicular to worldUp</p> */ public function lookAt(target:Transform3D, worldUp:Vector3D=null):void { // actually, we only make note that a lookAt is scheduled. // its up to some higher level class to deal with it. scheduledLookAt = target; scheduledLookAtUp = worldUp || DEFAULT_LOOKAT_UP; _localEulerAngles.x = 0; _localEulerAngles.y = 0; _localEulerAngles.z = 0; var eye :Vector3D = _position; var center :Vector3D = target.position; //_lookAt = MatrixUtil.createLookAtMatrix(eye, center, DEFAULT_LOOKAT_UP); /* var q :Quaternion = Quaternion.createFromMatrix(_lookAt); var euler :Vector3D = q.toEuler(); euler.x *= MathUtil.TO_DEGREES; euler.y *= MathUtil.TO_DEGREES; euler.z *= MathUtil.TO_DEGREES; _eulerAngles.x = -euler.y; _eulerAngles.y = euler.x; _eulerAngles.z = euler.z; */ //_dirty = true; } private var _lookAt :Matrix3D; /** * Applies a rotation of eulerAngles.x degrees around the x axis, eulerAngles.y degrees around * the y axis and eulerAngles.z degrees around the z axis. * * @param eulerAngles * @param relativeToSelf */ public function rotate(eulerAngles:Vector3D, relativeToSelf:Boolean=true):void { if (relativeToSelf) { _localEulerAngles.x = eulerAngles.x % 360; _localEulerAngles.y = eulerAngles.y % 360; _localEulerAngles.z = eulerAngles.z % 360; _localRotation.setFromEuler( -_localEulerAngles.y * MathUtil.TO_RADIANS, _localEulerAngles.z * MathUtil.TO_RADIANS, _localEulerAngles.x * MathUtil.TO_RADIANS ); /* var euler :Vector3D = _localRotation.toEuler(); euler.x *= MathUtil.TO_DEGREES; euler.y *= MathUtil.TO_DEGREES; euler.z *= MathUtil.TO_DEGREES; _localEulerAngles.x = -euler.y; _localEulerAngles.y = euler.x; _localEulerAngles.z = euler.z; */ } else { _eulerAngles.x = eulerAngles.x % 360; _eulerAngles.y = eulerAngles.y % 360; _eulerAngles.z = eulerAngles.z % 360; _rotation.setFromEuler( -_eulerAngles.y * MathUtil.TO_RADIANS, _eulerAngles.z * MathUtil.TO_RADIANS, _eulerAngles.x * MathUtil.TO_RADIANS ); } _dirty = true; } /** * */ public function get dirty():Boolean { return _dirty; } public function set dirty(value:Boolean):void { _dirty = value; } /** * The rotation as Euler angles in degrees. */ public function get eulerAngles():Vector3D { return _eulerAngles; } public function set eulerAngles(value:Vector3D):void { _eulerAngles = value; _dirty = true; } /** * The rotation as Euler angles in degrees relative to the parent transform's rotation. */ public function get localEulerAngles():Vector3D { return _localEulerAngles; } public function set localEulerAngles(value:Vector3D):void { _localEulerAngles = value; _dirty = true; } /** * */ public function get localToWorldMatrix():Matrix3D { if (_dirty) { if (false) { _transform.rawData = _lookAt.rawData; //_transform.prependTranslation( -_localPosition.x, -_localPosition.y, -_localPosition.z); _transform.append(_localRotation.matrix); var euler :Vector3D = Quaternion.createFromMatrix(_transform).toEuler(); euler.x *= MathUtil.TO_DEGREES; euler.y *= MathUtil.TO_DEGREES; euler.z *= MathUtil.TO_DEGREES; //_localEulerAngles.x = -euler.y; //_localEulerAngles.y = euler.x; //_localEulerAngles.z = euler.z; _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); _lookAt = null; } else { rotate( _localEulerAngles, true ); _transform.rawData = _localRotation.matrix.rawData; _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); } rotate( _eulerAngles, false ); _transform.append( _rotation.matrix ); - // _transform.prependScale(_localScale.x, _localScale.y, _localScale.z); + _transform.prependScale(_localScale.x, _localScale.y, _localScale.z); _dirty = false; } return _transform; } /** * The position of the transform in world space. */ public function get position():Vector3D { return _position; } public function set position(value:Vector3D):void { _position = value; _dirty = true; } /** * Position of the transform relative to the parent transform. */ public function get localPosition():Vector3D { return _localPosition; } public function set localPosition(value:Vector3D):void { _localPosition = value; _dirty = true; } /** * */ public function get rotation():Quaternion { return _rotation; } public function set rotation(value:Quaternion):void { _rotation = value; } /** * */ public function get localRotation():Quaternion { return _localRotation; } public function set localRotation(value:Quaternion):void { _localRotation = value; } /** * */ public function get localScale():Vector3D { return _localScale; } public function set localScale(value:Vector3D):void { _localScale = value; _dirty = true; } public function get parent():Transform3D { return _parent; } public function set parent(value:Transform3D):void { _parent = value; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as index 6f30dbc..38d41d5 100755 --- a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as +++ b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as @@ -1,173 +1,174 @@ package org.papervision3d.core.render.pipeline { - import __AS3__.vec.Vector; - import flash.geom.Matrix3D; import flash.geom.Rectangle; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.proto.Transform3D; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.objects.DisplayObject3D; + /** + * @author Tim Knip / floorplanner.com + */ public class BasicPipeline implements IRenderPipeline { use namespace pv3d; private var _scheduledLookAt :Vector.<DisplayObject3D>; private var _lookAtMatrix :Matrix3D; private var _invWorldMatrix :Matrix3D; /** * */ public function BasicPipeline() { _scheduledLookAt = new Vector.<DisplayObject3D>(); _lookAtMatrix = new Matrix3D(); _invWorldMatrix = new Matrix3D(); } /** * */ public function execute(renderData:RenderData):void { var scene :DisplayObject3D = renderData.scene; var camera :Camera3D = renderData.camera; var rect :Rectangle = renderData.viewport.sizeRectangle; _scheduledLookAt.length = 0; transformToWorld(scene); // handle lookAt if (_scheduledLookAt.length) { handleLookAt(); } camera.update(rect); transformToView(camera, scene); } /** * Processes all scheduled lookAt's. */ protected function handleLookAt():void { while (_scheduledLookAt.length) { var object :DisplayObject3D = _scheduledLookAt.pop(); var parent :DisplayObject3D = object.parent as DisplayObject3D; var transform :Transform3D = object.transform; var eye :Vector3D = transform.position; var tgt :Vector3D = transform.scheduledLookAt.position; var up :Vector3D = transform.scheduledLookAtUp; // create the lookAt matrix MatrixUtil.createLookAtMatrix(eye, tgt, up, _lookAtMatrix); // prepend it to the world matrix object.transform.worldTransform.prepend(_lookAtMatrix); if (parent) { _invWorldMatrix.rawData = parent.transform.worldTransform.rawData; _invWorldMatrix.invert(); object.transform.worldTransform.append(_invWorldMatrix); } var components :Vector.<Vector3D> = object.transform.worldTransform.decompose(); var euler :Vector3D = components[1]; object.transform.localEulerAngles.x = -euler.x * MathUtil.TO_DEGREES; object.transform.localEulerAngles.y = euler.y * MathUtil.TO_DEGREES; object.transform.localEulerAngles.z = euler.z * MathUtil.TO_DEGREES; // clear object.transform.scheduledLookAt = null; } } /** * */ protected function transformToWorld(object:DisplayObject3D, parent:DisplayObject3D=null, processLookAt:Boolean=false):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; if (!processLookAt && object.transform.scheduledLookAt) { _scheduledLookAt.push( object ); } wt.rawData = object.transform.localToWorldMatrix.rawData; if (parent) { wt.append(parent.transform.worldTransform); } object.transform.position = wt.transformVector(object.transform.localPosition); for each (child in object._children) { transformToWorld(child, object, processLookAt); } } /** * */ protected function transformToView(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; var vt :Matrix3D = object.transform.viewTransform; vt.rawData = wt.rawData; vt.append(camera.viewMatrix); if (object.geometry is VertexGeometry) { projectVertices(camera, object); } for each (child in object._children) { transformToView(camera, child); } } /** * */ protected function projectVertices(camera:Camera3D, object:DisplayObject3D):void { var vt :Matrix3D = object.transform.viewTransform; var st :Matrix3D = object.transform.screenTransform; // move the vertices into view / camera space // we'll need the vertices in this space to check whether vertices are behind the camera. // if we move to screen space in one go, screen vertices could move to infinity. vt.transformVectors(object.geometry.vertexData, object.geometry.viewVertexData); // append the projection matrix to the object's view matrix st.rawData = vt.rawData; st.append(camera.projectionMatrix); // move the vertices to screen space. // AKA: the perspective divide // NOTE: some vertices may have moved to infinity, we need to check while processing triangles. // IF so we need to check whether we need to clip the triangles or disgard them. Utils3D.projectVectors(st, object.geometry.vertexData, object.geometry.screenVertexData, object.geometry.uvtData); } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Frustum.as b/src/org/papervision3d/objects/primitives/Frustum.as new file mode 100644 index 0000000..59bce83 --- /dev/null +++ b/src/org/papervision3d/objects/primitives/Frustum.as @@ -0,0 +1,25 @@ +package org.papervision3d.objects.primitives +{ + import org.papervision3d.core.geom.Vertex; + import org.papervision3d.core.geom.provider.LineGeometry; + import org.papervision3d.objects.DisplayObject3D; + + /** + * + */ + public class Frustum extends DisplayObject3D + { + public var nc :Vertex; + public var fc :Vertex; + public var ntl :Vertex; + /** + * + */ + public function Frustum(name:String=null) + { + super(name); + + this.geometry = new LineGeometry(); + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 9dd1228..b134188 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,395 +1,395 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; /** - * + * @author Tim Knip / floorplanner.com */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); _drawablePool.reset(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var sv0 :Vector3D = new Vector3D(); var sv1 :Vector3D = new Vector3D(); var sv2 :Vector3D = new Vector3D(); stats.totalObjects++; if (object.cullingState == 0 && object.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; // Setup clipflags for the triangle (detect whether the tri is in, out or straddling // the frustum). // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // Grab the screem vertices sv0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; sv0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; sv1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; sv1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; sv2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; sv2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; // When *not* straddling the near plane we can safely test for backfacing triangles // (as we're sure the infinity case is filtered out). // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } // Okay, all vertices are in front of the near plane and backfacing tris are gone. // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = sv0.x; drawable.y0 = sv0.y; drawable.x1 = sv1.x; drawable.y1 = sv1.y; drawable.x2 = sv2.x; drawable.y2 = sv2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
77689e9262eeac50c444fb896cd6b490805b71c5
seperate renderer
diff --git a/src/org/papervision3d/core/geom/provider/VertexGeometry.as b/src/org/papervision3d/core/geom/provider/VertexGeometry.as index cef05dc..da732a6 100755 --- a/src/org/papervision3d/core/geom/provider/VertexGeometry.as +++ b/src/org/papervision3d/core/geom/provider/VertexGeometry.as @@ -1,156 +1,164 @@ package org.papervision3d.core.geom.provider { import org.papervision3d.core.geom.Geometry; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.ns.pv3d; public class VertexGeometry extends Geometry { - use namespace pv3d; + + + public var vertices :Vector.<Vertex>; + + public var uvtData :Vector.<Number>; + public var vertexData :Vector.<Number>; - public var vertices :Vector.<Vertex>; - pv3d var vertexData :Vector.<Number>; - pv3d var viewVertexData :Vector.<Number>; - pv3d var screenVertexData :Vector.<Number>; - pv3d var uvtData :Vector.<Number>; + public var screenVertexLength : int = 0; + public var viewVertexLength : int = 0; /** * Constructor */ public function VertexGeometry(name:String=null) { super(); vertices = new Vector.<Vertex>(); vertexData = new Vector.<Number>(); - viewVertexData = new Vector.<Number>(); - screenVertexData = new Vector.<Number>(); uvtData = new Vector.<Number>(); } /** * Adds a new Vertex. * * @param vertex * * @return The added vertex. * * @see org.papervision3d.core.geom.Vertex */ public function addVertex(vertex:Vertex):Vertex { var index :int = vertices.indexOf(vertex); if (index >= 0) { return vertices[index]; } else { vertex.vertexGeometry = this; + vertex.vectorIndexX = vertexData.push(vertex.x) - 1; vertex.vectorIndexY = vertexData.push(vertex.y) - 1; vertex.vectorIndexZ = vertexData.push(vertex.z) - 1; - vertex.screenIndexX = screenVertexData.push(vertex.x) - 1; - vertex.screenIndexY = screenVertexData.push(vertex.y) - 1; - viewVertexData.push(vertex.x, vertex.y, vertex.z); + + viewVertexLength += 3; + vertex.screenIndexX = screenVertexLength; + + vertex.screenIndexY = screenVertexLength+1; + screenVertexLength += 2; uvtData.push(0, 0, 0); vertices.push(vertex); return vertex; } } /** * Finds a vertex within the specified range. * * @param vertex * @param range * * @return The found vertex or null if not found. */ public function findVertexInRange(vertex:Vertex, range:Number=0.01):Vertex { var v :Vertex; for each (v in vertices) { if (vertex.x > v.x - range && vertex.x < v.x + range && vertex.y > v.y - range && vertex.y < v.y + range && vertex.z > v.z - range && vertex.z < v.z + range) { return v; } } return null; } /** * Removes a new Vertex. * * @param vertex The vertex to remove. * * @return The removed vertex or null on failure. * * @see org.papervision3d.core.geom.Vertex */ public function removeVertex(vertex:Vertex):Vertex { var index :int = vertices.indexOf(vertex); if (index < 0) { return null; } else { vertices.splice(index, 1); vertex.vertexGeometry = null; vertex.vectorIndexX = vertex.vectorIndexY = vertex.vectorIndexZ = -1; vertex.screenIndexX = vertex.screenIndexY = -1; updateIndices(); return vertex; } } /** * */ public function removeAllVertices():void { this.vertices.length = 0; updateIndices(); } /** * */ public function updateIndices():void { var vertex :Vertex; vertexData.length = 0; - viewVertexData.length = 0; - screenVertexData.length = 0; + viewVertexLength = 0; + screenVertexLength = 0; uvtData.length = 0; for each (vertex in vertices) { vertex.vectorIndexX = vertexData.push(vertex.x) - 1; vertex.vectorIndexY = vertexData.push(vertex.y) - 1; vertex.vectorIndexZ = vertexData.push(vertex.z) - 1; - vertex.screenIndexX = screenVertexData.push(vertex.x) - 1; - vertex.screenIndexY = screenVertexData.push(vertex.y) - 1; - viewVertexData.push(vertex.x, vertex.y, vertex.z); + + viewVertexLength += 3; + vertex.screenIndexX = screenVertexLength; + + vertex.screenIndexY = screenVertexLength+1; + screenVertexLength += 2; uvtData.push(0, 0, 0); + } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/object/ObjectRenderer.as b/src/org/papervision3d/core/render/object/ObjectRenderer.as new file mode 100644 index 0000000..d3590cc --- /dev/null +++ b/src/org/papervision3d/core/render/object/ObjectRenderer.as @@ -0,0 +1,28 @@ +package org.papervision3d.core.render.object +{ + import __AS3__.vec.Vector; + + import org.papervision3d.core.geom.provider.VertexGeometry; + + public class ObjectRenderer + { + public var geometry : VertexGeometry; + public var viewVertexData :Vector.<Number>; + public var screenVertexData :Vector.<Number>; + + public function ObjectRenderer() + { + viewVertexData = new Vector.<Number>(); + screenVertexData = new Vector.<Number>(); + + } + + public function updateIndices():void{ + + viewVertexData.length = geometry.viewVertexLength; + screenVertexData.length = geometry.screenVertexLength; + + } + + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as index 6f30dbc..27bb4a2 100755 --- a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as +++ b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as @@ -1,173 +1,174 @@ package org.papervision3d.core.render.pipeline { import __AS3__.vec.Vector; import flash.geom.Matrix3D; import flash.geom.Rectangle; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.proto.Transform3D; import org.papervision3d.core.render.data.RenderData; + import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.objects.DisplayObject3D; public class BasicPipeline implements IRenderPipeline { use namespace pv3d; private var _scheduledLookAt :Vector.<DisplayObject3D>; private var _lookAtMatrix :Matrix3D; private var _invWorldMatrix :Matrix3D; /** * */ public function BasicPipeline() { _scheduledLookAt = new Vector.<DisplayObject3D>(); _lookAtMatrix = new Matrix3D(); _invWorldMatrix = new Matrix3D(); } /** * */ public function execute(renderData:RenderData):void { var scene :DisplayObject3D = renderData.scene; var camera :Camera3D = renderData.camera; var rect :Rectangle = renderData.viewport.sizeRectangle; _scheduledLookAt.length = 0; transformToWorld(scene); // handle lookAt if (_scheduledLookAt.length) { handleLookAt(); } camera.update(rect); transformToView(camera, scene); } /** * Processes all scheduled lookAt's. */ protected function handleLookAt():void { while (_scheduledLookAt.length) { var object :DisplayObject3D = _scheduledLookAt.pop(); var parent :DisplayObject3D = object.parent as DisplayObject3D; var transform :Transform3D = object.transform; var eye :Vector3D = transform.position; var tgt :Vector3D = transform.scheduledLookAt.position; var up :Vector3D = transform.scheduledLookAtUp; // create the lookAt matrix MatrixUtil.createLookAtMatrix(eye, tgt, up, _lookAtMatrix); // prepend it to the world matrix object.transform.worldTransform.prepend(_lookAtMatrix); if (parent) { _invWorldMatrix.rawData = parent.transform.worldTransform.rawData; _invWorldMatrix.invert(); object.transform.worldTransform.append(_invWorldMatrix); } var components :Vector.<Vector3D> = object.transform.worldTransform.decompose(); var euler :Vector3D = components[1]; object.transform.localEulerAngles.x = -euler.x * MathUtil.TO_DEGREES; object.transform.localEulerAngles.y = euler.y * MathUtil.TO_DEGREES; object.transform.localEulerAngles.z = euler.z * MathUtil.TO_DEGREES; // clear object.transform.scheduledLookAt = null; } } /** * */ protected function transformToWorld(object:DisplayObject3D, parent:DisplayObject3D=null, processLookAt:Boolean=false):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; if (!processLookAt && object.transform.scheduledLookAt) { _scheduledLookAt.push( object ); } wt.rawData = object.transform.localToWorldMatrix.rawData; if (parent) { wt.append(parent.transform.worldTransform); } object.transform.position = wt.transformVector(object.transform.localPosition); for each (child in object._children) { transformToWorld(child, object, processLookAt); } } /** * */ protected function transformToView(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; var vt :Matrix3D = object.transform.viewTransform; vt.rawData = wt.rawData; vt.append(camera.viewMatrix); - if (object.geometry is VertexGeometry) + if (object.renderer.geometry is VertexGeometry) { projectVertices(camera, object); } for each (child in object._children) { transformToView(camera, child); } } /** * */ protected function projectVertices(camera:Camera3D, object:DisplayObject3D):void { var vt :Matrix3D = object.transform.viewTransform; var st :Matrix3D = object.transform.screenTransform; - + var renderer : ObjectRenderer = object.renderer; // move the vertices into view / camera space // we'll need the vertices in this space to check whether vertices are behind the camera. // if we move to screen space in one go, screen vertices could move to infinity. - vt.transformVectors(object.geometry.vertexData, object.geometry.viewVertexData); + vt.transformVectors(renderer.geometry.vertexData, renderer.viewVertexData); // append the projection matrix to the object's view matrix st.rawData = vt.rawData; st.append(camera.projectionMatrix); // move the vertices to screen space. // AKA: the perspective divide // NOTE: some vertices may have moved to infinity, we need to check while processing triangles. // IF so we need to check whether we need to clip the triangles or disgard them. - Utils3D.projectVectors(st, object.geometry.vertexData, object.geometry.screenVertexData, object.geometry.uvtData); + Utils3D.projectVectors(st, renderer.geometry.vertexData, renderer.screenVertexData, renderer.geometry.uvtData); } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/DisplayObject3D.as b/src/org/papervision3d/objects/DisplayObject3D.as index 3ee2852..327ebde 100755 --- a/src/org/papervision3d/objects/DisplayObject3D.as +++ b/src/org/papervision3d/objects/DisplayObject3D.as @@ -1,44 +1,31 @@ package org.papervision3d.objects { import __AS3__.vec.Vector; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.proto.DisplayObjectContainer3D; + import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.materials.AbstractMaterial; /** * */ public class DisplayObject3D extends DisplayObjectContainer3D { /** * - */ - public var material:AbstractMaterial; - - /** - * - */ - public var geometry:VertexGeometry; - - /** - * - */ - public var viewVertexData :Vector.<Number>; - - /** - * - */ - public var screenVertexData :Vector.<Number>; - - /** - * - */ + */ + + public var material:AbstractMaterial; + public var renderer:ObjectRenderer; + public function DisplayObject3D(name:String=null) { super(name); - viewVertexData = new Vector.<Number>(); - screenVertexData = new Vector.<Number>(); + renderer = new ObjectRenderer(); + } + + } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Cube.as b/src/org/papervision3d/objects/primitives/Cube.as index 7f5fb0f..6cd1d44 100755 --- a/src/org/papervision3d/objects/primitives/Cube.as +++ b/src/org/papervision3d/objects/primitives/Cube.as @@ -1,80 +1,86 @@ package org.papervision3d.objects.primitives { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.UVCoord; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.materials.AbstractMaterial; /** * */ public class Cube extends DisplayObject3D { /** * */ - private var triGeometry : TriangleGeometry; + + private var triGeometry : TriangleGeometry; public function Cube(material:AbstractMaterial, size:Number = 100, name:String=null) { super(name); this.material = material; - geometry = triGeometry = new TriangleGeometry(); + renderer.geometry = triGeometry = new TriangleGeometry(); create(size); } - + + + /** * */ protected function create(size:Number):void { var sz : Number = size / 2; var v :Array = [ new Vertex(-sz, sz, -sz), new Vertex(sz, sz, -sz), new Vertex(sz, -sz, -sz), new Vertex(-sz, -sz, -sz), new Vertex(-sz, sz, sz), new Vertex(sz, sz, sz), new Vertex(sz, -sz, sz), new Vertex(-sz, -sz, sz) ]; var vertex : Vertex; for each(vertex in v) { - this.geometry.addVertex(vertex); + this.renderer.geometry.addVertex(vertex); } var uv0 :UVCoord = new UVCoord(0, 1); var uv1 :UVCoord = new UVCoord(0, 0); var uv2 :UVCoord = new UVCoord(1, 0); var uv3 :UVCoord = new UVCoord(1, 1); // top triGeometry.addTriangle(new Triangle(material, v[0], v[4], v[5], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(material, v[0], v[5], v[1], uv0, uv2, uv3) ); // bottom triGeometry.addTriangle(new Triangle(material, v[6], v[7], v[3], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(material, v[6], v[3], v[2], uv2, uv0, uv3) ); // left triGeometry.addTriangle(new Triangle(material, v[0], v[3], v[7], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(material, v[0], v[7], v[4], uv1, uv3, uv2) ); // right triGeometry.addTriangle(new Triangle(material, v[5], v[6], v[2], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(material, v[5], v[2], v[1], uv1, uv3, uv2) ); // front triGeometry.addTriangle(new Triangle(material, v[0], v[1], v[2], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(material, v[0], v[2], v[3], uv2, uv0, uv3) ); // back triGeometry.addTriangle(new Triangle(material, v[6], v[5], v[4], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(material, v[6], v[4], v[7], uv0, uv2, uv3) ); + + renderer.updateIndices(); + } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Plane.as b/src/org/papervision3d/objects/primitives/Plane.as index 97d187a..b371a37 100644 --- a/src/org/papervision3d/objects/primitives/Plane.as +++ b/src/org/papervision3d/objects/primitives/Plane.as @@ -1,60 +1,62 @@ package org.papervision3d.objects.primitives { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.UVCoord; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.materials.AbstractMaterial; import org.papervision3d.objects.DisplayObject3D; public class Plane extends DisplayObject3D { public function Plane(material:AbstractMaterial, width:Number=100, height:Number=100, segX:Number=1, segY:Number=1, name:String=null) { super(name); + this.material = material; - this.geometry = new TriangleGeometry(); + this.renderer.geometry = new TriangleGeometry(); create(width, height, segX, segY); } protected function create(width:Number, height:Number, segX:Number=1, segY:Number=1):void { var sizeX : Number = width / 2; var sizeZ : Number = height / 2; var stepX :Number = width / segX; var stepZ :Number = height / segY; var curX :Number = -sizeX; var curZ :Number = sizeZ; var curU :Number = 0; var curV :Number = 0; var i :int, j :int; for (i = 0; i < segX; i++) { curX = -sizeX + (i * stepX); for (j = 0; j < segY; j++) { curZ = sizeZ - (j * stepZ); var v0 :Vertex = new Vertex(curX, 0, curZ); var v1 :Vertex = new Vertex(curX + stepX, 0, curZ); var v2 :Vertex = new Vertex(curX + stepX, 0, curZ - stepZ); var v3 :Vertex = new Vertex(curX, 0, curZ - stepZ); var uv0 :UVCoord = new UVCoord(0, 1); var uv1 :UVCoord = new UVCoord(0, 0); var uv2 :UVCoord = new UVCoord(1, 0); var uv3 :UVCoord = new UVCoord(1, 1); - TriangleGeometry(geometry).addTriangle( new Triangle(material, v0, v1, v2, uv0, uv1, uv2) ); - TriangleGeometry(geometry).addTriangle( new Triangle(material, v0, v2, v3, uv0, uv2, uv3) ); + TriangleGeometry(renderer.geometry).addTriangle( new Triangle(material, v0, v1, v2, uv0, uv1, uv2) ); + TriangleGeometry(renderer.geometry).addTriangle( new Triangle(material, v0, v2, v3, uv0, uv2, uv3) ); } } - TriangleGeometry(geometry).mergeVertices(); + TriangleGeometry(renderer.geometry).mergeVertices(); + renderer.updateIndices(); } } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 65f450f..a290acb 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,399 +1,401 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; + import org.papervision3d.core.render.object.ObjectRenderer; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; /** * */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; private var _v0 :Vector3D; private var _v1 :Vector3D; private var _v2 :Vector3D; private var _sv0 :Vector3D; private var _sv1 :Vector3D; private var _sv2 :Vector3D; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; _v0 = new Vector3D(); _v1 = new Vector3D(); _v2 = new Vector3D(); _sv0 = new Vector3D(); _sv1 = new Vector3D(); _sv2 = new Vector3D(); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); var _sv0 :Vector3D = new Vector3D(); var _sv1 :Vector3D = new Vector3D(); var _sv2 :Vector3D = new Vector3D(); stats.totalObjects++; - if (object.cullingState == 0 && object.geometry is TriangleGeometry) + if (object.cullingState == 0 && object.renderer.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; - geometry = object.geometry as TriangleGeometry; + geometry = object.renderer.geometry as TriangleGeometry; + var renderer : ObjectRenderer = object.renderer; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space - v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; - v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; - v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; - v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; - v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; - v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; - v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; - v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; - v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; + v0.x = renderer.viewVertexData[ triangle.v0.vectorIndexX ]; + v0.y = renderer.viewVertexData[ triangle.v0.vectorIndexY ]; + v0.z = renderer.viewVertexData[ triangle.v0.vectorIndexZ ]; + v1.x = renderer.viewVertexData[ triangle.v1.vectorIndexX ]; + v1.y = renderer.viewVertexData[ triangle.v1.vectorIndexY ]; + v1.z = renderer.viewVertexData[ triangle.v1.vectorIndexZ ]; + v2.x = renderer.viewVertexData[ triangle.v2.vectorIndexX ]; + v2.y = renderer.viewVertexData[ triangle.v2.vectorIndexY ]; + v2.z = renderer.viewVertexData[ triangle.v2.vectorIndexZ ]; // setup clipflags // first test the near plane as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } // passed the near test loosely, verts may have projected to infinity // we do it here, cause - paranoia - even these array accesses may cost us - _sv0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; - _sv0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; - _sv1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; - _sv1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; - _sv2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; - _sv2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; + _sv0.x = renderer.screenVertexData[ triangle.v0.screenIndexX ]; + _sv0.y = renderer.screenVertexData[ triangle.v0.screenIndexY ]; + _sv1.x = renderer.screenVertexData[ triangle.v1.screenIndexX ]; + _sv1.y = renderer.screenVertexData[ triangle.v1.screenIndexY ]; + _sv2.x = renderer.screenVertexData[ triangle.v2.screenIndexX ]; + _sv2.y = renderer.screenVertexData[ triangle.v2.screenIndexY ]; // when *not* straddling the near plane we can safely test for backfaces // ie: lets not clip backfacing triangles! if (triangle.clipFlags != ClipFlags.NEAR) { // Simple backface culling. if ((_sv2.x - _sv0.x) * (_sv1.y - _sv0.y) - (_sv2.y - _sv0.y) * (_sv1.x - _sv0.x) > 0) { stats.culledTriangles ++; continue; } } // okay, continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // triangle completely in view var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = _sv0.x; drawable.y0 = _sv0.y; drawable.x1 = _sv1.x; drawable.y1 = _sv1.y; drawable.x2 = _sv2.x; drawable.y2 = _sv2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { clipViewTriangle(camera, triangle, v0, v1, v2); } } } for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = new TriangleDrawable(); drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
671f599ef19568e09a53716fc6c30c5bc7bceb6b
more optimizattion
diff --git a/README b/README index 6718ddc..0992883 100644 --- a/README +++ b/README @@ -1,42 +1,8 @@ Papervision3D - 3.0 This code is for discussing the core architecture. Your comments are welcome! Discussion: ============================================== -geometry: -VertexGeometry holds a mesh's vertices and maintains some Vector.<Number> arrays -which we can pass easily to Utils3D.projectVectors() - -camera: -The camera *should* be part of the scenegraph (ie: scene.addChild(camera);) - -projection: -* assuming a righthanded system. -* uses the default OpenGL projection matrix (gluPerspective) - => Flash's native PerspectiveProjection is not used on purpose. - => This is up for grabs. Think its not well suited for clipping etc. (I'd rather work in normalized clip space) -* while traversing the scenegraph matrices are post-multiplied (ie: earth.rotationY++ will orbit sun) -* we need a mechanism to distinguish between "local" and "global" rotations. - => maybe roll / pitch / yaw to make earth spin its own axis (local) - => maybe rotationX / Y / Z to make earth spin its parent (sun, global) - => or do we? Maybe I'm missing something here. -* projection is divided in some steps: - 1. transform all objects including camera to world space - 2. update camera: calculate its inverse world transform - => cull objects by bbox / bshpere outside camera frustum - 3. transform all objects to view / camera space - a] check whether objects are behind, in front or straddling the near-plane, clip if needed - => think this can only be done in view / camera space *before* the perspective transform - b] cull triangles outside view - 4. perspective divide (mult the view matrix with the projection matrix) - 5. draw - - Clipping can be done in multiple spaces: we can clip triangles in world, view(?) or in screen space. - For clipping in screen space we *must* be sure all vertices are in front of the near plane. - => ie: all triangles straddling the near plane should have been clipped already - Clipping in world space has advantage that we can move from object to screen space in one go. - Clipping in view space: not sure, its ideal for clipping to the near plane - \ No newline at end of file diff --git a/src/Main.as b/src/Main.as index d038d51..80a7e23 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,167 +1,169 @@ package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public var tf :TextField; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; var aspect :Number = stage.stageWidth / stage.stageHeight; container = new Sprite(); addChild(container); container.x = stage.stageWidth / 2; container.y = stage.stageHeight / 2; addChild(new Stats()); tf = new TextField(); addChild(tf); tf.x = 1; tf.y = 110; tf.width = 300; tf.height = 200; tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); tf.selectable = false; tf.multiline = true; tf.text = "Papervision3D - version 3.0"; - camera = new Camera3D(50, 400, 2300, "Camera01"); + camera = new Camera3D(30, 400, 2300, "Camera01"); pipeline = new BasicPipeline(); cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 200; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; scene = new DisplayObject3D("Scene"); scene.addChild( camera ); scene.addChild( cube ); camera.z = 800; viewport = new Viewport3D(0, 0, true); renderer = new BasicRenderEngine(); renderer.clipFlags = ClipFlags.ALL; addChild(viewport); var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); scene.addChild(plane); // render(); camera.y = 500; camera.lookAt(cube.getChildByName("red")); render(); //camera.lookAt(cube.getChildByName("red")); render(); render(); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("blue").rotationZ += 4; cube.getChildByName("blue").transform.eulerAngles.y--; - cube.getChildByName("green").lookAt( cube.getChildByName("red") ); + cube.getChildByName("green").lookAt( cube.getChildByName("blue") ); + + cube.lookAt(cube.getChildByName("blue")); cube.getChildByName("red").transform.eulerAngles.z++; // cube.getChildByName("red").transform.eulerAngles.y--; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(scene, camera, viewport); var stats :RenderStats = renderer.renderData.stats; tf.text = "Papervision3D - version 3.0\n" + "\ntotal objects: " + stats.totalObjects + "\nculled objects: " + stats.culledObjects + "\n\ntotal triangles: " + stats.totalTriangles + "\nculled triangles: " + stats.culledTriangles + "\nclipped triangles: " + stats.clippedTriangles; } } } diff --git a/src/org/papervision3d/core/memory/pool/DrawablePool.as b/src/org/papervision3d/core/memory/pool/DrawablePool.as new file mode 100644 index 0000000..1318541 --- /dev/null +++ b/src/org/papervision3d/core/memory/pool/DrawablePool.as @@ -0,0 +1,62 @@ +package org.papervision3d.core.memory.pool +{ + import org.papervision3d.core.render.draw.items.AbstractDrawable; + + public class DrawablePool + { + public var growSize :uint; + + protected var drawables :Vector.<AbstractDrawable>; + + private var _drawableClass :Class; + private var _currentItem :uint; + private var _numItems :uint; + + public function DrawablePool(drawableClass:Class=null, growSize:uint=20) + { + this.growSize = growSize; + this.drawables = new Vector.<AbstractDrawable>(); + + _drawableClass = drawableClass; + _currentItem = 0; + _numItems = 0; + + grow(); + } + + public function get drawable():AbstractDrawable + { + if (_currentItem < _numItems) + { + return drawables[ _currentItem++ ]; + } + else + { + _currentItem = drawables.length; + + grow(); + + return drawables[ _currentItem++ ]; + } + } + + public function reset():void + { + _currentItem = 0; + } + + protected function grow():void + { + var i :int; + + for (i = 0; i < growSize; i++) + { + drawables.push( new _drawableClass() ); + } + + _numItems = drawables.length; + + trace("[DrawablePool] grown to " + _numItems + " items of type " + _drawableClass); + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 65f450f..9dd1228 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,399 +1,395 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; + import org.papervision3d.core.memory.pool.DrawablePool; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; /** * */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; - private var _v0 :Vector3D; - private var _v1 :Vector3D; - private var _v2 :Vector3D; - private var _sv0 :Vector3D; - private var _sv1 :Vector3D; - private var _sv2 :Vector3D; + private var _drawablePool :DrawablePool; /** * */ public function BasicRenderEngine() { super(); init(); } /** * */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; - _v0 = new Vector3D(); - _v1 = new Vector3D(); - _v2 = new Vector3D(); - _sv0 = new Vector3D(); - _sv1 = new Vector3D(); - _sv2 = new Vector3D(); + _drawablePool = new DrawablePool(TriangleDrawable); } /** * */ override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { renderData.scene = scene; renderData.camera = camera; renderData.viewport = viewport; renderData.stats = stats; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); stats.clear(); + _drawablePool.reset(); + fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); - var _sv0 :Vector3D = new Vector3D(); - var _sv1 :Vector3D = new Vector3D(); - var _sv2 :Vector3D = new Vector3D(); + var sv0 :Vector3D = new Vector3D(); + var sv1 :Vector3D = new Vector3D(); + var sv2 :Vector3D = new Vector3D(); stats.totalObjects++; if (object.cullingState == 0 && object.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; stats.totalTriangles++; // get vertices in view / camera space v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; - // setup clipflags - // first test the near plane as verts behind near project to infinity. + // Setup clipflags for the triangle (detect whether the tri is in, out or straddling + // the frustum). + // First test the near plane, as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } - // passed the near test loosely, verts may have projected to infinity - // we do it here, cause - paranoia - even these array accesses may cost us - _sv0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; - _sv0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; - _sv1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; - _sv1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; - _sv2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; - _sv2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; + // Grab the screem vertices + sv0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; + sv0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; + sv1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; + sv1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; + sv2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; + sv2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; - // when *not* straddling the near plane we can safely test for backfaces - // ie: lets not clip backfacing triangles! + // When *not* straddling the near plane we can safely test for backfacing triangles + // (as we're sure the infinity case is filtered out). + // Hence we can have an early out by a simple backface test. if (triangle.clipFlags != ClipFlags.NEAR) { - // Simple backface culling. - if ((_sv2.x - _sv0.x) * (_sv1.y - _sv0.y) - (_sv2.y - _sv0.y) * (_sv1.x - _sv0.x) > 0) + if ((sv2.x - sv0.x) * (sv1.y - sv0.y) - (sv2.y - sv0.y) * (sv1.x - sv0.x) > 0) { stats.culledTriangles ++; continue; } } - // okay, continue setting up clipflags + // Okay, all vertices are in front of the near plane and backfacing tris are gone. + // Continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { - // triangle completely in view + // Triangle completely inside the (view) frustum var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; - drawable.x0 = _sv0.x; - drawable.y0 = _sv0.y; - drawable.x1 = _sv1.x; - drawable.y1 = _sv1.y; - drawable.x2 = _sv2.x; - drawable.y2 = _sv2.y; + drawable.x0 = sv0.x; + drawable.y0 = sv0.y; + drawable.x1 = sv1.x; + drawable.y1 = sv1.y; + drawable.x2 = sv2.x; + drawable.y2 = sv2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { + // Triangle straddles some plane of the (view) camera frustum, we need clip 'm clipViewTriangle(camera, triangle, v0, v1, v2); } } } + // Recurse for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { stats.culledTriangles ++; continue; } - var drawable :TriangleDrawable = new TriangleDrawable(); + var drawable :TriangleDrawable = _drawablePool.drawable as TriangleDrawable; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } } } \ No newline at end of file
timknip/papervision3d
e1700f32e9d91e6e768820e8d7e1911a437b0ace
some optimizattion
diff --git a/src/Main.as b/src/Main.as index 1a14b3f..d038d51 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,156 +1,167 @@ package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; - import flash.geom.Rectangle; + import flash.text.TextField; + import flash.text.TextFormat; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; - import org.papervision3d.core.render.draw.list.DrawableList; + import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; - public var viewport :Rectangle; + public var viewport :Viewport3D; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; - + public var tf :TextField; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; var aspect :Number = stage.stageWidth / stage.stageHeight; container = new Sprite(); addChild(container); container.x = stage.stageWidth / 2; container.y = stage.stageHeight / 2; addChild(new Stats()); - camera = new Camera3D(30, 400, 2300, "Camera01"); + tf = new TextField(); + addChild(tf); + tf.x = 1; + tf.y = 110; + tf.width = 300; + tf.height = 200; + tf.defaultTextFormat = new TextFormat("Arial", 10, 0xff0000); + tf.selectable = false; + tf.multiline = true; + tf.text = "Papervision3D - version 3.0"; + + camera = new Camera3D(50, 400, 2300, "Camera01"); pipeline = new BasicPipeline(); cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 200; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; scene = new DisplayObject3D("Scene"); scene.addChild( camera ); scene.addChild( cube ); camera.z = 800; - renderData = new RenderData(); - renderData.camera = camera; - renderData.scene = scene; - renderData.drawlist = new DrawableList(); - - renderData.viewport = new Viewport3D(0, 0, true); + viewport = new Viewport3D(0, 0, true); renderer = new BasicRenderEngine(); - renderer.clipFlags = ClipFlags.NONE; + renderer.clipFlags = ClipFlags.ALL; - addChild(renderData.viewport); + addChild(viewport); var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); scene.addChild(plane); // render(); camera.y = 500; camera.lookAt(cube.getChildByName("red")); render(); //camera.lookAt(cube.getChildByName("red")); render(); render(); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { // rotation in global frame of reference : append // cube.x ++; cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); + cube.getChildByName("blue").rotationZ += 4; + cube.getChildByName("blue").transform.eulerAngles.y--; cube.getChildByName("green").lookAt( cube.getChildByName("red") ); cube.getChildByName("red").transform.eulerAngles.z++; - cube.getChildByName("red").transform.eulerAngles.y--; + // cube.getChildByName("red").transform.eulerAngles.y--; cube.getChildByName("red").transform.dirty = true; // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); - renderer.renderScene(renderData); - + renderer.renderScene(scene, camera, viewport); + var stats :RenderStats = renderer.renderData.stats; - //renderScene(renderData.viewport.containerSprite.graphics, scene); - //trace((drawArray[1] as GraphicsTrianglePath).vertices); + tf.text = "Papervision3D - version 3.0\n" + + "\ntotal objects: " + stats.totalObjects + + "\nculled objects: " + stats.culledObjects + + "\n\ntotal triangles: " + stats.totalTriangles + + "\nculled triangles: " + stats.culledTriangles + + "\nclipped triangles: " + stats.clippedTriangles; } - - } } diff --git a/src/org/papervision3d/cameras/Camera3D.as b/src/org/papervision3d/cameras/Camera3D.as index d2fc91b..45c6f4a 100755 --- a/src/org/papervision3d/cameras/Camera3D.as +++ b/src/org/papervision3d/cameras/Camera3D.as @@ -1,215 +1,215 @@ package org.papervision3d.cameras { import flash.geom.Matrix3D; import flash.geom.Rectangle; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.objects.DisplayObject3D; /** * */ public class Camera3D extends DisplayObject3D { use namespace pv3d; public var projectionMatrix :Matrix3D; public var viewMatrix :Matrix3D; public var frustum :Frustum3D; private var _dirty:Boolean; private var _fov:Number; private var _far:Number; private var _near:Number; private var _ortho:Boolean; private var _orthoScale:Number; private var _aspectRatio :Number; private var _enableCulling :Boolean; private var _worldCullingMatrix :Matrix3D; /** * Constructor. * * @param fov * @param near * @param far * @param name */ public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, name:String=null) { super(name); _fov = fov; _near = near; _far = far; _dirty = true; _ortho = false; _orthoScale = 1; _enableCulling = false; _worldCullingMatrix = new Matrix3D(); frustum = new Frustum3D(this); viewMatrix = new Matrix3D(); } /** * */ public function update(viewport:Rectangle) : void { var aspect :Number = viewport.width / viewport.height; viewMatrix.rawData = transform.worldTransform.rawData; viewMatrix.invert(); if (_aspectRatio != aspect) { _aspectRatio = aspect; _dirty = true; } if(_dirty) { _dirty = false; if(_ortho) { projectionMatrix = MatrixUtil.createOrthoMatrix(-viewport.width, viewport.width, viewport.height, -viewport.height, _far, -_far); } else { projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); } // extract the view clipping planes frustum.extractPlanes(projectionMatrix, frustum.viewClippingPlanes); } - // TODO: sniff whether our transform was dirty, no need to calc when can didn't move. + // TODO: sniff whether our transform was dirty, no need to calc when camera didn't move. if (_enableCulling) { _worldCullingMatrix.rawData = viewMatrix.rawData; _worldCullingMatrix.append(projectionMatrix); // TODO: why this is needed is weird. If we don't the culling / clipping planes don't // seem to match. With this hack all ok... // Tim: Think its got to do with a discrepancy between GL viewport and // our draw-container sitting at center stage. _worldCullingMatrix.prependScale(0.5, 0.5, 0.5); // extract the world clipping planes frustum.extractPlanes(_worldCullingMatrix, frustum.worldClippingPlanes, false); } } /** * */ public function get aspectRatio():Number { return _aspectRatio; } /** * */ public function get enableCulling():Boolean { return _enableCulling; } public function set enableCulling(value:Boolean):void { _enableCulling = value; } /** * Distance to the far clipping plane. */ public function get far():Number { return _far; } public function set far(value:Number):void { if (value != _far && value > _near) { _far = value; _dirty = true; } } /** * Field of view (vertical) in degrees. */ public function get fov():Number { return _fov; } public function set fov(value:Number):void { if (value != _fov) { _fov = value; _dirty = true; } } /** * Distance to the near clipping plane. */ public function get near():Number { return _near; } public function set near(value:Number):void { if (value != _near && value > 0 && value < _far) { _near = value; _dirty = true; } } /** * Whether to use a orthogonal projection. */ public function get ortho():Boolean { return _ortho; } public function set ortho(value:Boolean):void { if (value != _ortho) { _ortho = value; _dirty = true; } } /** * Scale of the orthogonal projection. */ public function get orthoScale():Number { return _orthoScale; } public function set orthoScale(value:Number):void { if (value != _orthoScale) { _orthoScale = value; _dirty = true; } } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/data/RenderStats.as b/src/org/papervision3d/core/render/data/RenderStats.as index b828025..23e29e5 100644 --- a/src/org/papervision3d/core/render/data/RenderStats.as +++ b/src/org/papervision3d/core/render/data/RenderStats.as @@ -1,12 +1,27 @@ package org.papervision3d.core.render.data { public class RenderStats { public var totalObjects :uint; public var culledObjects :uint; public var clippedObjects :uint; public var totalTriangles :uint; public var culledTriangles :uint; public var clippedTriangles :uint; + + public function RenderStats() + { + + } + + public function clear():void + { + totalObjects = 0; + culledObjects = 0; + clippedObjects = 0; + totalTriangles = 0; + culledTriangles = 0; + clippedTriangles = 0; + } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/engine/AbstractRenderEngine.as b/src/org/papervision3d/core/render/engine/AbstractRenderEngine.as index 63b5599..72f2dd7 100755 --- a/src/org/papervision3d/core/render/engine/AbstractRenderEngine.as +++ b/src/org/papervision3d/core/render/engine/AbstractRenderEngine.as @@ -1,23 +1,25 @@ package org.papervision3d.core.render.engine { import flash.events.EventDispatcher; import flash.events.IEventDispatcher; - import org.papervision3d.core.render.data.RenderData; + import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.render.pipeline.IRenderPipeline; + import org.papervision3d.objects.DisplayObject3D; + import org.papervision3d.view.Viewport3D; public class AbstractRenderEngine extends EventDispatcher implements IRenderEngine { public var pipeline :IRenderPipeline; public function AbstractRenderEngine(target:IEventDispatcher=null) { super(target); } - public function renderScene(renderData:RenderData):void + public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void { } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/engine/IRenderEngine.as b/src/org/papervision3d/core/render/engine/IRenderEngine.as index 1a4a6c3..bb38cd6 100755 --- a/src/org/papervision3d/core/render/engine/IRenderEngine.as +++ b/src/org/papervision3d/core/render/engine/IRenderEngine.as @@ -1,9 +1,11 @@ package org.papervision3d.core.render.engine { - import org.papervision3d.core.render.data.RenderData; + import org.papervision3d.cameras.Camera3D; + import org.papervision3d.objects.DisplayObject3D; + import org.papervision3d.view.Viewport3D; public interface IRenderEngine { - function renderScene(renderData:RenderData):void; + function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void; } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 1e1b519..65f450f 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,385 +1,399 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; + /** + * + */ public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; + public var renderData :RenderData; public var stats :RenderStats; private var _clipFlags :uint; - private var _clippedTriangles :int = 0; - private var _culledTriangles :int = 0; - private var _totalTriangles :int = 0; + private var _v0 :Vector3D; + private var _v1 :Vector3D; + private var _v2 :Vector3D; + private var _sv0 :Vector3D; + private var _sv1 :Vector3D; + private var _sv2 :Vector3D; + + /** + * + */ public function BasicRenderEngine() { super(); init(); } + /** + * + */ protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); + renderData = new RenderData(); stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; + + _v0 = new Vector3D(); + _v1 = new Vector3D(); + _v2 = new Vector3D(); + _sv0 = new Vector3D(); + _sv1 = new Vector3D(); + _sv2 = new Vector3D(); } - override public function renderScene(renderData:RenderData):void - { - var scene :DisplayObject3D = renderData.scene; - var camera :Camera3D = renderData.camera; - - renderList = renderData.drawlist; - viewport = renderData.viewport; + /** + * + */ + override public function renderScene(scene:DisplayObject3D, camera:Camera3D, viewport:Viewport3D):void + { + renderData.scene = scene; + renderData.camera = camera; + renderData.viewport = viewport; renderData.stats = stats; - camera.rotationX = camera.rotationX; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); + stats.clear(); + fillRenderList(camera, scene); + rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); + var _sv0 :Vector3D = new Vector3D(); + var _sv1 :Vector3D = new Vector3D(); + var _sv2 :Vector3D = new Vector3D(); + + stats.totalObjects++; if (object.cullingState == 0 && object.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; - _totalTriangles++; + stats.totalTriangles++; // get vertices in view / camera space v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; // setup clipflags + // first test the near plane as verts behind near project to infinity. if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); - if (flags == 7 ) { _culledTriangles++; continue; } + if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } + // passed the near test loosely, verts may have projected to infinity + // we do it here, cause - paranoia - even these array accesses may cost us + _sv0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; + _sv0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; + _sv1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; + _sv1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; + _sv2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; + _sv2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; + + // when *not* straddling the near plane we can safely test for backfaces + // ie: lets not clip backfacing triangles! + if (triangle.clipFlags != ClipFlags.NEAR) + { + // Simple backface culling. + if ((_sv2.x - _sv0.x) * (_sv1.y - _sv0.y) - (_sv2.y - _sv0.y) * (_sv1.x - _sv0.x) > 0) + { + stats.culledTriangles ++; + continue; + } + } + + // okay, continue setting up clipflags if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); - if (flags == 7 ) { _culledTriangles++; continue; } + if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); - if (flags == 7 ) { _culledTriangles++; continue; } + if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); - if (flags == 7 ) { _culledTriangles++; continue; } + if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); - if (flags == 7 ) { _culledTriangles++; continue; } + if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); - if (flags == 7 ) { _culledTriangles++; continue; } + if (flags == 7 ) { stats.culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } - + if (triangle.clipFlags == 0) { // triangle completely in view - // select screen vertex data - v0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; - v0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; - v1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; - v1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; - v2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; - v2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; - - // Simple backface culling. - if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) - { - _culledTriangles ++; - continue; - } - var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; - drawable.x0 = v0.x; - drawable.y0 = v0.y; - drawable.x1 = v1.x; - drawable.y1 = v1.y; - drawable.x2 = v2.x; - drawable.y2 = v2.y; + drawable.x0 = _sv0.x; + drawable.y0 = _sv0.y; + drawable.x1 = _sv1.x; + drawable.y1 = _sv1.y; + drawable.x2 = _sv2.x; + drawable.y2 = _sv2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { clipViewTriangle(camera, triangle, v0, v1, v2); } } } for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); - _clippedTriangles++; + stats.clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; - _totalTriangles += numTriangles - 1; + stats.totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { - _culledTriangles ++; + stats.culledTriangles ++; continue; } var drawable :TriangleDrawable = new TriangleDrawable(); drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } - - /** - * - */ - public function get clippedTriangles():int - { - return _clippedTriangles; - } - - /** - * - */ - public function get culledTriangles():int - { - return _culledTriangles; - } - - /** - * - */ - public function get totalTriangles():int - { - return _totalTriangles; - } } } \ No newline at end of file
timknip/papervision3d
e2228100b28443b050cdd63f7e9165b2bfe76904
lookat
diff --git a/src/Main.as b/src/Main.as index 5011356..1a14b3f 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,150 +1,156 @@ package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.geom.Rectangle; - import flash.geom.Vector3D; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; - import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; + import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Rectangle; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; var aspect :Number = stage.stageWidth / stage.stageHeight; container = new Sprite(); addChild(container); container.x = stage.stageWidth / 2; container.y = stage.stageHeight / 2; addChild(new Stats()); - camera = new Camera3D(50, 400, 2300, "Camera01"); + camera = new Camera3D(30, 400, 2300, "Camera01"); pipeline = new BasicPipeline(); cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 200; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; scene = new DisplayObject3D("Scene"); scene.addChild( camera ); scene.addChild( cube ); camera.z = 800; renderData = new RenderData(); renderData.camera = camera; renderData.scene = scene; renderData.drawlist = new DrawableList(); renderData.viewport = new Viewport3D(0, 0, true); renderer = new BasicRenderEngine(); + renderer.clipFlags = ClipFlags.NONE; addChild(renderData.viewport); var plane :Plane = new Plane(new WireframeMaterial(0x0000FF), 400, 400, 1, 1, "Plane0"); scene.addChild(plane); // render(); - - var clipper:SutherlandHodgmanClipper; - + camera.y = 500; + camera.lookAt(cube.getChildByName("red")); + render(); + //camera.lookAt(cube.getChildByName("red")); + render(); + render(); addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { // rotation in global frame of reference : append // cube.x ++; - // cube.rotationY--; + cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; - //cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); + // cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("green").lookAt( cube.getChildByName("red") ); - cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, 0, _s)); + cube.getChildByName("red").transform.eulerAngles.z++; + cube.getChildByName("red").transform.eulerAngles.y--; + cube.getChildByName("red").transform.dirty = true; + // cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, _s, _s)); // cube.getChildByName("red").scaleX = 2; - cube.getChildByName("red").rotationX += 3; + // cube.getChildByName("red").rotateAround(_s, new Vector3D(0, -_s, 0)); // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(renderData); //renderScene(renderData.viewport.containerSprite.graphics, scene); //trace((drawArray[1] as GraphicsTrianglePath).vertices); } } } diff --git a/src/org/papervision3d/core/math/utils/MatrixUtil.as b/src/org/papervision3d/core/math/utils/MatrixUtil.as index a09f0e2..c53b15f 100755 --- a/src/org/papervision3d/core/math/utils/MatrixUtil.as +++ b/src/org/papervision3d/core/math/utils/MatrixUtil.as @@ -1,186 +1,188 @@ package org.papervision3d.core.math.utils { import flash.geom.Matrix3D; import flash.geom.Vector3D; public class MatrixUtil { private static var _f :Vector3D = new Vector3D(); private static var _s :Vector3D = new Vector3D(); private static var _u :Vector3D = new Vector3D(); /** * */ public static function createLookAtMatrix(eye:Vector3D, target:Vector3D, up:Vector3D, resultMatrix:Matrix3D=null):Matrix3D { resultMatrix = resultMatrix || new Matrix3D(); _f.x = target.x - eye.x; _f.y = target.y - eye.y; _f.z = target.z - eye.z; _f.normalize(); + // f x up _s.x = (up.y * _f.z) - (up.z * _f.y); _s.y = (up.z * _f.x) - (up.x * _f.z); _s.z = (up.x * _f.y) - (up.y * _f.x); _s.normalize(); + // f x s _u.x = (_s.y * _f.z) - (_s.z * _f.y); _u.y = (_s.z * _f.x) - (_s.x * _f.z); _u.z = (_s.x * _f.y) - (_s.y * _f.x); _u.normalize(); resultMatrix.rawData = Vector.<Number>([ _s.x, _s.y, _s.z, 0, _u.x, _u.y, _u.z, 0, -_f.x, -_f.y, -_f.z, 0, 0, 0, 0, 1 ]); return resultMatrix; } /** * Creates a projection matrix. * * @param fovY * @param aspectRatio * @param near * @param far */ public static function createProjectionMatrix(fovy:Number, aspect:Number, zNear:Number, zFar:Number):Matrix3D { var sine :Number, cotangent :Number, deltaZ :Number; var radians :Number = (fovy / 2) * (Math.PI / 180); deltaZ = zFar - zNear; sine = Math.sin(radians); if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) { return null; } cotangent = Math.cos(radians) / sine; var v:Vector.<Number> = Vector.<Number>([ cotangent / aspect, 0, 0, 0, 0, cotangent, 0, 0, 0, 0, -(zFar + zNear) / deltaZ, -1, 0, 0, -(2 * zFar * zNear) / deltaZ, 0 ]); return new Matrix3D(v); } /** * */ public static function createOrthoMatrix(left:Number, right:Number, top:Number, bottom:Number, zNear:Number, zFar:Number) : Matrix3D { var tx :Number = (right + left) / (right - left); var ty :Number = (top + bottom) / (top - bottom); var tz :Number = (zFar+zNear) / (zFar-zNear); var v:Vector.<Number> = Vector.<Number>([ 2 / (right - left), 0, 0, 0, 0, 2 / (top - bottom), 0, 0, 0, 0, -2 / (zFar-zNear), 0, tx, ty, tz, 1 ]); return new Matrix3D(v); } public static function __gluMakeIdentityd(m : Vector.<Number>) :void { m[0+4*0] = 1; m[0+4*1] = 0; m[0+4*2] = 0; m[0+4*3] = 0; m[1+4*0] = 0; m[1+4*1] = 1; m[1+4*2] = 0; m[1+4*3] = 0; m[2+4*0] = 0; m[2+4*1] = 0; m[2+4*2] = 1; m[2+4*3] = 0; m[3+4*0] = 0; m[3+4*1] = 0; m[3+4*2] = 0; m[3+4*3] = 1; } public static function __gluMultMatricesd(a:Vector.<Number>, b:Vector.<Number>, r:Vector.<Number>):void { var i :int, j :int; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { r[int(i*4+j)] = a[int(i*4+0)]*b[int(0*4+j)] + a[int(i*4+1)]*b[int(1*4+j)] + a[int(i*4+2)]*b[int(2*4+j)] + a[int(i*4+3)]*b[int(3*4+j)]; } } } public static function __gluMultMatrixVecd(matrix : Vector.<Number>, a : Vector.<Number> , out : Vector.<Number>) : void { var i :int; for (i=0; i<4; i++) { out[i] = a[0] * matrix[int(0*4+i)] + a[1] * matrix[int(1*4+i)] + a[2] * matrix[int(2*4+i)] + a[3] * matrix[int(3*4+i)]; } } public static function __gluInvertMatrixd(src : Vector.<Number>, inverse : Vector.<Number>):Boolean { var i :int, j :int, k :int, swap :int; var t :Number; var temp :Vector.<Vector.<Number>> = new Vector.<Vector.<Number>>(4); for (i=0; i<4; i++) { temp[i] = new Vector.<Number>(4, true); for (j=0; j<4; j++) { temp[i][j] = src[i*4+j]; } } __gluMakeIdentityd(inverse); for (i = 0; i < 4; i++) { /* ** Look for largest element in column */ swap = i; for (j = i + 1; j < 4; j++) { if (Math.abs(temp[j][i]) > Math.abs(temp[i][i])) { swap = j; } } if (swap != i) { /* ** Swap rows. */ for (k = 0; k < 4; k++) { t = temp[i][k]; temp[i][k] = temp[swap][k]; temp[swap][k] = t; t = inverse[i*4+k]; inverse[i*4+k] = inverse[swap*4+k]; inverse[swap*4+k] = t; } } if (temp[i][i] == 0) { /* ** No non-zero pivot. The matrix is singular, which shouldn't ** happen. This means the user gave us a bad matrix. */ return false; } t = temp[i][i]; for (k = 0; k < 4; k++) { temp[i][k] /= t; inverse[i*4+k] /= t; } for (j = 0; j < 4; j++) { if (j != i) { t = temp[j][i]; for (k = 0; k < 4; k++) { temp[j][k] -= temp[i][k]*t; inverse[j*4+k] -= inverse[i*4+k]*t; } } } } return true; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/proto/Transform3D.as b/src/org/papervision3d/core/proto/Transform3D.as index 81b93e5..5582243 100755 --- a/src/org/papervision3d/core/proto/Transform3D.as +++ b/src/org/papervision3d/core/proto/Transform3D.as @@ -1,294 +1,355 @@ package org.papervision3d.core.proto { import flash.geom.Matrix3D; import flash.geom.Vector3D; import org.papervision3d.core.math.Quaternion; import org.papervision3d.core.math.utils.MathUtil; + import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; /** * Transform3D. * <p></p> * * @author Tim Knip / floorplanner.com */ public class Transform3D { use namespace pv3d; /** */ public static var DEFAULT_LOOKAT_UP :Vector3D = new Vector3D(0, -1, 0); /** */ public var worldTransform :Matrix3D; /** */ public var viewTransform :Matrix3D; /** */ public var screenTransform :Matrix3D; /** */ pv3d var scheduledLookAt :Transform3D; /** */ pv3d var scheduledLookAtUp :Vector3D; /** */ private var _parent :Transform3D; /** The position of the transform in world space. */ private var _position :Vector3D; /** Position of the transform relative to the parent transform. */ private var _localPosition :Vector3D; /** The rotation as Euler angles in degrees. */ private var _eulerAngles :Vector3D; /** The rotation as Euler angles in degrees relative to the parent transform's rotation. */ private var _localEulerAngles :Vector3D; /** The X axis of the transform in world space */ private var _right :Vector3D; /** The Y axis of the transform in world space */ private var _up :Vector3D; /** The Z axis of the transform in world space */ private var _forward :Vector3D; /** The rotation of the transform in world space stored as a Quaternion. */ private var _rotation :Quaternion; /** The rotation of the transform relative to the parent transform's rotation. */ private var _localRotation :Quaternion; /** */ private var _localScale :Vector3D; private var _transform :Matrix3D; private var _localTransform :Matrix3D; private var _dirty :Boolean; /** * */ public function Transform3D() { _position = new Vector3D(); _localPosition = new Vector3D(); _eulerAngles = new Vector3D(); _localEulerAngles = new Vector3D(); _right = new Vector3D(); _up = new Vector3D(); _forward = new Vector3D(); _rotation = new Quaternion(); _localRotation = new Quaternion(); _localScale = new Vector3D(1, 1, 1); _transform = new Matrix3D(); _localTransform = new Matrix3D(); this.worldTransform = new Matrix3D(); this.viewTransform = new Matrix3D(); this.screenTransform = new Matrix3D(); _dirty = true; } /** * Rotates the transform so the forward vector points at /target/'s current position. * <p>Then it rotates the transform to point its up direction vector in the direction hinted at by the * worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. * worldUp is only a hint vector. The up vector of the rotation will only match the worldUp vector if * the forward direction is perpendicular to worldUp</p> */ public function lookAt(target:Transform3D, worldUp:Vector3D=null):void { // actually, we only make note that a lookAt is scheduled. // its up to some higher level class to deal with it. scheduledLookAt = target; scheduledLookAtUp = worldUp || DEFAULT_LOOKAT_UP; + + _localEulerAngles.x = 0; + _localEulerAngles.y = 0; + _localEulerAngles.z = 0; + + var eye :Vector3D = _position; + var center :Vector3D = target.position; + + //_lookAt = MatrixUtil.createLookAtMatrix(eye, center, DEFAULT_LOOKAT_UP); + /* + var q :Quaternion = Quaternion.createFromMatrix(_lookAt); + + var euler :Vector3D = q.toEuler(); + + euler.x *= MathUtil.TO_DEGREES; + euler.y *= MathUtil.TO_DEGREES; + euler.z *= MathUtil.TO_DEGREES; + + _eulerAngles.x = -euler.y; + _eulerAngles.y = euler.x; + _eulerAngles.z = euler.z; + */ + //_dirty = true; } + private var _lookAt :Matrix3D; + /** * Applies a rotation of eulerAngles.x degrees around the x axis, eulerAngles.y degrees around * the y axis and eulerAngles.z degrees around the z axis. * * @param eulerAngles * @param relativeToSelf */ public function rotate(eulerAngles:Vector3D, relativeToSelf:Boolean=true):void { if (relativeToSelf) { _localEulerAngles.x = eulerAngles.x % 360; _localEulerAngles.y = eulerAngles.y % 360; _localEulerAngles.z = eulerAngles.z % 360; _localRotation.setFromEuler( -_localEulerAngles.y * MathUtil.TO_RADIANS, _localEulerAngles.z * MathUtil.TO_RADIANS, _localEulerAngles.x * MathUtil.TO_RADIANS ); + /* + var euler :Vector3D = _localRotation.toEuler(); + + euler.x *= MathUtil.TO_DEGREES; + euler.y *= MathUtil.TO_DEGREES; + euler.z *= MathUtil.TO_DEGREES; + + _localEulerAngles.x = -euler.y; + _localEulerAngles.y = euler.x; + _localEulerAngles.z = euler.z; + */ } else { _eulerAngles.x = eulerAngles.x % 360; _eulerAngles.y = eulerAngles.y % 360; _eulerAngles.z = eulerAngles.z % 360; _rotation.setFromEuler( -_eulerAngles.y * MathUtil.TO_RADIANS, _eulerAngles.z * MathUtil.TO_RADIANS, _eulerAngles.x * MathUtil.TO_RADIANS ); } _dirty = true; } /** * */ public function get dirty():Boolean { return _dirty; } public function set dirty(value:Boolean):void { _dirty = value; } /** * The rotation as Euler angles in degrees. */ public function get eulerAngles():Vector3D { return _eulerAngles; } public function set eulerAngles(value:Vector3D):void { _eulerAngles = value; _dirty = true; } /** * The rotation as Euler angles in degrees relative to the parent transform's rotation. */ public function get localEulerAngles():Vector3D { return _localEulerAngles; } public function set localEulerAngles(value:Vector3D):void { _localEulerAngles = value; _dirty = true; } /** * */ public function get localToWorldMatrix():Matrix3D { if (_dirty) { - rotate( _localEulerAngles, true ); + if (false) + { + _transform.rawData = _lookAt.rawData; + //_transform.prependTranslation( -_localPosition.x, -_localPosition.y, -_localPosition.z); + _transform.append(_localRotation.matrix); + + + var euler :Vector3D = Quaternion.createFromMatrix(_transform).toEuler(); + + euler.x *= MathUtil.TO_DEGREES; + euler.y *= MathUtil.TO_DEGREES; + euler.z *= MathUtil.TO_DEGREES; + + //_localEulerAngles.x = -euler.y; + //_localEulerAngles.y = euler.x; + //_localEulerAngles.z = euler.z; + + _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); + + _lookAt = null; + } + else + { + rotate( _localEulerAngles, true ); - _transform.rawData = _localRotation.matrix.rawData; - _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); - + _transform.rawData = _localRotation.matrix.rawData; + + _transform.appendTranslation( _localPosition.x, _localPosition.y, _localPosition.z); + } rotate( _eulerAngles, false ); _transform.append( _rotation.matrix ); - _transform.prependScale(_localScale.x, _localScale.y, _localScale.z); + // _transform.prependScale(_localScale.x, _localScale.y, _localScale.z); _dirty = false; } return _transform; } /** * The position of the transform in world space. */ public function get position():Vector3D { return _position; } public function set position(value:Vector3D):void { _position = value; _dirty = true; } /** * Position of the transform relative to the parent transform. */ public function get localPosition():Vector3D { return _localPosition; } public function set localPosition(value:Vector3D):void { _localPosition = value; _dirty = true; } /** * */ public function get rotation():Quaternion { return _rotation; } public function set rotation(value:Quaternion):void { _rotation = value; } /** * */ public function get localRotation():Quaternion { return _localRotation; } public function set localRotation(value:Quaternion):void { _localRotation = value; } /** * */ public function get localScale():Vector3D { return _localScale; } public function set localScale(value:Vector3D):void { _localScale = value; _dirty = true; } public function get parent():Transform3D { return _parent; } public function set parent(value:Transform3D):void { _parent = value; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/data/RenderData.as b/src/org/papervision3d/core/render/data/RenderData.as index 5b0368c..c326746 100755 --- a/src/org/papervision3d/core/render/data/RenderData.as +++ b/src/org/papervision3d/core/render/data/RenderData.as @@ -1,19 +1,21 @@ package org.papervision3d.core.render.data { import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.render.draw.list.AbstractDrawableList; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; public class RenderData { public var scene :DisplayObject3D; public var camera :Camera3D; public var viewport :Viewport3D; public var drawlist : AbstractDrawableList; + public var stats :RenderStats; public function RenderData() { + } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/data/RenderStats.as b/src/org/papervision3d/core/render/data/RenderStats.as new file mode 100644 index 0000000..b828025 --- /dev/null +++ b/src/org/papervision3d/core/render/data/RenderStats.as @@ -0,0 +1,12 @@ +package org.papervision3d.core.render.data +{ + public class RenderStats + { + public var totalObjects :uint; + public var culledObjects :uint; + public var clippedObjects :uint; + public var totalTriangles :uint; + public var culledTriangles :uint; + public var clippedTriangles :uint; + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as index 4b19ed5..6f30dbc 100755 --- a/src/org/papervision3d/core/render/pipeline/BasicPipeline.as +++ b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as @@ -1,155 +1,173 @@ package org.papervision3d.core.render.pipeline { + import __AS3__.vec.Vector; + import flash.geom.Matrix3D; import flash.geom.Rectangle; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.provider.VertexGeometry; + import org.papervision3d.core.math.utils.MathUtil; import org.papervision3d.core.math.utils.MatrixUtil; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.proto.Transform3D; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.objects.DisplayObject3D; public class BasicPipeline implements IRenderPipeline { use namespace pv3d; private var _scheduledLookAt :Vector.<DisplayObject3D>; private var _lookAtMatrix :Matrix3D; + private var _invWorldMatrix :Matrix3D; /** * */ public function BasicPipeline() { _scheduledLookAt = new Vector.<DisplayObject3D>(); _lookAtMatrix = new Matrix3D(); + _invWorldMatrix = new Matrix3D(); } /** * */ public function execute(renderData:RenderData):void { var scene :DisplayObject3D = renderData.scene; var camera :Camera3D = renderData.camera; var rect :Rectangle = renderData.viewport.sizeRectangle; _scheduledLookAt.length = 0; transformToWorld(scene); // handle lookAt if (_scheduledLookAt.length) { handleLookAt(); } camera.update(rect); transformToView(camera, scene); } /** * Processes all scheduled lookAt's. */ protected function handleLookAt():void { while (_scheduledLookAt.length) { var object :DisplayObject3D = _scheduledLookAt.pop(); + var parent :DisplayObject3D = object.parent as DisplayObject3D; var transform :Transform3D = object.transform; var eye :Vector3D = transform.position; var tgt :Vector3D = transform.scheduledLookAt.position; var up :Vector3D = transform.scheduledLookAtUp; // create the lookAt matrix MatrixUtil.createLookAtMatrix(eye, tgt, up, _lookAtMatrix); // prepend it to the world matrix object.transform.worldTransform.prepend(_lookAtMatrix); + if (parent) + { + _invWorldMatrix.rawData = parent.transform.worldTransform.rawData; + _invWorldMatrix.invert(); + object.transform.worldTransform.append(_invWorldMatrix); + } + + var components :Vector.<Vector3D> = object.transform.worldTransform.decompose(); + var euler :Vector3D = components[1]; + + object.transform.localEulerAngles.x = -euler.x * MathUtil.TO_DEGREES; + object.transform.localEulerAngles.y = euler.y * MathUtil.TO_DEGREES; + object.transform.localEulerAngles.z = euler.z * MathUtil.TO_DEGREES; + // clear object.transform.scheduledLookAt = null; } } /** * */ - protected function transformToWorld(object:DisplayObject3D, parent:DisplayObject3D=null):void + protected function transformToWorld(object:DisplayObject3D, parent:DisplayObject3D=null, processLookAt:Boolean=false):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; - if (object.transform.scheduledLookAt) + if (!processLookAt && object.transform.scheduledLookAt) { _scheduledLookAt.push( object ); } - + wt.rawData = object.transform.localToWorldMatrix.rawData; - if (parent) { wt.append(parent.transform.worldTransform); } - object.transform.position = wt.transformVector(object.transform.localPosition); - + for each (child in object._children) { - transformToWorld(child, object); + transformToWorld(child, object, processLookAt); } } /** * */ protected function transformToView(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var wt :Matrix3D = object.transform.worldTransform; var vt :Matrix3D = object.transform.viewTransform; vt.rawData = wt.rawData; vt.append(camera.viewMatrix); if (object.geometry is VertexGeometry) { projectVertices(camera, object); } for each (child in object._children) { transformToView(camera, child); } } /** * */ protected function projectVertices(camera:Camera3D, object:DisplayObject3D):void { var vt :Matrix3D = object.transform.viewTransform; var st :Matrix3D = object.transform.screenTransform; // move the vertices into view / camera space // we'll need the vertices in this space to check whether vertices are behind the camera. // if we move to screen space in one go, screen vertices could move to infinity. vt.transformVectors(object.geometry.vertexData, object.geometry.viewVertexData); // append the projection matrix to the object's view matrix st.rawData = vt.rawData; st.append(camera.projectionMatrix); // move the vertices to screen space. // AKA: the perspective divide // NOTE: some vertices may have moved to infinity, we need to check while processing triangles. // IF so we need to check whether we need to clip the triangles or disgard them. Utils3D.projectVectors(st, object.geometry.vertexData, object.geometry.screenVertexData, object.geometry.uvtData); } } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index f4717b3..1e1b519 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,381 +1,385 @@ package org.papervision3d.render { import flash.errors.IllegalOperationError; import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; + import org.papervision3d.core.render.data.RenderStats; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; - import org.papervision3d.materials.AbstractMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; public var geometry :TriangleGeometry; + public var stats :RenderStats; private var _clipFlags :uint; private var _clippedTriangles :int = 0; private var _culledTriangles :int = 0; private var _totalTriangles :int = 0; public function BasicRenderEngine() { super(); init(); } protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); + stats = new RenderStats(); _clipFlags = ClipFlags.NEAR; } override public function renderScene(renderData:RenderData):void { var scene :DisplayObject3D = renderData.scene; var camera :Camera3D = renderData.camera; + renderList = renderData.drawlist; - this.viewport = renderData.viewport; + viewport = renderData.viewport; + renderData.stats = stats; camera.rotationX = camera.rotationX; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** * Fills our renderlist. * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); if (object.cullingState == 0 && object.geometry is TriangleGeometry) { var triangle :Triangle; var inside :Boolean; var flags :int = 0; geometry = object.geometry as TriangleGeometry; for each (triangle in geometry.triangles) { triangle.clipFlags = 0; triangle.visible = false; _totalTriangles++; // get vertices in view / camera space v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; // setup clipflags if (_clipFlags & ClipFlags.NEAR) { flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); if (flags == 7 ) { _culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } if (_clipFlags & ClipFlags.FAR) { flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); if (flags == 7 ) { _culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } if (_clipFlags & ClipFlags.LEFT) { flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); if (flags == 7 ) { _culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } } if (_clipFlags & ClipFlags.RIGHT) { flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); if (flags == 7 ) { _culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } if (_clipFlags & ClipFlags.TOP) { flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); if (flags == 7 ) { _culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } if (_clipFlags & ClipFlags.BOTTOM) { flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); if (flags == 7 ) { _culledTriangles++; continue; } else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; } if (triangle.clipFlags == 0) { // triangle completely in view // select screen vertex data v0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; v0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; v1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; v1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; v2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; v2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; // Simple backface culling. if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { _culledTriangles ++; continue; } var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); drawable.screenZ = (v0.z + v1.z + v2.z) / 3; drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.material = triangle.material; renderList.addDrawable(drawable); triangle.drawable = drawable; } else { clipViewTriangle(camera, triangle, v0, v1, v2); } } } for each (child in object._children) { fillRenderList(camera, child); } } /** * Clips a triangle in view / camera space. Typically used for the near and far planes. * * @param camera * @param triangle * @param v0 * @param v1 * @param v2 */ private function clipViewTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D):void { var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); _clippedTriangles++; if (triangle.clipFlags & ClipFlags.NEAR) { clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.FAR) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.LEFT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.RIGHT) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.TOP) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } if (triangle.clipFlags & ClipFlags.BOTTOM) { plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); var i:int, i2 :int, i3 :int; _totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; v0.x = outV[0]; v0.y = outV[1]; v1.x = outV[i2+2]; v1.y = outV[i2+3]; v2.x = outV[i2+4]; v2.y = outV[i2+5]; if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { _culledTriangles ++; continue; } var drawable :TriangleDrawable = new TriangleDrawable(); drawable.x0 = v0.x; drawable.y0 = v0.y; drawable.x1 = v1.x; drawable.y1 = v1.y; drawable.x2 = v2.x; drawable.y2 = v2.y; drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; drawable.material = triangle.material; renderList.addDrawable(drawable); } } /** * */ private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int { var flags :int = 0; if ( plane.distance(v0) < 0 ) flags |= 1; if ( plane.distance(v1) < 0 ) flags |= 2; if ( plane.distance(v2) < 0 ) flags |= 4; return flags; } /** * Clip flags. * * @see org.papervision3d.core.render.clipping.ClipFlags */ public function get clipFlags():int { return _clipFlags; } public function set clipFlags(value:int):void { if (value >= 0 && value <= ClipFlags.ALL) { _clipFlags = value; } else { throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); } } /** * */ public function get clippedTriangles():int { return _clippedTriangles; } /** * */ public function get culledTriangles():int { return _culledTriangles; } /** * */ public function get totalTriangles():int { return _totalTriangles; } } } \ No newline at end of file
timknip/papervision3d
6aa07f4ff084bd4a41471dded72afa606fd603e2
branching
diff --git a/src/Main.as b/src/Main.as index fcc463e..78b296c 100644 --- a/src/Main.as +++ b/src/Main.as @@ -1,155 +1,153 @@ package { - import __AS3__.vec.Vector; - import flash.display.Graphics; import flash.display.GraphicsTrianglePath; import flash.display.IGraphicsData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.geom.Rectangle; import flash.geom.Vector3D; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Rectangle; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; var aspect :Number = stage.stageWidth / stage.stageHeight; container = new Sprite(); addChild(container); container.x = stage.stageWidth / 2; container.y = stage.stageHeight / 2; addChild(new Stats()); camera = new Camera3D(20, 400, 2300, "Camera01"); pipeline = new BasicPipeline(); cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 200; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; scene = new DisplayObject3D("Scene"); scene.addChild( camera ); scene.addChild( cube ); camera.z = 800; renderData = new RenderData(); renderData.camera = camera; renderData.scene = scene; renderData.drawlist = new DrawableList(); renderData.viewport = new Viewport3D(0, 0, true); renderer = new BasicRenderEngine(); addChild(renderData.viewport); // render(); var clipper:SutherlandHodgmanClipper; addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { // rotation in global frame of reference : append // cube.x ++; // cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; //cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("green").lookAt( cube.getChildByName("red") ); cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, 0, _s)); // cube.getChildByName("red").scaleX = 2; cube.getChildByName("red").rotationX += 3; // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(renderData); //renderScene(renderData.viewport.containerSprite.graphics, scene); //trace((drawArray[1] as GraphicsTrianglePath).vertices); } } }
timknip/papervision3d
0164784fede4585dc1a8651c8db1442b5a38838f
all code is back
diff --git a/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as b/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as index 17a235c..3e65ff2 100755 --- a/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as +++ b/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as @@ -1,346 +1,349 @@ package org.papervision3d.core.proto { - import flash.geom.Matrix3D; import flash.geom.Vector3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.objects.DisplayObject3D; public class DisplayObjectContainer3D { use namespace pv3d; /** */ public var name :String; /** */ public var parent :DisplayObjectContainer3D; /** */ public var transform :Transform3D; + /** */ + public var cullingState :int; + /** */ pv3d var _children :Vector.<DisplayObject3D>; /** */ private static var _newID :int = 0; /** * */ public function DisplayObjectContainer3D(name:String=null) { this.name = name || "Object" + (_newID++); this.transform = new Transform3D(); + this.cullingState = 0; _children = new Vector.<DisplayObject3D>(); } /** * */ public function addChild(child:DisplayObject3D):DisplayObject3D { var root :DisplayObjectContainer3D = this; while( root.parent ) root = root.parent; if (root.findChild(child, true) ) { throw new Error("This child was already added to the scene!"); } child.parent = this; child.transform.parent = this.transform; _children.push(child); return child; } /** * Find a child. * * @param child The child to find. * @param deep Whether to search recursivelly * * @return The found child or null on failure. */ public function findChild(child:DisplayObject3D, deep:Boolean=true):DisplayObject3D { var index :int = _children.indexOf(child); if (index < 0) { if (deep) { var object :DisplayObject3D; for each (object in _children) { var c :DisplayObject3D = object.findChild(child, true); if (c) return c; } } } else { return _children[index]; } return null; } /** * */ public function getChildAt(index:uint):DisplayObject3D { if (index < _children.length) { return _children[index]; } else { return null; } } /** * Gets a child by name. * * @param name Name of the DisplayObject3D to find. * @param deep Whether to perform a recursive search * * @return The found DisplayObject3D or null on failure. */ public function getChildByName(name:String, deep:Boolean=false):DisplayObject3D { var child :DisplayObject3D; for each (child in _children) { if (child.name == name) { return child; } if (deep) { var c :DisplayObject3D = child.getChildByName(name, true); if (c) return c; } } return null; } /** * */ public function lookAt(object:DisplayObject3D, up:Vector3D=null):void { transform.lookAt(object.transform, up); } /** * Removes a child. * * @param child The child to remove. * @param deep Whether to perform a recursive search. * * @return The removed child or null on failure. */ public function removeChild(child:DisplayObject3D, deep:Boolean=false):DisplayObject3D { var index :int = _children.indexOf(child); if (index < 0) { if (deep) { var object :DisplayObject3D; for each (object in _children) { var c :DisplayObject3D = object.removeChild(object, true); if (c) { c.parent = null; return c; } } } return null; } else { child = _children.splice(index, 1)[0]; child.parent = null; return child; } } /** * */ public function removeChildAt(index:int):DisplayObject3D { if (index < _children.length) { return _children.splice(index, 1)[0]; } else { return null; } } /** * */ public function rotateAround(degrees:Number, axis:Vector3D, pivot:*=null):void { pivot = pivot || this.parent; var pivotPoint :Vector3D; if (pivot === this.parent) { pivotPoint = this.parent.transform.localPosition; } else if (pivot is Vector3D) { pivotPoint = pivot as Vector3D; } if (pivotPoint) { transform.rotate(axis, false); } } /** * */ public function get x():Number { return transform.localPosition.x; } public function set x(value:Number):void { transform.localPosition.x = value; transform.dirty = true; } /** * */ public function get y():Number { return transform.localPosition.y; } public function set y(value:Number):void { transform.localPosition.y = value; transform.dirty = true; } /** * */ public function get z():Number { return transform.localPosition.z; } public function set z(value:Number):void { transform.localPosition.z = value; transform.dirty = true; } /** * */ public function get rotationX():Number { return transform.localEulerAngles.x; } public function set rotationX(value:Number):void { transform.localEulerAngles.x = value; transform.dirty = true; } /** * */ public function get rotationY():Number { return transform.localEulerAngles.y; } public function set rotationY(value:Number):void { transform.localEulerAngles.y = value transform.dirty = true; } /** * */ public function get rotationZ():Number { return transform.localEulerAngles.z; } public function set rotationZ(value:Number):void { transform.localEulerAngles.z = value; transform.dirty = true; } /** * */ public function get scaleX():Number { return transform.localScale.x; } public function set scaleX(value:Number):void { transform.localScale.x = value; transform.dirty = true; } /** * */ public function get scaleY():Number { return transform.localScale.y; } public function set scaleY(value:Number):void { transform.localScale.y = value; transform.dirty = true; } /** * */ public function get scaleZ():Number { return transform.localScale.z; } public function set scaleZ(value:Number):void { transform.localScale.z = value; transform.dirty = true; } } } \ No newline at end of file diff --git a/src/org/papervision3d/core/render/clipping/ClipFlags.as b/src/org/papervision3d/core/render/clipping/ClipFlags.as index 26bae9d..7cb6723 100755 --- a/src/org/papervision3d/core/render/clipping/ClipFlags.as +++ b/src/org/papervision3d/core/render/clipping/ClipFlags.as @@ -1,12 +1,14 @@ package org.papervision3d.core.render.clipping { public class ClipFlags { + public static const NONE :int = 0; public static const NEAR :int = 1; public static const FAR :int = 2; public static const LEFT :int = 4; public static const RIGHT :int = 8; public static const TOP :int = 16; public static const BOTTOM :int = 32; + public static const ALL :int = 1+2+4+8+16+32; } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/DisplayObject3D.as b/src/org/papervision3d/objects/DisplayObject3D.as index fb6273f..3ee2852 100755 --- a/src/org/papervision3d/objects/DisplayObject3D.as +++ b/src/org/papervision3d/objects/DisplayObject3D.as @@ -1,33 +1,44 @@ package org.papervision3d.objects { import __AS3__.vec.Vector; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.proto.DisplayObjectContainer3D; import org.papervision3d.materials.AbstractMaterial; /** * */ public class DisplayObject3D extends DisplayObjectContainer3D { /** * */ public var material:AbstractMaterial; + + /** + * + */ public var geometry:VertexGeometry; - + + /** + * + */ public var viewVertexData :Vector.<Number>; + + /** + * + */ public var screenVertexData :Vector.<Number>; /** * */ public function DisplayObject3D(name:String=null) { super(name); viewVertexData = new Vector.<Number>(); screenVertexData = new Vector.<Number>(); } } } \ No newline at end of file diff --git a/src/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as index 40b8b57..fa0a577 100755 --- a/src/org/papervision3d/render/BasicRenderEngine.as +++ b/src/org/papervision3d/render/BasicRenderEngine.as @@ -1,279 +1,381 @@ package org.papervision3d.render { - import __AS3__.vec.Vector; - + import flash.errors.IllegalOperationError; + import flash.geom.Utils3D; import flash.geom.Vector3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; + import org.papervision3d.core.math.Frustum3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.ClipFlags; import org.papervision3d.core.render.clipping.IPolygonClipper; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.draw.list.IDrawableList; import org.papervision3d.core.render.engine.AbstractRenderEngine; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.core.render.raster.DefaultRasterizer; import org.papervision3d.core.render.raster.IRasterizer; import org.papervision3d.materials.AbstractMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.Viewport3D; public class BasicRenderEngine extends AbstractRenderEngine { use namespace pv3d; public var renderList :IDrawableList; public var clipper :IPolygonClipper; public var viewport :Viewport3D; public var rasterizer : IRasterizer; + public var geometry :TriangleGeometry; + + private var _clipFlags :uint; + private var _clippedTriangles :int = 0; + private var _culledTriangles :int = 0; + private var _totalTriangles :int = 0; public function BasicRenderEngine() { super(); init(); } protected function init():void { pipeline = new BasicPipeline(); renderList = new DrawableList(); clipper = new SutherlandHodgmanClipper(); rasterizer = new DefaultRasterizer(); + + _clipFlags = ClipFlags.NEAR; } override public function renderScene(renderData:RenderData):void { var scene :DisplayObject3D = renderData.scene; var camera :Camera3D = renderData.camera; renderList = renderData.drawlist; this.viewport = renderData.viewport; camera.rotationX = camera.rotationX; camera.update(renderData.viewport.sizeRectangle); pipeline.execute(renderData); renderList.clear(); - test(camera, scene); + fillRenderList(camera, scene); rasterizer.rasterize(renderList, renderData.viewport); } /** - * Get rid of triangles behind the near plane, clip straddling triangles if needed. + * Fills our renderlist. + * <p>Get rid of triangles behind the near plane, clip straddling triangles if needed.</p> * * @param camera * @param object */ - private function test(camera:Camera3D, object:DisplayObject3D):void + private function fillRenderList(camera:Camera3D, object:DisplayObject3D):void { var child :DisplayObject3D; + var clipPlanes :Vector.<Plane3D> = camera.frustum.viewClippingPlanes; var v0 :Vector3D = new Vector3D(); var v1 :Vector3D = new Vector3D(); var v2 :Vector3D = new Vector3D(); - if (object.geometry is TriangleGeometry) + if (object.cullingState == 0 && object.geometry is TriangleGeometry) { - var geom :TriangleGeometry = object.geometry as TriangleGeometry; var triangle :Triangle; var inside :Boolean; var flags :int = 0; - for each (triangle in geom.triangles) + geometry = object.geometry as TriangleGeometry; + + for each (triangle in geometry.triangles) { - //trace("got a triangle"); triangle.clipFlags = 0; triangle.visible = false; + _totalTriangles++; + // get vertices in view / camera space - v0.x = geom.viewVertexData[ triangle.v0.vectorIndexX ]; - v0.y = geom.viewVertexData[ triangle.v0.vectorIndexY ]; - v0.z = geom.viewVertexData[ triangle.v0.vectorIndexZ ]; - v1.x = geom.viewVertexData[ triangle.v1.vectorIndexX ]; - v1.y = geom.viewVertexData[ triangle.v1.vectorIndexY ]; - v1.z = geom.viewVertexData[ triangle.v1.vectorIndexZ ]; - v2.x = geom.viewVertexData[ triangle.v2.vectorIndexX ]; - v2.y = geom.viewVertexData[ triangle.v2.vectorIndexY ]; - v2.z = geom.viewVertexData[ triangle.v2.vectorIndexZ ]; + v0.x = geometry.viewVertexData[ triangle.v0.vectorIndexX ]; + v0.y = geometry.viewVertexData[ triangle.v0.vectorIndexY ]; + v0.z = geometry.viewVertexData[ triangle.v0.vectorIndexZ ]; + v1.x = geometry.viewVertexData[ triangle.v1.vectorIndexX ]; + v1.y = geometry.viewVertexData[ triangle.v1.vectorIndexY ]; + v1.z = geometry.viewVertexData[ triangle.v1.vectorIndexZ ]; + v2.x = geometry.viewVertexData[ triangle.v2.vectorIndexX ]; + v2.y = geometry.viewVertexData[ triangle.v2.vectorIndexY ]; + v2.z = geometry.viewVertexData[ triangle.v2.vectorIndexZ ]; - flags = 0; - if (v0.z >= -camera.near) flags |= 1; - if (v1.z >= -camera.near) flags |= 2; - if (v2.z >= -camera.near) flags |= 4; - - if (flags == 7 ) + // setup clipflags + if (_clipFlags & ClipFlags.NEAR) { - // behind near plane - continue; + flags = getClipFlags(clipPlanes[Frustum3D.NEAR], v0, v1, v2); + if (flags == 7 ) { _culledTriangles++; continue; } + else if (flags) { triangle.clipFlags |= ClipFlags.NEAR; } } - else if (flags) + + if (_clipFlags & ClipFlags.FAR) { - // clip candidate - triangle.clipFlags |= ClipFlags.NEAR; + flags = getClipFlags(clipPlanes[Frustum3D.FAR], v0, v1, v2); + if (flags == 7 ) { _culledTriangles++; continue; } + else if (flags) { triangle.clipFlags |= ClipFlags.FAR; } } - flags = 0; - if (v0.z <= -camera.far) flags |= 1; - if (v1.z <= -camera.far) flags |= 2; - if (v2.z <= -camera.far) flags |= 4; + if (_clipFlags & ClipFlags.LEFT) + { + flags = getClipFlags(clipPlanes[Frustum3D.LEFT], v0, v1, v2); + if (flags == 7 ) { _culledTriangles++; continue; } + else if (flags) { triangle.clipFlags |= ClipFlags.LEFT; } + } - if (flags == 7 ) + if (_clipFlags & ClipFlags.RIGHT) { - // behind far plane - continue; + flags = getClipFlags(clipPlanes[Frustum3D.RIGHT], v0, v1, v2); + if (flags == 7 ) { _culledTriangles++; continue; } + else if (flags) { triangle.clipFlags |= ClipFlags.RIGHT; } } - else if (flags) + + if (_clipFlags & ClipFlags.TOP) { - // clip candidate - triangle.clipFlags |= ClipFlags.FAR; + flags = getClipFlags(clipPlanes[Frustum3D.TOP], v0, v1, v2); + if (flags == 7 ) { _culledTriangles++; continue; } + else if (flags) { triangle.clipFlags |= ClipFlags.TOP; } } - triangle.visible = (triangle.clipFlags == 0); + if (_clipFlags & ClipFlags.BOTTOM) + { + flags = getClipFlags(clipPlanes[Frustum3D.BOTTOM], v0, v1, v2); + if (flags == 7 ) { _culledTriangles++; continue; } + else if (flags) { triangle.clipFlags |= ClipFlags.BOTTOM }; + } - if (triangle.visible) - { + if (triangle.clipFlags == 0) + { + // triangle completely in view // select screen vertex data - v0.x = geom.screenVertexData[ triangle.v0.screenIndexX ]; - v0.y = geom.screenVertexData[ triangle.v0.screenIndexY ]; - v1.x = geom.screenVertexData[ triangle.v1.screenIndexX ]; - v1.y = geom.screenVertexData[ triangle.v1.screenIndexY ]; - v2.x = geom.screenVertexData[ triangle.v2.screenIndexX ]; - v2.y = geom.screenVertexData[ triangle.v2.screenIndexY ]; - - var left :int = 0; - var right :int = 0; - var top :int = 0; - var bottom :int = 0; + v0.x = geometry.screenVertexData[ triangle.v0.screenIndexX ]; + v0.y = geometry.screenVertexData[ triangle.v0.screenIndexY ]; + v1.x = geometry.screenVertexData[ triangle.v1.screenIndexX ]; + v1.y = geometry.screenVertexData[ triangle.v1.screenIndexY ]; + v2.x = geometry.screenVertexData[ triangle.v2.screenIndexX ]; + v2.y = geometry.screenVertexData[ triangle.v2.screenIndexY ]; - if (v0.x < -1) left++; - if (v1.x < -1) left++; - if (v2.x < -1) left++; - if (v0.x > 1) right++; - if (v1.x > 1) right++; - if (v2.x > 1) right++; - if (v0.y > 1) top++; - if (v1.y > 1) top++; - if (v2.y > 1) top++; - if (v0.y < -1) bottom++; - if (v1.y < -1) bottom++; - if (v2.y < -1) bottom++; - - if (left == 0 && right == 0 && top == 0 && bottom == 0) + // Simple backface culling. + if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) { - var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); - drawable.screenZ = (v0.z + v1.z + v2.z) / 3; - drawable.x0 = v0.x; - drawable.y0 = v0.y; - drawable.x1 = v1.x; - drawable.y1 = v1.y; - drawable.x2 = v2.x; - drawable.y2 = v2.y; - drawable.material = object.material; - - renderList.addDrawable(drawable); - } - else if (left == 3 || right == 3 || top == 3 || bottom == 3) - { - triangle.visible = false; - } - else - { - if (left > 0) flags |= ClipFlags.LEFT; - if (right > 0) flags |= ClipFlags.RIGHT; - if (top > 0) flags |= ClipFlags.TOP; - if (bottom > 0) flags |= ClipFlags.BOTTOM; - - //f( right > 0) - clipTriangle(camera, triangle, v0, v1, v2, flags, object.material); + _culledTriangles ++; + continue; } + + var drawable :TriangleDrawable = triangle.drawable as TriangleDrawable || new TriangleDrawable(); + drawable.screenZ = (v0.z + v1.z + v2.z) / 3; + drawable.x0 = v0.x; + drawable.y0 = v0.y; + drawable.x1 = v1.x; + drawable.y1 = v1.y; + drawable.x2 = v2.x; + drawable.y2 = v2.y; + drawable.material = object.material; + + renderList.addDrawable(drawable); + + triangle.drawable = drawable; } + else + { + clipViewTriangle(camera, triangle, object.material, v0, v1, v2); + } } } for each (child in object._children) { - test(camera, child); + fillRenderList(camera, child); } } - private function clipTriangle(camera:Camera3D, triangle:Triangle, v0:Vector3D, v1:Vector3D, v2:Vector3D, clipFlags:int, material:AbstractMaterial):void - { - var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, 0, v1.x, v1.y, 0, v2.x, v2.y, 0]); + /** + * Clips a triangle in view / camera space. Typically used for the near and far planes. + * + * @param camera + * @param triangle + * @param v0 + * @param v1 + * @param v2 + */ + private function clipViewTriangle(camera:Camera3D, triangle:Triangle, material:AbstractMaterial, v0:Vector3D, v1:Vector3D, v2:Vector3D):void + { + var plane :Plane3D = camera.frustum.viewClippingPlanes[ Frustum3D.NEAR ]; + var inV :Vector.<Number> = Vector.<Number>([v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z]); var inUVT :Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0]); var outV :Vector.<Number> = new Vector.<Number>(); var outUVT :Vector.<Number> = new Vector.<Number>(); - var svd :Vector.<Number> = new Vector.<Number>(); - var plane :Plane3D = Plane3D.fromCoefficients(1, 0, 0, -1); - - if (clipFlags & ClipFlags.LEFT) + _clippedTriangles++; + + if (triangle.clipFlags & ClipFlags.NEAR) { - plane.setCoefficients(-1, 0, 0, 1); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } - - if (clipFlags & ClipFlags.RIGHT) + + if (triangle.clipFlags & ClipFlags.FAR) { + plane = camera.frustum.viewClippingPlanes[ Frustum3D.FAR ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); - plane.setCoefficients(1, 0, 0, 1); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } - - if (clipFlags & ClipFlags.TOP) + + if (triangle.clipFlags & ClipFlags.LEFT) { + plane = camera.frustum.viewClippingPlanes[ Frustum3D.LEFT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); - plane.setCoefficients(0, -1, 0, 1); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } - if (clipFlags & ClipFlags.BOTTOM) + if (triangle.clipFlags & ClipFlags.RIGHT) { + plane = camera.frustum.viewClippingPlanes[ Frustum3D.RIGHT ]; outV = new Vector.<Number>(); outUVT = new Vector.<Number>(); - plane.setCoefficients(0, 1, 0, 1); clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); inV = outV; inUVT = outUVT; } - svd = inV; + if (triangle.clipFlags & ClipFlags.TOP) + { + plane = camera.frustum.viewClippingPlanes[ Frustum3D.TOP ]; + outV = new Vector.<Number>(); + outUVT = new Vector.<Number>(); + clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); + inV = outV; + inUVT = outUVT; + } + + if (triangle.clipFlags & ClipFlags.BOTTOM) + { + plane = camera.frustum.viewClippingPlanes[ Frustum3D.BOTTOM ]; + outV = new Vector.<Number>(); + outUVT = new Vector.<Number>(); + clipper.clipPolygonToPlane(inV, inUVT, outV, outUVT, plane); + inV = outV; + inUVT = outUVT; + } + + Utils3D.projectVectors(camera.projectionMatrix, inV, outV, inUVT); var numTriangles : int = 1 + ((inV.length / 3)-3); - var i :int, i2 :int, i3 :int; + var i:int, i2 :int, i3 :int; + + _totalTriangles += numTriangles - 1; for(i = 0; i < numTriangles; i++) { i2 = i * 2; i3 = i * 3; + v0.x = outV[0]; + v0.y = outV[1]; + v1.x = outV[i2+2]; + v1.y = outV[i2+3]; + v2.x = outV[i2+4]; + v2.y = outV[i2+5]; + + if ((v2.x - v0.x) * (v1.y - v0.y) - (v2.y - v0.y) * (v1.x - v0.x) > 0) + { + _culledTriangles ++; + continue; + } + var drawable :TriangleDrawable = new TriangleDrawable(); - drawable.x0 = svd[0]; - drawable.y0 = svd[1]; + drawable.x0 = v0.x; + drawable.y0 = v0.y; - drawable.x1 = svd[i3+3]; - drawable.y1 = svd[i3+4]; + drawable.x1 = v1.x; + drawable.y1 = v1.y; - drawable.x2 = svd[i3+6]; - drawable.y2 = svd[i3+7]; - drawable.material = material; - drawable.screenZ = (v0.z + v1.z + v2.z) / 3; + drawable.x2 = v2.x; + drawable.y2 = v2.y; + drawable.screenZ = (inV[2]+inV[i3+5]+inV[i3+8])/3; + drawable.material = material; renderList.addDrawable(drawable); } } + + /** + * + */ + private function getClipFlags(plane:Plane3D, v0:Vector3D, v1:Vector3D, v2:Vector3D):int + { + var flags :int = 0; + if ( plane.distance(v0) < 0 ) flags |= 1; + if ( plane.distance(v1) < 0 ) flags |= 2; + if ( plane.distance(v2) < 0 ) flags |= 4; + return flags; + } + + /** + * Clip flags. + * + * @see org.papervision3d.core.render.clipping.ClipFlags + */ + public function get clipFlags():int + { + return _clipFlags; + } + + public function set clipFlags(value:int):void + { + if (value >= 0 && value <= ClipFlags.ALL) + { + _clipFlags = value; + } + else + { + throw new IllegalOperationError("clipFlags should be a value between 0 and " + ClipFlags.ALL + "\nsee org.papervision3d.core.render.clipping.ClipFlags"); + } + } + + /** + * + */ + public function get clippedTriangles():int + { + return _clippedTriangles; + } + + /** + * + */ + public function get culledTriangles():int + { + return _culledTriangles; + } + + /** + * + */ + public function get totalTriangles():int + { + return _totalTriangles; + } } } \ No newline at end of file
timknip/papervision3d
92857925ac00cebbd7764f16347a90ceaa824e51
ascollada
diff --git a/src/org/ascollada/core/DaeAccessor.as b/src/org/ascollada/core/DaeAccessor.as new file mode 100644 index 0000000..3d161a2 --- /dev/null +++ b/src/org/ascollada/core/DaeAccessor.as @@ -0,0 +1,55 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeAccessor extends DaeElement { + use namespace collada; + + public var params :Vector.<DaeParam>; + public var count :int; + public var stride :int; + public var offset :int; + + /** + * + */ + public function DaeAccessor(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + if(params) { + while(params.length) { + var param : DaeParam = params.pop(); + param.destroy(); + } + params = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.count = parseInt([email protected](), 10); + this.stride = [email protected]() ? parseInt([email protected](), 10) : 1; + this.offset = [email protected]() ? parseInt([email protected](), 10) : 0; + this.params = new Vector.<DaeParam>(); + + var list :XMLList = element["param"]; + var i :int; + + for(i = 0; i < list.length(); i++) { + this.params.push(new DaeParam(this.document, list[i])); + } + } + } +} diff --git a/src/org/ascollada/core/DaeAnimation.as b/src/org/ascollada/core/DaeAnimation.as new file mode 100644 index 0000000..035afb5 --- /dev/null +++ b/src/org/ascollada/core/DaeAnimation.as @@ -0,0 +1,104 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeAnimation extends DaeElement { + use namespace collada; + + /** + * + */ + public var animations : Array; + + /** + * + */ + public var channels : Array; + + /** */ + public var clips : Array; + + /** + * + */ + private static var _newID : int = 0; + + /** + * + */ + public function DaeAnimation(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.animations) { + for each(var animation:DaeAnimation in this.animations) { + animation.destroy(); + } + this.animations = null; + } + + if(this.channels) { + for each(var channel:DaeChannel in this.channels) { + channel.destroy(); + } + this.channels = null; + } + + this.clips = null; + } + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.id = (this.id && this.id.length) ? this.id : "animation" + (_newID++); + this.name = (this.name && this.name.length) ? this.name : this.id; + this.animations = new Array(); + this.channels = new Array(); + + var samplers : Object = new Object(); + var sampler : DaeSampler; + var list : XMLList = element.children(); + var num : int = list.length(); + var child : XML; + var i : int; + + for(i = 0; i < num; i++) { + child = list[i]; + + switch(child.localName() as String) { + case "animation": + this.animations.push(new DaeAnimation(this.document, child)); + break; + case "sampler": + sampler = new DaeSampler(this.document, child); + samplers[sampler.id] = sampler; + break; + case "channel": + this.channels.push(new DaeChannel(this.document, this, child)); + break; + default: + break; + } + } + + for(i = 0; i < this.channels.length; i++) { + var channel : DaeChannel = this.channels[i]; + if(samplers[channel.source] is DaeSampler) { + channel.sampler = samplers[channel.source]; + } else { + throw new Error("[DaeAnimation] no sampler!"); + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeAnimationClip.as b/src/org/ascollada/core/DaeAnimationClip.as new file mode 100644 index 0000000..054c42c --- /dev/null +++ b/src/org/ascollada/core/DaeAnimationClip.as @@ -0,0 +1,3 @@ +package org.ascollada.core { import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; /** * @author Tim Knip / floorplanner.com */ public class DaeAnimationClip extends DaeElement { use namespace collada; /** */ public var start : Number; /** */ public var end : Number; /** */ public var instances : Array; /** */ private var _instanceUrls : Object; /** * */ private static var _newID : int = 0; /** * */ public function DaeAnimationClip(document : DaeDocument, element : XML = null) { super(document, element); } /** * */ override public function destroy() : void { super.destroy(); this.instances = null; } /** * */ override public function read(element : XML) : void { super.read(element); this.id = (this.id && this.id.length) ? this.id : "animation_clip" + (_newID++); this.name = (this.name && this.name.length) ? this.name : this.id; this.start = parseFloat(readAttribute(element, "start")); this.end = parseFloat(readAttribute(element, "end")); this.instances = new Array(); _instanceUrls = new Object(); var animation : DaeAnimation; var list : XMLList = element["instance_animation"]; var child : XML; var num : int = list.length(); var i : int; for(i = 0; i < num; i++) { child = list[i]; var url : String = readAttribute(child, "url"); if(url.charAt(0) == "#") { url = url.substr(1); } this.instances.push(url); _instanceUrls[url] = i; animation = this.document.animations[url]; if(animation) { animation.clips = animation.clips || new Array(); if(animation.clips.indexOf(this) == -1) { animation.clips.push(this); } } } } + } } \ No newline at end of file diff --git a/src/org/ascollada/core/DaeBlendWeight.as b/src/org/ascollada/core/DaeBlendWeight.as new file mode 100644 index 0000000..87cdf74 --- /dev/null +++ b/src/org/ascollada/core/DaeBlendWeight.as @@ -0,0 +1,14 @@ +package org.ascollada.core { + + public class DaeBlendWeight { + public var vertexIndex :int; + public var joint :String; + public var weight :Number; + + public function DaeBlendWeight(vertex:int=-1, joint:String=null, weight:Number=0.0) { + this.vertexIndex = vertex; + this.joint = joint; + this.weight = weight; + } + } +} diff --git a/src/org/ascollada/core/DaeChannel.as b/src/org/ascollada/core/DaeChannel.as new file mode 100644 index 0000000..9d109cf --- /dev/null +++ b/src/org/ascollada/core/DaeChannel.as @@ -0,0 +1,169 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeChannel extends DaeElement { + use namespace collada; + + public static const MEMBER_ACCESS :uint = 0; + public static const ARRAY_ACCESS :uint = 1; + + /** + * + */ + public var animation : DaeAnimation; + + /** + * + */ + public var source : String; + + /** + * + */ + public var target : String; + + /** + * + */ + public var sampler : DaeSampler; + + public var type :int = -1; + public var targetID :String; + public var targetSID :String; + public var targetMember :String; + public var arrayIndex0 :int; + public var arrayIndex1 :int; + + /** + * + */ + public function DaeChannel(document : DaeDocument, animation : DaeAnimation, element : XML = null) { + this.animation = animation; + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.sampler) { + this.sampler.destroy(); + this.sampler = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.source = readAttribute(element, "source", true); + this.target = readAttribute(element, "target"); + + var parts : Array = this.target.split("/"); + + if(parseArraySyntax(this.target)) { + this.type = ARRAY_ACCESS; + } else if(parseDotSyntax(this.target)) { + this.type = MEMBER_ACCESS; + } else if(this.target.length && parts.length) { + this.targetSID = parts.pop() as String; + this.type = MEMBER_ACCESS; + } else { + trace("[ERROR while parsing DaeChannel] " + target); + return; + } + + if(parts.length) { + this.targetID = this.targetID || parts.shift() as String; + } else { + this.targetID = this.targetID || this.targetSID; + this.targetSID = null; + } + + if(this.targetSID.indexOf("/") != -1) { + parts = this.targetSID.split("/"); + this.targetSID = parts.pop() as String; + } + + if(this.targetID.indexOf("(") != -1) { + parts = this.targetID.split("("); + this.targetID = parts.shift() as String; + } + } + + /** + * + */ + private function parseArraySyntax(target : String) : Boolean { + this.arrayIndex0 = -1; + this.arrayIndex1 = -1; + + if(target.indexOf("(") != -1) { + var pattern :RegExp = /.+\/(.+)\((\d+)\)\((\d+)\)/g; + + var matches:Array = pattern.exec(target); + + if(!matches) { + pattern = /.+\/(.+)\((\d+)\)/g; + matches = pattern.exec(target); + if(!matches) { + pattern = /(.+)\((\d+)\)\((\d+)\)/g; + matches = pattern.exec(target); + if(!matches) { + pattern = /(.+)\((\d+)\)/g; + matches = pattern.exec(target); + } + } + } + + if(matches && matches.length > 2) { + this.targetSID = matches[1]; + this.arrayIndex0 = parseInt(matches[2], 10); + if(matches.length > 3) + this.arrayIndex1 = parseInt(matches[3], 10); + return true; + } else { + trace("[WARNING] channel target contains '(...)', but failed to extract values! " + target); + } + } + + return false; + } + + /** + * + */ + private function parseDotSyntax(target : String) : Boolean { + if(target.indexOf(".") != -1) { + var parts :Array = target.split("."); + if(parts.length < 2) { + return false; + } + this.targetSID = parts.shift() as String; + this.targetMember = parts.shift() as String; + return true; + } + return false; + } + + override public function toString():String { + var str :String = "[DaeChannel "; + if(this.type == MEMBER_ACCESS) { + str += " (member access) targetID: '" + targetID + "' targetSID: '" + targetSID + "' targetMember: '" + targetMember +"'"; + } else { + str += " (array access) targetID: '" + targetID + "' targetSID: '" + targetSID + "' idx0: " + arrayIndex0; + if(arrayIndex1 >= 0) + str += " idx1: " + arrayIndex1; + } + str += "]"; + return str; + } + } +} diff --git a/src/org/ascollada/core/DaeController.as b/src/org/ascollada/core/DaeController.as new file mode 100644 index 0000000..16fa76c --- /dev/null +++ b/src/org/ascollada/core/DaeController.as @@ -0,0 +1,64 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeController extends DaeElement { + use namespace collada; + + /** + * + */ + public var skin : DaeSkin; + + /** + * + */ + public var morph : DaeMorph; + + /** + * + */ + public function DaeController(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.skin) { + this.skin.destroy(); + this.skin = null; + } + + if(this.morph) { + this.morph.destroy(); + this.morph = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element["skin"]; + + if(list.length()) { + this.skin = new DaeSkin(this.document, list[0]); + } else { + list = element["morph"]; + if(list.length()) { + this.morph = new DaeMorph(this.document, list[0]); + } else { + throw new Error("[DaeController] Could not find a <skin> or <morph> element!"); + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeDocument.as b/src/org/ascollada/core/DaeDocument.as new file mode 100644 index 0000000..a13b08b --- /dev/null +++ b/src/org/ascollada/core/DaeDocument.as @@ -0,0 +1,507 @@ +package org.ascollada.core { + import flash.display.Bitmap; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.TimerEvent; + import flash.net.URLRequest; + import flash.utils.Dictionary; + import flash.utils.Timer; + + import org.ascollada.fx.*; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeDocument extends DaeElement { + use namespace collada; + + /** */ + public static var DEFAULT_PARSE_SPEED : uint = 1; + + /** */ + public var COLLADA : XML; + + /** */ + public var scene : DaeNode; + + /** */ + public var animations : Dictionary; + + /** */ + public var animationClips : Dictionary; + + /** */ + public var animatables : Dictionary; + + /** */ + public var controllers : Dictionary; + + /** */ + public var images : Dictionary; + + /** */ + public var sources : Dictionary; + + /** */ + public var geometries : Dictionary; + + /** */ + public var materials : Dictionary; + + /** */ + public var effects : Dictionary; + + private var _elementQueue : Vector.<XML>; + private var _imageQueue : Vector.<DaeImage>; + private var _loadingImage : DaeImage; + private var _fileSearchPaths : Vector.<String>; + private var _searchPathIndex : int; + private var _parseSpeed : int; + + /** + * Constructor. + */ + public function DaeDocument(parseSpeed : int=-1) { + super(this, null); + + _fileSearchPaths = Vector.<String>([ + "testData", + ".", + "..", + "images", + "image", + "textures", + "texture", + "assets" + ]); + + _parseSpeed = parseSpeed > 0 ? parseSpeed : DEFAULT_PARSE_SPEED; + } + + /** + * + */ + public function addFileSearchPath(path : String) : void { + path = path.split("\\").join("/"); + if(path.charAt(path.length-1) == "/") { + path = path.substr(0, path.length-1); + } + _fileSearchPaths.unshift(path); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + var element : DaeElement; + + if(this.images) { + for each(element in this.images) { + element.destroy(); + element = null; + } + this.images = null; + } + + if(this.sources) { + for each(element in this.sources) { + element.destroy(); + element = null; + } + this.sources = null; + } + + if(this.materials) { + for each(element in this.materials) { + element.destroy(); + element = null; + } + this.materials = null; + } + + if(this.effects) { + for each(element in this.effects) { + element.destroy(); + element = null; + } + this.effects = null; + } + + if(this.geometries) { + for each(element in this.geometries) { + element.destroy(); + element = null; + } + this.geometries = null; + } + + if(this.scene) { + this.scene.destroy(); + this.scene = null; + } + + this.animatables = null; + + this.COLLADA = null; + } + + /** + * + */ + public function getNodeByID(id : String, parent : DaeNode = null) : DaeNode { + var child : DaeNode; + + parent = parent || this.scene; + + if(parent.id == id) { + return parent; + } + + for each(child in parent.nodes) { + var node : DaeNode = getNodeByID(id, child); + if(node) { + return node; + } + } + + return null; + } + + /** + * + */ + public function getNodeByName(name : String, parent : DaeNode = null) : DaeNode { + var child : DaeNode; + + parent = parent || this.scene; + + if(parent.name == name) { + return parent; + } + + for each(child in parent.nodes) { + var node : DaeNode = getNodeByName(name, child); + if(node) { + return node; + } + } + + return null; + } + + /** + * + */ + public function getNodeBySID(sid : String, parent : DaeNode = null) : DaeNode { + var child : DaeNode; + + parent = parent || this.scene; + + if(parent.sid == sid) { + return parent; + } + + for each(child in parent.nodes) { + var node : DaeNode = getNodeBySID(sid, child); + if(node) { + return node; + } + } + + return null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.COLLADA = element; + + readLibraryImages(); + } + + /** + * + */ + private function readAnimation(animation : DaeAnimation) : void { + var child : DaeAnimation; + var channel : DaeChannel; + + if(animation.channels) { + for each(channel in animation.channels) { + readAnimationChannel(channel); + } + } + + if(animation.animations) { + for each(child in animation.animations) { + readAnimation(child); + } + } + } + + /** + * + */ + private function readAnimationChannel(channel : DaeChannel) : void { + + var target : String = channel.targetID; + var node : DaeNode = getNodeByID(target); + + if(node) { + node.channels = node.channels || new Array(); + node.channels.push(channel); + } else { + var source : DaeSource = this.sources[target]; + if(source) { + source.channels = source.channels || new Array(); + source.channels.push(channel); + } else { + trace("[DaeDocument#readAnimationChannel] : could not find target for animation channel! " + target + " " + source); + } + } + } + + /** + * + */ + private function readLibraryAnimations() : void { + var list : XMLList = this.COLLADA..library_animations.animation; + var element : XML; + var animation : DaeAnimation; + + this.animatables = new Dictionary(true); + this.animations = new Dictionary(true); + + for each(element in list) { + animation= new DaeAnimation(this, element); + this.animations[animation.id] = animation; + readAnimation(animation); + } + } + + /** + * + */ + private function readLibraryAnimationClips() : void { + var list : XMLList = this.COLLADA..library_animation_clips.animation_clip; + var element : XML; + var clip : DaeAnimationClip; + + this.animationClips = new Dictionary(true); + + for each(element in list) { + clip = new DaeAnimationClip(this, element); + this.animationClips[clip.id] = clip; + trace(clip.id + " " + clip.instances.length); + } + } + + /** + * + */ + private function readLibraryControllers() : void { + var list : XMLList = this.COLLADA..library_controllers.controller; + var element : XML; + + this.controllers = new Dictionary(true); + for each(element in list) { + var controller : DaeController = new DaeController(this, element); + this.controllers[controller.id] = controller; + } + } + + /** + * + */ + private function readLibraryEffects() : void { + var list : XMLList = this.COLLADA..library_effects.effect; + var element : XML; + + this.effects = new Dictionary(true); + for each(element in list) { + var effect : DaeEffect = new DaeEffect(this, element); + this.effects[effect.id] = effect; + } + } + + /** + * + */ + private function readLibraryGeometries() : void { + var list : XMLList = this.COLLADA..library_geometries.geometry; + var element : XML; + + this.geometries = new Dictionary(true); + for each(element in list) { + var geometry : DaeGeometry = new DaeGeometry(this, element); + this.geometries[geometry.id] = geometry; + } + } + + /** + * + */ + private function readLibraryImages() : void { + var list : XMLList = this.COLLADA..library_images.image; + var element : XML; + + this.images = new Dictionary(true); + + _imageQueue = new Vector.<DaeImage>(); + + for each(element in list) { + var image : DaeImage = new DaeImage(this, element); + + this.images[ image.id ] = image; + + _imageQueue.push(image); + } + + readNextImage(); + } + + /** + * + */ + private function readLibraryMaterials() : void { + var list : XMLList = this.COLLADA..library_materials.material; + var element : XML; + + this.materials = new Dictionary(true); + for each(element in list) { + var material : DaeMaterial = new DaeMaterial(this, element); + this.materials[material.id] = material; + } + } + + private function readImage(image : DaeImage) : void { + var url : String = image.init_from; + var loader : Loader = new Loader(); + + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoadComplete); + loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onImageLoadError); + + if(_searchPathIndex >= 0) { + url = url.split("\\").join("/"); + var parts : Array = url.split("/"); + url = parts.pop() as String; + url = _fileSearchPaths[_searchPathIndex] + "/" + url; + } + + loader.load(new URLRequest(url)); + } + + /** + * + */ + private function readNextImage(event : Event=null) : void { + if(_imageQueue.length) { + _loadingImage = _imageQueue.pop(); + _searchPathIndex = -1; + readImage(_loadingImage); + } else { + readSources(); + } + } + + /** + * + */ + private function readNextSource(event : TimerEvent) : void { + var timer : Timer = event.target as Timer; + + if(_elementQueue.length) { + var element : XML = _elementQueue.pop(); + var source : DaeSource = new DaeSource(this, element); + + this.sources[ source.id ] = source; + //trace(source.id + " " + this.sources[ source.id ] ); + timer.start(); + } else { + + readLibraryMaterials(); + readLibraryEffects(); + readLibraryControllers(); + readLibraryGeometries(); + readScene(); + + readLibraryAnimations(); + readLibraryAnimationClips(); + + dispatchEvent(new Event(Event.COMPLETE)); + } + } + + /** + * + */ + private function readScene() : void { + var list : XMLList = this.COLLADA["scene"]; + + if(list.length()) { + var s : DaeScene = new DaeScene(this, list[0]); + + list = this.COLLADA..visual_scene.(@id == s.url); + if(list.length()) { + this.scene = new DaeNode(this, list[0]); + } + } else { + trace("Could not find any scene!"); + } + } + + /** + * + */ + private function readSources() : void { + this.sources = new Dictionary(true); + + _elementQueue = new Vector.<XML>(); + + // parse all <source> elements which have an @id attribute + var list :XMLList = this.COLLADA..source.(hasOwnProperty("@id")); + for each(var element:XML in list) { + _elementQueue.push(element); + } + + var timer : Timer = new Timer(10, 1); + timer.addEventListener(TimerEvent.TIMER_COMPLETE, readNextSource); + timer.start(); + } + + private function onImageLoadComplete(event : Event) : void { + var loaderInfo : LoaderInfo = event.target as LoaderInfo; + if(loaderInfo.content is Bitmap) { + var bitmap : Bitmap = loaderInfo.content as Bitmap; + + _loadingImage.bitmapData = bitmap.bitmapData; + } + readNextImage(); + } + + private function onImageLoadError(event : IOErrorEvent) : void { + _searchPathIndex++; + if(_searchPathIndex < _fileSearchPaths.length) { + readImage(_loadingImage); + } else { + readNextImage(); + } + } + + public function set parseSpeed(value : uint) : void { + _parseSpeed = value; + } + + public function get parseSpeed() : uint { + return _parseSpeed; + } + } +} diff --git a/src/org/ascollada/core/DaeElement.as b/src/org/ascollada/core/DaeElement.as new file mode 100644 index 0000000..a7ee430 --- /dev/null +++ b/src/org/ascollada/core/DaeElement.as @@ -0,0 +1,88 @@ +package org.ascollada.core { + import flash.events.EventDispatcher; + + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeElement extends EventDispatcher { + use namespace collada; + + /** */ + public var document : DaeDocument; + + /** */ + public var id : String; + + /** */ + public var sid : String; + + /** */ + public var name : String; + + /** */ + public var nodeName : String; + + /** + * + */ + public function DaeElement(document : DaeDocument, element : XML=null) { + this.document = document; + + if(element) { + read(element); + } + } + + /** + * + */ + public function destroy() : void { + this.document = null; + //this.id = this.sid = this.name = this.nodeName = null; + } + + /** + * + */ + public function read(element:XML) : void { + this.id = [email protected](); + this.sid = [email protected](); + this.name = [email protected](); + this.nodeName = element.localName() as String; + } + + /** + * + */ + public function readAttribute(element:XML, name:String, stripPound:Boolean=false):String + { + var attr:String = element.@[name].toString(); + if(stripPound && attr.charAt(0) == "#") + attr = attr.substr(1); + return attr; + } + + /** + * + */ + public function readText(element:XML, stripPound:Boolean=false):String { + if(!element) { + return null; + } + var string :String = element.text().toString(); + if(stripPound && string.charAt(0) == "#") { + string = string.substr(1); + } + return string; + } + + /** + * + */ + public function readStringArray(element:XML) : Array { + return element.text().toString().split(/\s+/); + } + } +} diff --git a/src/org/ascollada/core/DaeGeometry.as b/src/org/ascollada/core/DaeGeometry.as new file mode 100644 index 0000000..670f999 --- /dev/null +++ b/src/org/ascollada/core/DaeGeometry.as @@ -0,0 +1,55 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeGeometry extends DaeElement { + use namespace collada; + + public var mesh : DaeMesh; + + /** + * + */ + public function DaeGeometry(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + if(this.mesh) { + this.mesh.destroy(); + this.mesh = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element["mesh"]; + + if(list.length()) { + this.mesh = new DaeMesh(this.document, list[0]); + } else { + list = element["convex_mesh"]; + if(list.length()) { + + } else { + list = element["spline"]; + if(list.length()) { + + } else { + throw new Error(""); + } + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeImage.as b/src/org/ascollada/core/DaeImage.as new file mode 100644 index 0000000..c9e89b5 --- /dev/null +++ b/src/org/ascollada/core/DaeImage.as @@ -0,0 +1,33 @@ +package org.ascollada.core { + import flash.display.BitmapData; + + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeImage extends DaeElement { + use namespace collada; + + public var init_from : String; + public var bitmapData : BitmapData; + + public function DaeImage(document : DaeDocument, element : XML = null) { + super(document, element); + } + + override public function destroy() : void { + super.destroy(); + + if(this.bitmapData) { + this.bitmapData.dispose(); + this.bitmapData = null; + } + } + + override public function read(element : XML) : void { + super.read(element); + this.init_from = readText(element..init_from[0]); + } + } +} diff --git a/src/org/ascollada/core/DaeInput.as b/src/org/ascollada/core/DaeInput.as new file mode 100644 index 0000000..65f15ec --- /dev/null +++ b/src/org/ascollada/core/DaeInput.as @@ -0,0 +1,33 @@ +package org.ascollada.core { + import org.ascollada.core.DaeElement; + + /** + * @author Tim Knip + */ + public class DaeInput extends DaeElement { + + public var semantic :String; + public var source :String; + public var offset :int; + public var setnum :int; + + /** + * + */ + public function DaeInput(document : DaeDocument, element : XML = null) { + super(document, element); + } + + override public function destroy() : void { + super.destroy(); + } + + override public function read(element : XML) : void { + super.read(element); + this.semantic = readAttribute(element, "semantic"); + this.source = readAttribute(element, "source", true); + this.offset = [email protected]() ? parseInt([email protected](), 10) : 0; + this.setnum = [email protected]() ? parseInt([email protected](), 10) : 0; + } + } +} diff --git a/src/org/ascollada/core/DaeInstanceCamera.as b/src/org/ascollada/core/DaeInstanceCamera.as new file mode 100644 index 0000000..131b634 --- /dev/null +++ b/src/org/ascollada/core/DaeInstanceCamera.as @@ -0,0 +1,31 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeInstanceCamera extends DaeElement { + use namespace collada; + + /** + * + */ + public function DaeInstanceCamera(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + } + } +} diff --git a/src/org/ascollada/core/DaeInstanceController.as b/src/org/ascollada/core/DaeInstanceController.as new file mode 100644 index 0000000..cb0d676 --- /dev/null +++ b/src/org/ascollada/core/DaeInstanceController.as @@ -0,0 +1,86 @@ +package org.ascollada.core { + import org.ascollada.fx.DaeBindMaterial; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeInstanceController extends DaeElement { + use namespace collada; + + /** + * + */ + public var url : String; + + /** + * + */ + public var skeletons : Array; + + /** + * + */ + public var bindMaterial : DaeBindMaterial; + + /** + * + */ + public function DaeInstanceController(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.skeletons) { + while(this.skeletons.length) { + this.skeletons.pop(); + } + this.skeletons = null; + } + + if(this.bindMaterial) { + this.bindMaterial.destroy(); + this.bindMaterial = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element.children(); + var child : XML; + var num : int = list.length(); + var i : int; + + this.url = readAttribute(element, "url", true); + this.skeletons = new Array(); + + for(i = 0; i < num; i++) { + child = list[i]; + + switch(child.localName() as String) { + case "skeleton": + var skeleton : String = readText(child); + if(skeleton.charAt(0) == "#") { + skeleton = skeleton.substr(1); + } + this.skeletons.push(skeleton); + break; + case "bind_material": + this.bindMaterial = new DaeBindMaterial(this.document, child); + break; + default: + break; + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeInstanceGeometry.as b/src/org/ascollada/core/DaeInstanceGeometry.as new file mode 100644 index 0000000..8b0dd29 --- /dev/null +++ b/src/org/ascollada/core/DaeInstanceGeometry.as @@ -0,0 +1,55 @@ +package org.ascollada.core { + import org.ascollada.fx.DaeBindMaterial; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeInstanceGeometry extends DaeElement { + use namespace collada; + + /** + * The URL of the location of the &lt;geometry&gt; element to instantiate. Required. Can + * refer to a local instance or external reference. + */ + public var url : String; + + /** + * + */ + public var bindMaterial : DaeBindMaterial; + + /** + * + */ + public function DaeInstanceGeometry(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.bindMaterial) { + this.bindMaterial.destroy(); + this.bindMaterial = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.url = readAttribute(element, "url"); + + var list : XMLList = element["bind_material"]; + if(list.length()) { + this.bindMaterial = new DaeBindMaterial(this.document, list[0]); + } + } + } +} diff --git a/src/org/ascollada/core/DaeInstanceLight.as b/src/org/ascollada/core/DaeInstanceLight.as new file mode 100644 index 0000000..5d8aaed --- /dev/null +++ b/src/org/ascollada/core/DaeInstanceLight.as @@ -0,0 +1,31 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeInstanceLight extends DaeElement { + use namespace collada; + + /** + * + */ + public function DaeInstanceLight(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + } + } +} diff --git a/src/org/ascollada/core/DaeInstanceNode.as b/src/org/ascollada/core/DaeInstanceNode.as new file mode 100644 index 0000000..a4b157c --- /dev/null +++ b/src/org/ascollada/core/DaeInstanceNode.as @@ -0,0 +1,31 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeInstanceNode extends DaeElement { + use namespace collada; + + /** + * + */ + public function DaeInstanceNode(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + } + } +} diff --git a/src/org/ascollada/core/DaeMesh.as b/src/org/ascollada/core/DaeMesh.as new file mode 100644 index 0000000..db79cd0 --- /dev/null +++ b/src/org/ascollada/core/DaeMesh.as @@ -0,0 +1,100 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeMesh extends DaeElement { + use namespace collada; + + /** + * + */ + public var vertices : DaeVertices; + + /** + * + */ + public var primitives : Array; + + /** + * + */ + public function DaeMesh(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.vertices) { + this.vertices.destroy(); + this.vertices = null; + } + + if(this.primitives) { + while(this.primitives.length) { + var primitive : DaePrimitive = primitives.pop() as DaePrimitive; + primitive.destroy(); + } + this.primitives = null; + } + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element["vertices"]; + var child : XML; + + this.primitives = new Array(); + + if(list.length()) { + this.vertices = new DaeVertices(this.document, list[0]); + } else { + throw new Error("[DaeMesh] Required <vertices> element not found!"); + } + + list = element["triangles"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + + list = element["trifans"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + + list = element["tristrips"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + + list = element["polylist"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + + list = element["polygons"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + + list = element["lines"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + + list = element["linestrips"]; + for each(child in list) { + this.primitives.push(new DaePrimitive(this.document, this.vertices, child)); + } + } + } +} diff --git a/src/org/ascollada/core/DaeMorph.as b/src/org/ascollada/core/DaeMorph.as new file mode 100644 index 0000000..9126ac5 --- /dev/null +++ b/src/org/ascollada/core/DaeMorph.as @@ -0,0 +1,78 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeMorph extends DaeElement { + use namespace collada; + + /** + * + */ + public var source : String; + + /** + * + */ + public var method : String; + + /** + * + */ + public var targets : DaeSource; + + /** + * + */ + public var weights : DaeSource; + + /** + * + */ + public function DaeMorph(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + this.targets = null; + this.weights = null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.source = readAttribute(element, "source", true); + this.method = readAttribute(element, "method") || "NORMALIZED"; + + var targetInputs : XMLList = element["targets"].input; + var num : int = targetInputs.length(); + var i : int; + + for(i = 0; i < num; i++) { + var input : DaeInput = new DaeInput(document, targetInputs[i]); + + var src : DaeSource = document.sources[ input.source ]; + + switch(input.semantic) { + case "MORPH_TARGET": + this.targets = src; + break; + + case "MORPH_WEIGHT": + this.weights = src; + break; + default: + break; + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeNode.as b/src/org/ascollada/core/DaeNode.as new file mode 100644 index 0000000..25c67bb --- /dev/null +++ b/src/org/ascollada/core/DaeNode.as @@ -0,0 +1,232 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeNode extends DaeElement { + use namespace collada; + + /** + * + */ + public var nodes : Array; + + /** */ + public var type : String; + + /** */ + public var layer : String; + + /** + * + */ + public var transforms : Array; + + /** + * + */ + public var cameraInstances : Array; + + /** + * + */ + public var controllerInstances : Array; + + /** + * + */ + public var geometryInstances : Array; + + /** + * + */ + public var lightInstances : Array; + + /** + * + */ + public var nodeInstances : Array; + + /** + * + */ + public var channels : Array; + + /** + * + */ + public function DaeNode(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + var element : DaeElement; + + if(this.nodes) { + while(this.nodes.length) { + element = this.nodes.pop() as DaeElement; + element.destroy(); + element = null; + } + this.nodes = null; + } + + if(this.transforms) { + while(this.transforms.length) { + element = this.transforms.pop() as DaeElement; + element.destroy(); + element = null; + } + this.transforms = null; + } + + if(this.cameraInstances) { + while(this.cameraInstances.length) { + element = this.cameraInstances.pop() as DaeElement; + element.destroy(); + element = null; + } + this.cameraInstances = null; + } + + if(this.controllerInstances) { + while(this.controllerInstances.length) { + element = this.controllerInstances.pop() as DaeElement; + element.destroy(); + element = null; + } + this.controllerInstances = null; + } + + if(this.geometryInstances) { + while(this.geometryInstances.length) { + element = this.geometryInstances.pop() as DaeElement; + element.destroy(); + element = null; + } + this.geometryInstances = null; + } + + if(this.lightInstances) { + while(this.lightInstances.length) { + element = this.lightInstances.pop() as DaeElement; + element.destroy(); + element = null; + } + this.lightInstances = null; + } + + if(this.nodeInstances) { + while(this.nodeInstances.length) { + element = this.nodeInstances.pop() as DaeElement; + element.destroy(); + element = null; + } + this.nodeInstances = null; + } + } + + /** + * Gets a transform by SID. + * + * @param sid + * + * @return The found transform or null on error. + * + * @see org.ascollada.core.DaeTransform + */ + public function getTransformBySID(sid : String) : DaeTransform { + if(this.transforms) { + var transform : DaeTransform; + for each(transform in this.transforms) { + if(transform.sid == sid) { + return transform; + } + } + } + return null; + } + + /** + * + */ + public function getTransformChannelBySID(sid : String) : DaeChannel { + var channel : DaeChannel; + for each(channel in this.channels) { + if(channel.targetSID == sid) { + return channel; + } + } + return null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element.children(); + var child : XML; + var num : int = list.length(); + var i : int; + + this.type = readAttribute(element, "type"); + this.type = this.type.length == 0 ? "NODE" : this.type; + this.layer = readAttribute(element, "layer"); + this.name = (this.name && this.name.length) ? this.name : this.id; + this.nodes = new Array(); + this.transforms = new Array(); + this.cameraInstances = new Array(); + this.controllerInstances = new Array(); + this.geometryInstances = new Array(); + this.lightInstances = new Array(); + this.nodeInstances = new Array(); + + for(i = 0; i < num; i++) { + child = list[i]; + + switch(child.localName() as String) { + case "lookat": + case "matrix": + case "scale": + case "skew": + case "rotate": + case "translate": + this.transforms.push(new DaeTransform(this.document, child)); + break; + case "node": + this.nodes.push(new DaeNode(this.document, child)); + break; + case "instance_camera": + trace("CAMERA!"); + this.cameraInstances.push(new DaeInstanceCamera(this.document, child)); + break; + case "instance_controller": + this.controllerInstances.push(new DaeInstanceController(this.document, child)); + break; + case "instance_geometry": + this.geometryInstances.push(new DaeInstanceGeometry(this.document, child)); + break; + case "instance_light": + this.lightInstances.push(new DaeInstanceLight(this.document, child)); + break; + case "instance_node": + this.nodeInstances.push(new DaeInstanceNode(this.document, child)); + break; + case "extra": + break; + default: + trace(child.localName()); + break; + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeParam.as b/src/org/ascollada/core/DaeParam.as new file mode 100644 index 0000000..1af259f --- /dev/null +++ b/src/org/ascollada/core/DaeParam.as @@ -0,0 +1,23 @@ +package org.ascollada.core { + import org.ascollada.core.DaeElement; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeParam extends DaeElement { + /** */ + public var type : String; + + /** + * + */ + public function DaeParam(document : DaeDocument, element : XML = null) { + super(document, element); + } + + override public function read(element : XML) : void { + super.read(element); + this.type = [email protected](); + } + } +} diff --git a/src/org/ascollada/core/DaePrimitive.as b/src/org/ascollada/core/DaePrimitive.as new file mode 100644 index 0000000..d6876c5 --- /dev/null +++ b/src/org/ascollada/core/DaePrimitive.as @@ -0,0 +1,220 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaePrimitive extends DaeElement { + use namespace collada; + + /** + * + */ + public var material : String; + + /** + * + */ + public var vertices : DaeVertices; + + /** + * + */ + public var count : int; + + /** + * + */ + public var triangles : Array; + + /** + * + */ + public var texCoordInputs : Array; + + /** + * + */ + public var uvSets : Object; + + /** + * + */ + public function DaePrimitive(document : DaeDocument, vertices :DaeVertices, element : XML = null) { + this.vertices = vertices; + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + var element : DaeElement; + if(texCoordInputs) { + while(texCoordInputs.length) { + element = texCoordInputs.pop() as DaeElement; + element.destroy(); + element = null; + } + texCoordInputs = null; + } + + uvSets = null; + triangles = null; + vertices = null; + material = null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.material = readAttribute(element, "material", true); + this.count = parseInt(readAttribute(element, "count"), 10); + this.triangles = new Array(); + this.uvSets = new Object(); + this.texCoordInputs = new Array(); + + var list : XMLList = element["input"]; + var child : XML; + var input : DaeInput; + var inputs : Array = new Array(); + var maxOffset : int = 0; + + for each(child in list) { + input = new DaeInput(this.document, child); + switch(input.semantic) { + case "VERTEX": + input.source = this.vertices.source.id; + break; + case "TEXCOORD": + this.uvSets[input.setnum] = new Array(); + this.texCoordInputs.push(input); + break; + default: + break; + } + maxOffset = Math.max(maxOffset, input.offset); + inputs.push(input); + } + + var primitives : XMLList = element["p"]; + var vc : XML = element["vcount"][0]; + var vcount : Array = vc ? readStringArray(vc) : null; + + switch(this.nodeName) { + case "triangles": + buildTriangles(primitives, inputs, maxOffset + 1); + break; + case "polylist": + buildPolylist(primitives[0], vcount, inputs, maxOffset + 1); + break; + default: + trace("don't know how to process primitives of type : " + this.nodeName); + break; + } + } + + private function buildPolylist(primitive : XML, vcount:Array, inputs : Array, maxOffset : int) : void { + var input : DaeInput; + var p : Array = readStringArray(primitive); + var i : int, j : int, index : int, pid : int = 0; + var tmpUV : Object = new Object(); + + for each(input in inputs) { + if(input.semantic == "TEXCOORD") { + tmpUV[input.setnum] = new Array(); + } + } + + for(i = 0; i < vcount.length; i++) { + var numVerts : int = parseInt(vcount[i], 10); + var poly : Array = new Array(); + var uvs : Object = new Object(); + + for(j = 0; j < numVerts; j++) { + for each(input in inputs) { + + uvs[input.setnum] = uvs[input.setnum] || new Array(); + index = parseInt(p[pid + input.offset], 10); + + switch(input.semantic) { + case "VERTEX": + poly.push(index); + break; + case "TEXCOORD": + uvs[input.setnum].push(index); + break; + default: + break; + } + } + pid += maxOffset; + } + + // simple triangulation + for(j = 1; j < poly.length - 1; j++) { + this.triangles.push([poly[0], poly[j], poly[j+1]]); + var uv : Array; + for(var o:String in uvs) { + uv = uvs[o]; + this.uvSets[o].push([uv[0], uv[j], uv[j+1]]); + } + } + } + } + + private function buildTriangles(primitives : XMLList, inputs : Array, maxOffset : int) : void { + var input : DaeInput; + var primitive : XML; + var index : int; + var source : DaeSource; + var i : int; + + for each(primitive in primitives) { + var p : Array = readStringArray(primitive); + var tri : Array = new Array(); + var tmpUV : Object = new Object(); + + for each(input in inputs) { + if(input.semantic == "TEXCOORD") { + tmpUV[input.setnum] = new Array(); + } + } + + while(i < p.length) { + for each(input in inputs) { + source = this.document.sources[input.source]; + index = parseInt(p[i + input.offset], 10); + + switch(input.semantic) { + case "VERTEX": + tri.push(index); + if(tri.length == 3) { + this.triangles.push(tri); + tri = new Array(); + } + break; + case "TEXCOORD": + tmpUV[input.setnum].push(index); + if(tmpUV[input.setnum].length == 3) { + this.uvSets[input.setnum].push(tmpUV[input.setnum]); + tmpUV[input.setnum] = new Array(); + } + break; + case "NORMAL": + break; + default: + break; + } + } + i += maxOffset; + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeSampler.as b/src/org/ascollada/core/DaeSampler.as new file mode 100644 index 0000000..2d4277a --- /dev/null +++ b/src/org/ascollada/core/DaeSampler.as @@ -0,0 +1,88 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeSampler extends DaeElement { + use namespace collada; + + /** + * + */ + public var input : DaeSource; + + /** + * + */ + public var output : DaeSource; + + /** + * + */ + public var interpolations : DaeSource; + + /** + * + */ + public var in_tangents : DaeSource; + + /** + * + */ + public var out_tangents : DaeSource; + + /** + * + */ + public function DaeSampler(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + this.input = null; + this.output = null; + this.interpolations = null; + this.in_tangents = null; + this.out_tangents = null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element["input"]; + var child : XML; + + for each(child in list) { + var input : DaeInput = new DaeInput(this.document, child); + switch(input.semantic) { + case "INPUT": + this.input = this.document.sources[input.source]; + break; + case "OUTPUT": + this.output = this.document.sources[input.source]; + break; + case "INTERPOLATION": + this.interpolations = this.document.sources[input.source]; + break; + case "IN_TANGENT": + this.in_tangents = this.document.sources[input.source]; + break; + case "OUT_TANGENT": + this.out_tangents = this.document.sources[input.source]; + break; + default: + trace("[DaeSampler] unhandled semantic: " + input.semantic); + break; + } + } + } + } +} diff --git a/src/org/ascollada/core/DaeScene.as b/src/org/ascollada/core/DaeScene.as new file mode 100644 index 0000000..17d55e6 --- /dev/null +++ b/src/org/ascollada/core/DaeScene.as @@ -0,0 +1,41 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeScene extends DaeElement { + use namespace collada; + + /** + * + */ + public var url : String; + + /** + * + */ + public function DaeScene(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + var list : XMLList = element["instance_visual_scene"]; + + if(list.length()) { + this.url = readAttribute(list[0], "url", true); + } + } + } +} diff --git a/src/org/ascollada/core/DaeSkin.as b/src/org/ascollada/core/DaeSkin.as new file mode 100644 index 0000000..1f36032 --- /dev/null +++ b/src/org/ascollada/core/DaeSkin.as @@ -0,0 +1,195 @@ +package org.ascollada.core { + import flash.errors.IllegalOperationError; + + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeSkin extends DaeElement { + use namespace collada; + + /** */ + public var source : String; + + /** + * + */ + public var bind_shape_matrix :DaeTransform; + + /** + * + */ + public var joints :Array; + + /** + * + */ + public var inv_bind_matrix :Array; + + /** + * + */ + public var vertex_weights :Array; + + /** + * + */ + public function DaeSkin(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + + if(this.bind_shape_matrix) { + this.bind_shape_matrix.destroy(); + this.bind_shape_matrix = null; + } + + this.joints = null; + this.inv_bind_matrix = null; + this.vertex_weights = null; + } + + /** + * + */ + public function getBlendWeightsForJoint(joint : String) : Array { + var i : int, j: int; + var result : Array = new Array(); + + for(i = 0; i < this.vertex_weights.length; i++) { + var arr : Array = this.vertex_weights[i]; + for(j = 0; j < arr.length; j++) { + var bw : DaeBlendWeight = arr[j]; + if(bw.joint == joint) { + result.push(bw); + } + } + } + + return result; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.source = readAttribute(element, "source"); + + var list : XMLList = element["bind_shape_matrix"]; + + // bind shape matrix + if(list[0]) { + this.bind_shape_matrix = new DaeTransform(this.document, list[0]); + } else { + this.bind_shape_matrix = new DaeTransform(this.document); + this.bind_shape_matrix.data = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]; + } + this.bind_shape_matrix.nodeName = "matrix"; + + readJoints(element["joints"][0]); + readWeights(element["vertex_weights"][0]); + } + + /** + * + */ + private function readJoints(element:XML):void + { + if(!element) { + throw new IllegalOperationError("DaeSkin expects a single <joints> element!"); + } + + var a :XML = element["input"].(@semantic == "JOINT")[0]; + var b :XML = element["input"].(@semantic == "INV_BIND_MATRIX")[0]; + + if(!a || !b) { + throw new IllegalOperationError("DaeSkin <joints> element misses a required <input> element!"); + } + + var ainput :DaeInput = new DaeInput(null, a); + var binput :DaeInput = new DaeInput(null, b); + var asource :DaeSource = this.document.sources[ainput.source]; + var bsource :DaeSource = this.document.sources[binput.source]; + var i :int; + + this.joints = asource.data; + this.inv_bind_matrix = new Array(); + + for(i = 0; i < bsource.data.length; i++) { + var transform : DaeTransform = new DaeTransform(this.document); + + transform.data = bsource.data[i]; + transform.nodeName = "matrix"; + + this.inv_bind_matrix.push(transform); + } + } + + /** + * + */ + private function readWeights(element:XML):void { + if(!element) { + throw new IllegalOperationError("DaeSkin expects a single <vertex_weights> element!"); + } + + var a :XML = element["input"].(@semantic == "JOINT")[0]; + var b :XML = element["input"].(@semantic == "WEIGHT")[0]; + + if(!a || !b) { + throw new IllegalOperationError("DaeSkin <vertex_weights> element misses a required <input> element!"); + } + + var ainput :DaeInput = new DaeInput(null, a); + var binput :DaeInput = new DaeInput(null, b); + + //var asource :DaeSource = document.sources[ainput.source]; + var bsource :DaeSource = document.sources[binput.source]; + var inputCount :uint = element["input"].length(); + var i :int, j:int; + + if(!element["v"][0]) { + trace("DaeSkin : <vertex_weights> elements does not have a <v> element!"); + return; + } + + if(!element["vcount"][0]) { + trace("DaeSkin : <vertex_weights> elements does not have a <v> element!"); + return; + } + + var v:Array = readStringArray(element["v"][0]); + var vcount :Array = readStringArray(element["vcount"][0]); + var cur :int = 0; + + this.vertex_weights = new Array(); + + for(i = 0; i < vcount.length; i++) { + var vc:int = vcount[i]; + + var tmp:Array = new Array(); + + for(j = 0; j < vc; j++) { + var jidx:int = v[cur + ainput.offset]; + var widx:int = v[cur + binput.offset]; + + var weight :Number = bsource.data[widx]; + + tmp.push(new DaeBlendWeight(i, joints[jidx], weight)); + + cur += inputCount; + } + + this.vertex_weights.push(tmp); + } + } + } +} diff --git a/src/org/ascollada/core/DaeSource.as b/src/org/ascollada/core/DaeSource.as new file mode 100644 index 0000000..4f5fc47 --- /dev/null +++ b/src/org/ascollada/core/DaeSource.as @@ -0,0 +1,143 @@ +package org.ascollada.core { + import flash.errors.IllegalOperationError; + + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeSource extends DaeElement { + use namespace collada; + + public var data : Array; + public var dataType : String; + public var accessor : DaeAccessor; + public var channels : Array; + + /** + * + */ + public function DaeSource(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + this.data = null; + this.dataType = null; + if(this.accessor) { + this.accessor.destroy(); + this.accessor = null; + } + this.channels = null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.dataType = "float_array"; + + var list : XMLList = element[this.dataType]; + + // read in the raw data + if(list.length()) { + this.data = readStringArray(list[0]); + } else { + this.dataType = "Name_array"; + list = element[this.dataType]; + if(list.length()) { + this.data = readStringArray(list[0]); + } else { + this.dataType = "IDREF_array"; + list = element[this.dataType]; + if(list.length()) { + this.data = readStringArray(list[0]); + } else { + this.dataType = "int_array"; + list = element[this.dataType]; + if(list.length()) { + this.data = readStringArray(list[0]); + } else { + this.dataType = "bool_array"; + list = element[this.dataType]; + if(list.length()) { + this.data = readStringArray(list[0]); + } else { + throw new IllegalOperationError("DaeSource : no data found!"); + } + } + } + } + } + + // read the accessor + if(element..accessor[0]) { + this.accessor = new DaeAccessor(this.document, element..accessor[0]); + } else { + throw new Error("[DaeSource] could not find an accessor!"); + } + + // interleave data + var tmp :Array = new Array(); + for(var i:int = 0; i < this.accessor.count; i++) + { + var arr :Array = readValue(i); + if(arr.length > 1) + tmp.push(arr); + else + tmp.push(arr[0]); + } + this.data = tmp; + } + + /** + * + */ + private function readValue(index:int, forceType:Boolean=true):Array + { + var values :Array = new Array(); + var data :Array = this.data; + var stride :int = this.accessor.stride; + var type :String = this.dataType; + var start :int = index * stride; + var value :String; + var i :int; + + for(i = 0; i < stride; i++) + { + value = data[start + i]; + if(forceType && (type == "bool_array" || type == "float_array" || type == "int_array")) + { + if(type == "float_array") + { + if(value.indexOf(",") != -1) + { + value = value.replace(/,/, "."); + } + values.push(parseFloat(value)); + } + else if(type == "bool_array") + { + values.push((value == "true" || value == "1" ? true : false)); + } + else + { + values.push(parseInt(value, 10)); + } + } + else + { + values.push(value); + } + } + + return values; + } + } +} diff --git a/src/org/ascollada/core/DaeTransform.as b/src/org/ascollada/core/DaeTransform.as new file mode 100644 index 0000000..f1228b0 --- /dev/null +++ b/src/org/ascollada/core/DaeTransform.as @@ -0,0 +1,43 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeTransform extends DaeElement { + use namespace collada; + + /** + * + */ + public var data : Array; + + /** + * + */ + public function DaeTransform(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + this.data = null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.data = readStringArray(element); + + for(var i : int = 0; i < this.data.length; i++) { + this.data[i] = parseFloat(this.data[i]); + } + } + } +} diff --git a/src/org/ascollada/core/DaeVertices.as b/src/org/ascollada/core/DaeVertices.as new file mode 100644 index 0000000..889dd22 --- /dev/null +++ b/src/org/ascollada/core/DaeVertices.as @@ -0,0 +1,50 @@ +package org.ascollada.core { + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeVertices extends DaeElement { + use namespace collada; + + public var source : DaeSource; + + /** + * + */ + public function DaeVertices(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element["input"]; + var num : int = list.length(); + var i : int; + + for(i = 0; i < num; i++) { + var child : XML = list[i]; + var input : DaeInput = new DaeInput(this.document, child); + + if(input.semantic == "POSITION") { + this.source = this.document.sources[input.source] as DaeSource; + } + } + + if(!this.source) { + throw new Error("[DaeVertices] required <input> element with @semantic=\"POSITION\" not found!"); + } + } + } +} diff --git a/src/org/ascollada/core/ns/collada.as b/src/org/ascollada/core/ns/collada.as new file mode 100644 index 0000000..7468e1f --- /dev/null +++ b/src/org/ascollada/core/ns/collada.as @@ -0,0 +1,6 @@ +package org.ascollada.core.ns { +/** + * @author Tim Knip + */ +public namespace collada = "http://www.collada.org/2005/11/COLLADASchema"; +} diff --git a/src/org/ascollada/fx/DaeBindMaterial.as b/src/org/ascollada/fx/DaeBindMaterial.as new file mode 100644 index 0000000..48cd7d8 --- /dev/null +++ b/src/org/ascollada/fx/DaeBindMaterial.as @@ -0,0 +1,58 @@ +package org.ascollada.fx { + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeBindMaterial extends DaeElement { + use namespace collada; + + public var instanceMaterials : Array; + + /** + * + */ + public function DaeBindMaterial(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public function getInstanceMaterialBySymbol(symbol : String) : DaeInstanceMaterial { + if(instanceMaterials) { + for each(var m : DaeInstanceMaterial in instanceMaterials) { + if(m.symbol == symbol) { + return m; + } + } + } + return null; + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + var list : XMLList = element..instance_material; + var child : XML; + + this.instanceMaterials = new Array(); + + for each(child in list) { + this.instanceMaterials.push(new DaeInstanceMaterial(this.document, child)); + } + } + } +} diff --git a/src/org/ascollada/fx/DaeBindVertexInput.as b/src/org/ascollada/fx/DaeBindVertexInput.as new file mode 100644 index 0000000..28b3fdb --- /dev/null +++ b/src/org/ascollada/fx/DaeBindVertexInput.as @@ -0,0 +1,64 @@ +package org.ascollada.fx { + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + /** + * Binds geometry vertex inputs to effect vertex inputs upon instantiation. + * + * <p><strong>CONCEPTS</strong></p> + * <p>This element is useful, for example, in binding a vertex-program parameter to a <source>. The vertex + * program needs data already gathered from sources. This data comes from the <input> elements under + * the collation elements such as <polygons> or <triangles>. Inputs access the data in <source>s and + * guarantee that it corresponds with the polygon vertex “fetch”. To reference the <input>s for binding, use + * <bind_vertex_input>.</p> + * + * @author Tim Knip / floorplanner.com + */ + public class DaeBindVertexInput extends DaeElement { + use namespace collada; + + /** + * + */ + public var semantic : String; + + /** + * + */ + public var input_semantic : String; + + /** + * + */ + public var input_set : uint; + + /** + * + */ + public function DaeBindVertexInput(document : DaeDocument, element : XML = null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + override public function read(element : XML) : void { + super.read(element); + + this.semantic = readAttribute(element, "semantic"); + this.input_semantic = readAttribute(element, "input_semantic"); + + var setid : String = readAttribute(element, "input_set"); + + this.input_set = (setid && setid.length) ? parseInt(setid, 10) : 0; + } + } +} diff --git a/src/org/ascollada/fx/DaeBlinn.as b/src/org/ascollada/fx/DaeBlinn.as new file mode 100644 index 0000000..cadb4a9 --- /dev/null +++ b/src/org/ascollada/fx/DaeBlinn.as @@ -0,0 +1,51 @@ +package org.ascollada.fx +{ + import org.ascollada.core.DaeDocument; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeBlinn extends DaeLambert { + use namespace collada; + + public var specular :DaeColorOrTexture; + public var shininess :Number = 0; + + /** + * + */ + public function DaeBlinn(document:DaeDocument, element:XML=null) { + super(document, element); + } + + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + var children:XMLList = element.children(); + var numChildren:int = children.length(); + + for( var i:int = 0; i < numChildren; i++ ) { + var child:XML = children[i]; + + switch(child.localName()) { + case "specular": + this.specular = new DaeColorOrTexture(document, child); + break; + case "shininess": + this.shininess = child["float"][0] ? parseFloat(readText(child["float"][0])) : this.shininess; + break; + default: + break; + } + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeColor.as b/src/org/ascollada/fx/DaeColor.as new file mode 100644 index 0000000..6388d67 --- /dev/null +++ b/src/org/ascollada/fx/DaeColor.as @@ -0,0 +1,53 @@ +package org.ascollada.fx +{ + import flash.errors.IllegalOperationError; + + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + public class DaeColor extends DaeElement + { + use namespace collada; + + public var r :Number; + public var g :Number; + public var b :Number; + public var a :Number; + + /** + * + */ + public function DaeColor(document:DaeDocument, element:XML=null) + { + super(document, element); + } + + /** + * + */ + public override function read(element:XML):void + { + super.read(element); + + var data :Array = readStringArray(element); + var i :int; + + if(data.length >= 3) + { + for(i = 0; i < data.length; i++) + { + data[i] = data[i].replace(/,/, "."); + } + this.r = parseFloat(data[0]); + this.g = parseFloat(data[1]); + this.b = parseFloat(data[2]); + this.a = data.length > 3 ? parseFloat(data[3]) : 1.0; + } + else + { + throw new IllegalOperationError("Invalid color: " + element); + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeColorOrTexture.as b/src/org/ascollada/fx/DaeColorOrTexture.as new file mode 100644 index 0000000..1ffdf32 --- /dev/null +++ b/src/org/ascollada/fx/DaeColorOrTexture.as @@ -0,0 +1,39 @@ +package org.ascollada.fx +{ + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + import org.ascollada.fx.DaeColor; + import org.ascollada.fx.DaeTexture; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeColorOrTexture extends DaeElement { + use namespace collada; + + public var color :DaeColor; + public var texture :DaeTexture; + + /** + * + */ + public function DaeColorOrTexture(document:DaeDocument, element:XML) { + super(document, element); + } + + /** + * + */ + public override function read(element:XML):void + { + super.read(element); + + if(element["texture"][0]) { + this.texture = new DaeTexture(document, element["texture"][0]); + } else if(element["color"][0]) { + this.color = new DaeColor(document, element["color"][0]); + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeConstant.as b/src/org/ascollada/fx/DaeConstant.as new file mode 100644 index 0000000..fb0d2de --- /dev/null +++ b/src/org/ascollada/fx/DaeConstant.as @@ -0,0 +1,64 @@ +package org.ascollada.fx +{ + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeConstant extends DaeElement { + use namespace collada; + + public var emission:DaeColorOrTexture; + public var reflective:DaeColorOrTexture; + public var reflectivity:Number = 0; + public var transparent:DaeColorOrTexture; + public var transparency:Number = 0; + public var index_of_refraction:Number = 0; + + /** + * + */ + public function DaeConstant(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + var children:XMLList = element.children(); + var numChildren:int = children.length(); + + for( var i:int = 0; i < numChildren; i++ ) { + var child:XML = children[i]; + + switch(child.localName()) { + case "emission": + this.emission = new DaeColorOrTexture(document, child); + break; + case "reflective": + this.reflective = new DaeColorOrTexture(document, child); + break; + case "transparant": + this.reflective = new DaeColorOrTexture(document, child); + break; + case "reflectivity": + this.reflectivity = child["float"][0] ? parseFloat(readText(child["float"][0])) : this.reflectivity; + break; + case "transparency": + this.transparency = child["float"][0] ? parseFloat(readText(child["float"][0])) : this.transparency; + break; + case "index_of_refraction": + this.index_of_refraction = child["float"][0] ? parseFloat(readText(child["float"][0])) : this.index_of_refraction; + break; + default: + break; + } + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeEffect.as b/src/org/ascollada/fx/DaeEffect.as new file mode 100644 index 0000000..13a66d7 --- /dev/null +++ b/src/org/ascollada/fx/DaeEffect.as @@ -0,0 +1,111 @@ +package org.ascollada.fx +{ + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + public class DaeEffect extends DaeElement { + use namespace collada; + + public var shader :DaeConstant; + + public var surface :DaeSurface; + + public var sampler2D :DaeSampler2D; + + public var double_sided :Boolean; + public var wireframe :Boolean; + + /** + * + */ + public function DaeEffect(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + this.double_sided = false; + this.wireframe = false; + + if(!readProfileCommon(element["profile_COMMON"][0])) { + trace("[WARNING] DaeEffect: profile not found!"); + } + + if(element["extra"][0]) { + readExtra(element["extra"][0]); + } + } + + private function readExtra(element:XML):void { + var technique :XML = element["technique"][0]; + + if(!technique) { + return; + } + + var profile :String = readAttribute(technique, "profile"); + + switch(profile) { + case "MAX3D": + this.double_sided = (technique["double_sided"][0] && readText(technique["double_sided"][0])) != "0" ? true : false; + this.wireframe = (technique["wireframe"][0] && readText(technique["wireframe"][0])) != "0" ? true : false; + break; + case "GOOGLEEARTH": + this.double_sided = (technique["double_sided"][0] && readText(technique["double_sided"][0])) != "0" ? true : false; + break; + default: + break; + } + } + + private function readProfileCommon(element:XML):Boolean + { + if(!element) return false; + + if(element..sampler2D[0]) { + this.sampler2D = new DaeSampler2D(document, element..sampler2D[0]); + + var surf :XML = element["newparam"].(@sid == this.sampler2D.source)["surface"][0]; + if(surf) { + this.surface = new DaeSurface(document, surf); + } + } + + if(!element["technique"].length) + return false; + + var technique :XML = element["technique"][0]; + + if(technique["constant"][0]) { + this.shader = new DaeConstant(document, technique["constant"][0]); + } else if(technique["lambert"][0]) { + this.shader = new DaeLambert(document, technique["lambert"][0]); + } else if(technique["blinn"][0]) { + this.shader = new DaeBlinn(document, technique["blinn"][0]); + } else if(technique["phong"][0]) { + this.shader = new DaePhong(document, technique["phong"][0]); + } else { + trace("[WARNING] DaeEffect : could not find a suitable shader!"); + } + + if(element["extra"][0]){ + readExtra(element["extra"][0]); + } + + return true; + } + + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeInstanceMaterial.as b/src/org/ascollada/fx/DaeInstanceMaterial.as new file mode 100644 index 0000000..5399522 --- /dev/null +++ b/src/org/ascollada/fx/DaeInstanceMaterial.as @@ -0,0 +1,59 @@ +package org.ascollada.fx { + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeInstanceMaterial extends DaeElement { + use namespace collada; + + public var symbol :String; + public var target :String; + public var bind_vertex_input :Array; + + /** + * + */ + public function DaeInstanceMaterial(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public function findBindVertexInput(semantic:String, input_semantic:String):DaeBindVertexInput { + for each(var bv:DaeBindVertexInput in this.bind_vertex_input) { + if(bv.semantic == semantic && bv.input_semantic == input_semantic) + return bv; + } + return null; + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + this.symbol = readAttribute(element, "symbol"); + this.target = readAttribute(element, "target"); + this.bind_vertex_input = new Array(); + + var list :XMLList = element["bind_vertex_input"]; + var i :int; + + for(i = 0; i < list.length(); i++) { + this.bind_vertex_input.push(new DaeBindVertexInput(document, list[i])); + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeLambert.as b/src/org/ascollada/fx/DaeLambert.as new file mode 100644 index 0000000..d0ce050 --- /dev/null +++ b/src/org/ascollada/fx/DaeLambert.as @@ -0,0 +1,50 @@ +package org.ascollada.fx { + import org.ascollada.core.DaeDocument; + import org.ascollada.core.ns.collada; + + public class DaeLambert extends DaeConstant { + use namespace collada; + + public var ambient:DaeColorOrTexture; + public var diffuse:DaeColorOrTexture; + + /** + * + */ + public function DaeLambert(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + var children:XMLList = element.children(); + var numChildren:int = children.length(); + + for( var i:int = 0; i < numChildren; i++ ) { + var child:XML = children[i]; + + switch(child.localName()) { + case "ambient": + this.ambient = new DaeColorOrTexture(document, child); + break; + case "diffuse": + this.diffuse = new DaeColorOrTexture(document, child); + break; + default: + break; + } + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeMaterial.as b/src/org/ascollada/fx/DaeMaterial.as new file mode 100644 index 0000000..d60c195 --- /dev/null +++ b/src/org/ascollada/fx/DaeMaterial.as @@ -0,0 +1,34 @@ +package org.ascollada.fx { + import flash.errors.IllegalOperationError; + + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + public class DaeMaterial extends DaeElement { + use namespace collada; + + public var instance_effect :String; + + /** + * + */ + public function DaeMaterial(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + public override function read(element:XML):void + { + super.read(element); + + if(element["instance_effect"][0]) { + this.instance_effect = readAttribute(element["instance_effect"][0], "url", true); + } else { + throw new IllegalOperationError("DaeMaterial expected a single <instance_effect> element!"); + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaePhong.as b/src/org/ascollada/fx/DaePhong.as new file mode 100644 index 0000000..500c998 --- /dev/null +++ b/src/org/ascollada/fx/DaePhong.as @@ -0,0 +1,53 @@ +package org.ascollada.fx { + import org.ascollada.core.DaeDocument; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaePhong extends DaeLambert { + use namespace collada; + + public var specular :DaeColorOrTexture; + public var shininess :Number = 0; + + /** + * + */ + public function DaePhong(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + var children:XMLList = element.children(); + var numChildren:int = children.length(); + + for( var i:int = 0; i < numChildren; i++ ) { + var child:XML = children[i]; + + switch(child.localName()) { + case "specular": + this.specular = new DaeColorOrTexture(document, child); + break; + case "shininess": + this.shininess = child["float"][0] ? parseFloat(readText(child["float"][0])) : this.shininess; + break; + default: + break; + } + } + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeSampler2D.as b/src/org/ascollada/fx/DaeSampler2D.as new file mode 100644 index 0000000..4654db2 --- /dev/null +++ b/src/org/ascollada/fx/DaeSampler2D.as @@ -0,0 +1,54 @@ +package org.ascollada.fx { + import flash.errors.IllegalOperationError; + + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + /** + * @author Tim Knip / floorplanner.com + */ + public class DaeSampler2D extends DaeElement { + use namespace collada; + + public var source :String; + public var wrap_s :String; + public var wrap_t :String; + public var minfilter :String; + public var magfilter :String; + public var mipfilter :String; + + /** + * + */ + public function DaeSampler2D(document:DaeDocument, element:XML=null) { + super(document, element); + } + + /** + * + */ + override public function destroy() : void { + super.destroy(); + } + + /** + * + */ + public override function read(element:XML):void { + super.read(element); + + if(element["source"][0]) { + this.source = readText(element["source"][0]); + } else { + throw new IllegalOperationError("DaeSampler2D expected a single <source> element!"); + } + + this.wrap_s = element["wrap_s"][0] ? readText(element["wrap_s"][0]) : "NONE"; + this.wrap_t = element["wrap_t"][0] ? readText(element["wrap_t"][0]) : "NONE"; + this.magfilter = element["magfilter"][0] ? readText(element["magfilter"][0]) : "NONE"; + this.minfilter = element["minfilter"][0] ? readText(element["minfilter"][0]) : "NONE"; + this.mipfilter = element["mipfilter"][0] ? readText(element["mipfilter"][0]) : "NONE"; + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeSurface.as b/src/org/ascollada/fx/DaeSurface.as new file mode 100644 index 0000000..5c7b93c --- /dev/null +++ b/src/org/ascollada/fx/DaeSurface.as @@ -0,0 +1,35 @@ +package org.ascollada.fx +{ + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + public class DaeSurface extends DaeElement + { + use namespace collada; + + public var type :String; + public var init_from :String; + public var format :String; + + /** + * + */ + public function DaeSurface(document:DaeDocument, element:XML=null) + { + super(document, element); + } + + /** + * + */ + public override function read(element:XML):void + { + super.read(element); + + this.type = readAttribute(element, "type"); + this.init_from = element["init_from"][0] ? readText(element["init_from"][0]) : ""; + this.format = element["format"][0] ? readText(element["format"][0]) : ""; + } + } +} \ No newline at end of file diff --git a/src/org/ascollada/fx/DaeTexture.as b/src/org/ascollada/fx/DaeTexture.as new file mode 100644 index 0000000..b7198b6 --- /dev/null +++ b/src/org/ascollada/fx/DaeTexture.as @@ -0,0 +1,33 @@ +package org.ascollada.fx +{ + import org.ascollada.core.DaeDocument; + import org.ascollada.core.DaeElement; + import org.ascollada.core.ns.collada; + + public class DaeTexture extends DaeElement + { + use namespace collada; + + public var texture :String; + public var texcoord :String; + + /** + * + */ + public function DaeTexture(document:DaeDocument, element:XML=null) + { + super(document, element); + } + + /** + * + */ + public override function read(element:XML):void + { + super.read(element); + + this.texture = readAttribute(element, "texture", true); + this.texcoord = readAttribute(element, "texcoord", true); + } + } +} \ No newline at end of file
timknip/papervision3d
fb84648d44c752d55cca6edcb0b2856312cfd183
cleanup
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a1b552 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.DS_Store +.actionScriptProperties +.flexLibProperties +.project +.settings/* +bin/* +bin-debug/* +html-template/* \ No newline at end of file diff --git a/org/papervision3d/cameras/Camera3D.as b/org/papervision3d/cameras/Camera3D.as deleted file mode 100755 index fd1af08..0000000 --- a/org/papervision3d/cameras/Camera3D.as +++ /dev/null @@ -1,115 +0,0 @@ -package org.papervision3d.cameras -{ - import flash.geom.Matrix3D; - import flash.geom.Rectangle; - - import org.papervision3d.core.math.utils.MatrixUtil; - import org.papervision3d.core.ns.pv3d; - import org.papervision3d.objects.DisplayObject3D; - import org.papervision3d.objects.Frustum3D; - - /** - * - */ - public class Camera3D extends DisplayObject3D - { - use namespace pv3d; - - public var projectionMatrix :Matrix3D; - public var viewMatrix :Matrix3D; - - private var _dirty:Boolean; - private var _aspectRatio:Number; - private var _fov:Number; - private var _far:Number; - private var _near:Number; - private var _ortho:Boolean; - private var _orthoScale:Number; - pv3d var _frustum :Frustum3D; - - /** - * Constructor. - * - * @param fov - * @param near - * @param far - * @param aspectRatio - * @param name - */ - public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, aspectRatio:Number=1.375, name:String=null) - { - super(name); - - _fov = fov; - _near = near; - _far = far; - _aspectRatio = aspectRatio; - _dirty = true; - _ortho = false; - _orthoScale = 1; - _frustum = new Frustum3D("Frustum3D_For_" + name); - - addChild(_frustum); - - viewMatrix = new Matrix3D(); - } - - /** - * - */ - public function update(viewport:Rectangle) : void - { - viewMatrix.rawData = transform.worldTransform.rawData; - viewMatrix.invert(); - - if(_dirty) - { - _dirty = false; - - if(_ortho) - { - projectionMatrix = MatrixUtil.createOrthoMatrix(viewport.width, -viewport.width, -viewport.height, viewport.height, -_far, _far); - } - else - { - _aspectRatio = viewport.width / viewport.height; - projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); - } - } - - //_frustum.update(this); - } - - /** - * - */ - public function get aspectRatio():Number - { - return _aspectRatio; - } - - /** - * - */ - public function get far():Number - { - return _far; - } - - /** - * - */ - public function get fov():Number - { - return _fov; - } - - /** - * - */ - public function get near():Number - { - return _near; - } - } -} \ No newline at end of file diff --git a/org/papervision3d/core/math/utils/MatrixUtil.as b/org/papervision3d/core/math/utils/MatrixUtil.as deleted file mode 100755 index 50e8ca8..0000000 --- a/org/papervision3d/core/math/utils/MatrixUtil.as +++ /dev/null @@ -1,91 +0,0 @@ -package org.papervision3d.core.math.utils -{ - import flash.geom.Matrix3D; - import flash.geom.Vector3D; - - public class MatrixUtil - { - private static var _f :Vector3D = new Vector3D(); - private static var _s :Vector3D = new Vector3D(); - private static var _u :Vector3D = new Vector3D(); - - /** - * - */ - public static function createLookAtMatrix(eye:Vector3D, target:Vector3D, up:Vector3D, resultMatrix:Matrix3D=null):Matrix3D - { - resultMatrix = resultMatrix || new Matrix3D(); - - _f.x = target.x - eye.x; - _f.y = target.y - eye.y; - _f.z = target.z - eye.z; - _f.normalize(); - - _s.x = (up.y * _f.z) - (up.z * _f.y); - _s.y = (up.z * _f.x) - (up.x * _f.z); - _s.z = (up.x * _f.y) - (up.y * _f.x); - _s.normalize(); - - _u.x = (_s.y * _f.z) - (_s.z * _f.y); - _u.y = (_s.z * _f.x) - (_s.x * _f.z); - _u.z = (_s.x * _f.y) - (_s.y * _f.x); - _u.normalize(); - - resultMatrix.rawData = Vector.<Number>([ - _s.x, _s.y, _s.z, 0, - _u.x, _u.y, _u.z, 0, - -_f.x, -_f.y, -_f.z, 0, - 0, 0, 0, 1 - ]); - - return resultMatrix; - } - - /** - * Creates a projection matrix. - * - * @param fovY - * @param aspectRatio - * @param near - * @param far - */ - public static function createProjectionMatrix(fovy:Number, aspect:Number, zNear:Number, zFar:Number):Matrix3D - { - var sine :Number, cotangent :Number, deltaZ :Number; - var radians :Number = (fovy / 2) * (Math.PI / 180); - - deltaZ = zFar - zNear; - sine = Math.sin(radians); - if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) - { - return null; - } - cotangent = Math.cos(radians) / sine; - - var v:Vector.<Number> = Vector.<Number>([ - cotangent / aspect, 0, 0, 0, - 0, cotangent, 0, 0, - 0, 0, -(zFar + zNear) / deltaZ, -1, - 0, 0, -(2 * zFar * zNear) / deltaZ, 0 - ]); - return new Matrix3D(v); - } - - /** - * - */ - public static function createOrthoMatrix(left:Number, right:Number, top:Number, bottom:Number, zNear:Number, zFar:Number) : Matrix3D { - var tx :Number = (right + left) / (right - left); - var ty :Number = (top + bottom) / (top - bottom); - var tz :Number = (zFar+zNear) / (zFar-zNear); - var v:Vector.<Number> = Vector.<Number>([ - 2 / (right - left), 0, 0, 0, - 0, 2 / (top - bottom), 0, 0, - 0, 0, -2 / (zFar-zNear), 0, - tx, ty, tz, 1 - ]); - return new Matrix3D(v); - } - - } -} \ No newline at end of file diff --git a/org/papervision3d/objects/Frustum3D.as b/org/papervision3d/objects/Frustum3D.as deleted file mode 100755 index ec9b13b..0000000 --- a/org/papervision3d/objects/Frustum3D.as +++ /dev/null @@ -1,132 +0,0 @@ -package org.papervision3d.objects -{ - import flash.geom.Matrix3D; - import flash.geom.Vector3D; - - import org.papervision3d.cameras.Camera3D; - import org.papervision3d.core.math.Plane3D; - - public class Frustum3D extends DisplayObject3D - { - public var worldPlanes :Vector.<Plane3D>; - - private var _xAxis :Vector3D; - private var _yAxis :Vector3D; - private var _zAxis :Vector3D; - - private var _MP :Matrix3D; - - /** - * - */ - public function Frustum3D(name:String=null) - { - super(name); - - this.worldPlanes = new Vector.<Plane3D>(6, true); - for (var i:int = 0; i < 6; i++) - { - this.worldPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); - } - - _xAxis = new Vector3D(); - _yAxis = new Vector3D(); - _zAxis = new Vector3D(); - - _MP = new Matrix3D(); - } - - /** - * - */ - public function update(camera:Camera3D):void - { - //this.transform.worldTransform.rawData = camera.transform.viewTransform.rawData; - //this.transform.worldTransform.invert(); - - var v :Vector.<Number> = camera.transform.viewTransform.rawData; - - _xAxis.x = v[0]; - _xAxis.y = v[1]; - _xAxis.z = v[2]; - _yAxis.x = v[4]; - _yAxis.y = v[5]; - _yAxis.z = v[6]; - _zAxis.x = v[8]; - _zAxis.y = v[9]; - _zAxis.z = v[10]; - - _xAxis.normalize(); - _yAxis.normalize(); - _zAxis.normalize(); - - var zNeg :Vector3D = _zAxis.clone(); - zNeg.negate(); - - _MP.rawData = camera.transform.worldTransform.rawData; - - // _MP.prepend(camera.projectionMatrix); - //_MP.invert(); - - //this.worldPlanes[0].normalize(); - - Plane3D(this.worldPlanes[0]).setNormalAndPoint(_zAxis, new Vector3D()); - - //trace(this.worldPlanes[0]); - //extractPlanes(_MP, this.worldPlanes); - } - - /** - * Extract planes. - * - * @param matrix - * @param planes - */ - public function extractPlanes(matrix:Matrix3D, planes:Vector.<Plane3D> ):void - { - var m :Vector.<Number> = matrix.rawData; - - planes[0].setCoefficients( - m[2] + m[3], - m[6] + m[7], - m[10] + m[11], - m[14] + m[15] - ); - - planes[1].setCoefficients( - -m[2] + m[3], - -m[6] + m[7], - -m[10] + m[11], - -m[14] + m[15] - ); - - planes[2].setCoefficients( - m[0] + m[3], - m[4] + m[7], - m[8] + m[11], - m[12] + m[15] - ); - - planes[3].setCoefficients( - -m[0] + m[3], - -m[4] + m[7], - -m[8] + m[11], - -m[12] + m[15] - ); - - planes[4].setCoefficients( - -m[1] + m[3], - -m[5] + m[7], - -m[9] + m[11], - -m[13] + m[15] - ); - - planes[5].setCoefficients( - m[1] + m[3], - m[5] + m[7], - m[9] + m[11], - m[13] + m[15] - ); - } - } -} \ No newline at end of file diff --git a/Main.as b/src/Main.as old mode 100755 new mode 100644 similarity index 98% rename from Main.as rename to src/Main.as index c80d6e6..fcc463e --- a/Main.as +++ b/src/Main.as @@ -1,155 +1,155 @@ package { import __AS3__.vec.Vector; import flash.display.Graphics; import flash.display.GraphicsTrianglePath; import flash.display.IGraphicsData; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.geom.Rectangle; import flash.geom.Vector3D; import net.hires.debug.Stats; import org.papervision3d.cameras.Camera3D; import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.ns.pv3d; import org.papervision3d.core.render.clipping.SutherlandHodgmanClipper; import org.papervision3d.core.render.data.RenderData; import org.papervision3d.core.render.draw.items.TriangleDrawable; import org.papervision3d.core.render.draw.list.DrawableList; import org.papervision3d.core.render.pipeline.BasicPipeline; import org.papervision3d.materials.WireframeMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.Viewport3D; [SWF (backgroundColor="#000000")] public class Main extends Sprite { use namespace pv3d; public var container :Sprite; public var vertexGeometry :VertexGeometry; public var cube :Cube; public var camera :Camera3D; public var pipeline :BasicPipeline; public var viewport :Rectangle; public var scene :DisplayObject3D; public var renderData :RenderData; public var renderer :BasicRenderEngine; public function Main() { init(); } private function init():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.frameRate = 60; stage.quality = StageQuality.LOW; var aspect :Number = stage.stageWidth / stage.stageHeight; container = new Sprite(); addChild(container); container.x = stage.stageWidth / 2; container.y = stage.stageHeight / 2; addChild(new Stats()); - camera = new Camera3D(20, 400, 2300, aspect, "Camera01"); + camera = new Camera3D(20, 400, 2300, "Camera01"); pipeline = new BasicPipeline(); cube = new Cube(new WireframeMaterial(), 100, "Cube"); var cubeChild0 :Cube = new Cube(new WireframeMaterial(0xFF0000), 100, "red"); cube.addChild( cubeChild0 ); cubeChild0.x = 300; //cubeChild0.z = -500; var cubeChild1 :Cube = new Cube(new WireframeMaterial(0x00FF00), 100, "blue"); cube.addChild( cubeChild1 ); cubeChild1.z = 200; var cubeChild2 :Cube = new Cube(new WireframeMaterial(0x0000FF), 100, "green"); cube.addChild( cubeChild2 ); cubeChild2.y = 200; cubeChild2.z = 10; scene = new DisplayObject3D("Scene"); scene.addChild( camera ); scene.addChild( cube ); camera.z = 800; renderData = new RenderData(); renderData.camera = camera; renderData.scene = scene; renderData.drawlist = new DrawableList(); renderData.viewport = new Viewport3D(0, 0, true); renderer = new BasicRenderEngine(); addChild(renderData.viewport); // render(); var clipper:SutherlandHodgmanClipper; addEventListener(Event.ENTER_FRAME, render); } private var _r :Number = 0; private var _s :Number = 0; private function render(event:Event=null):void { // rotation in global frame of reference : append // cube.x ++; // cube.rotationY--; //cube.getChildByName("blue").x += 0.1; //cube.getChildByName("blue").rotationZ--; //cube.getChildByName("blue").lookAt( cube.getChildByName("red") ); cube.getChildByName("green").lookAt( cube.getChildByName("red") ); cube.getChildByName("red").rotateAround(_s++, new Vector3D(0, 0, _s)); // cube.getChildByName("red").scaleX = 2; cube.getChildByName("red").rotationX += 3; // cube.getChildByName("green").rotateAround(_r++, Vector3D.X_AXIS); camera.x = Math.sin(_r) * 950; camera.y = 500; camera.z = Math.cos(_r) * 950; _r += Math.PI / 180; camera.lookAt(cube); //camera.lookAt( cube.getChildByName("blue") ); //trace(cube.getChildByName("red").transform.position); renderer.renderScene(renderData); //renderScene(renderData.viewport.containerSprite.graphics, scene); //trace((drawArray[1] as GraphicsTrianglePath).vertices); } } } diff --git a/net/hires/debug/Stats.as b/src/net/hires/debug/Stats.as similarity index 100% rename from net/hires/debug/Stats.as rename to src/net/hires/debug/Stats.as diff --git a/src/org/papervision3d/cameras/Camera3D.as b/src/org/papervision3d/cameras/Camera3D.as new file mode 100755 index 0000000..d2fc91b --- /dev/null +++ b/src/org/papervision3d/cameras/Camera3D.as @@ -0,0 +1,215 @@ +package org.papervision3d.cameras +{ + import flash.geom.Matrix3D; + import flash.geom.Rectangle; + + import org.papervision3d.core.math.Frustum3D; + import org.papervision3d.core.math.utils.MatrixUtil; + import org.papervision3d.core.ns.pv3d; + import org.papervision3d.objects.DisplayObject3D; + + /** + * + */ + public class Camera3D extends DisplayObject3D + { + use namespace pv3d; + + public var projectionMatrix :Matrix3D; + public var viewMatrix :Matrix3D; + public var frustum :Frustum3D; + + private var _dirty:Boolean; + private var _fov:Number; + private var _far:Number; + private var _near:Number; + private var _ortho:Boolean; + private var _orthoScale:Number; + private var _aspectRatio :Number; + private var _enableCulling :Boolean; + private var _worldCullingMatrix :Matrix3D; + + /** + * Constructor. + * + * @param fov + * @param near + * @param far + * @param name + */ + public function Camera3D(fov:Number=60, near:Number=1, far:Number=10000, name:String=null) + { + super(name); + + _fov = fov; + _near = near; + _far = far; + _dirty = true; + _ortho = false; + _orthoScale = 1; + _enableCulling = false; + _worldCullingMatrix = new Matrix3D(); + + frustum = new Frustum3D(this); + viewMatrix = new Matrix3D(); + } + + /** + * + */ + public function update(viewport:Rectangle) : void + { + var aspect :Number = viewport.width / viewport.height; + + viewMatrix.rawData = transform.worldTransform.rawData; + viewMatrix.invert(); + + if (_aspectRatio != aspect) + { + _aspectRatio = aspect; + _dirty = true; + } + + if(_dirty) + { + _dirty = false; + + if(_ortho) + { + projectionMatrix = MatrixUtil.createOrthoMatrix(-viewport.width, viewport.width, viewport.height, -viewport.height, _far, -_far); + } + else + { + + projectionMatrix = MatrixUtil.createProjectionMatrix(_fov, _aspectRatio, _near, _far); + + } + + // extract the view clipping planes + frustum.extractPlanes(projectionMatrix, frustum.viewClippingPlanes); + } + + // TODO: sniff whether our transform was dirty, no need to calc when can didn't move. + if (_enableCulling) + { + _worldCullingMatrix.rawData = viewMatrix.rawData; + _worldCullingMatrix.append(projectionMatrix); + + // TODO: why this is needed is weird. If we don't the culling / clipping planes don't + // seem to match. With this hack all ok... + // Tim: Think its got to do with a discrepancy between GL viewport and + // our draw-container sitting at center stage. + _worldCullingMatrix.prependScale(0.5, 0.5, 0.5); + + // extract the world clipping planes + frustum.extractPlanes(_worldCullingMatrix, frustum.worldClippingPlanes, false); + } + } + + /** + * + */ + public function get aspectRatio():Number + { + return _aspectRatio; + } + + /** + * + */ + public function get enableCulling():Boolean + { + return _enableCulling; + } + + public function set enableCulling(value:Boolean):void + { + _enableCulling = value; + } + + /** + * Distance to the far clipping plane. + */ + public function get far():Number + { + return _far; + } + + public function set far(value:Number):void + { + if (value != _far && value > _near) + { + _far = value; + _dirty = true; + } + } + + /** + * Field of view (vertical) in degrees. + */ + public function get fov():Number + { + return _fov; + } + + public function set fov(value:Number):void + { + if (value != _fov) + { + _fov = value; + _dirty = true; + } + } + + /** + * Distance to the near clipping plane. + */ + public function get near():Number + { + return _near; + } + + public function set near(value:Number):void + { + if (value != _near && value > 0 && value < _far) + { + _near = value; + _dirty = true; + } + } + + /** + * Whether to use a orthogonal projection. + */ + public function get ortho():Boolean + { + return _ortho; + } + + public function set ortho(value:Boolean):void + { + if (value != _ortho) + { + _ortho = value; + _dirty = true; + } + } + + /** + * Scale of the orthogonal projection. + */ + public function get orthoScale():Number + { + return _orthoScale; + } + + public function set orthoScale(value:Number):void + { + if (value != _orthoScale) + { + _orthoScale = value; + _dirty = true; + } + } + } +} \ No newline at end of file diff --git a/org/papervision3d/core/geom/Geometry.as b/src/org/papervision3d/core/geom/Geometry.as similarity index 100% rename from org/papervision3d/core/geom/Geometry.as rename to src/org/papervision3d/core/geom/Geometry.as diff --git a/org/papervision3d/core/geom/Triangle.as b/src/org/papervision3d/core/geom/Triangle.as similarity index 100% rename from org/papervision3d/core/geom/Triangle.as rename to src/org/papervision3d/core/geom/Triangle.as diff --git a/org/papervision3d/core/geom/UVCoord.as b/src/org/papervision3d/core/geom/UVCoord.as similarity index 100% rename from org/papervision3d/core/geom/UVCoord.as rename to src/org/papervision3d/core/geom/UVCoord.as diff --git a/org/papervision3d/core/geom/Vertex.as b/src/org/papervision3d/core/geom/Vertex.as similarity index 100% rename from org/papervision3d/core/geom/Vertex.as rename to src/org/papervision3d/core/geom/Vertex.as diff --git a/org/papervision3d/core/geom/provider/TriangleGeometry.as b/src/org/papervision3d/core/geom/provider/TriangleGeometry.as similarity index 100% rename from org/papervision3d/core/geom/provider/TriangleGeometry.as rename to src/org/papervision3d/core/geom/provider/TriangleGeometry.as diff --git a/org/papervision3d/core/geom/provider/VertexGeometry.as b/src/org/papervision3d/core/geom/provider/VertexGeometry.as similarity index 100% rename from org/papervision3d/core/geom/provider/VertexGeometry.as rename to src/org/papervision3d/core/geom/provider/VertexGeometry.as diff --git a/src/org/papervision3d/core/math/AABoundingBox3D.as b/src/org/papervision3d/core/math/AABoundingBox3D.as new file mode 100644 index 0000000..d32ae12 --- /dev/null +++ b/src/org/papervision3d/core/math/AABoundingBox3D.as @@ -0,0 +1,79 @@ +package org.papervision3d.core.math +{ + import flash.geom.Vector3D; + + import org.papervision3d.core.geom.Vertex; + + public class AABoundingBox3D + { + /** */ + public var origin :Vector3D; + + /** */ + public var min :Vector3D; + + /** */ + public var max :Vector3D; + + /** + * Constructor. + */ + public function AABoundingBox3D() + { + this.origin = new Vector3D(); + this.min = new Vector3D(); + this.max = new Vector3D(); + } + + /** + * Sets the axis-aligned bounding box from a set of vertices. + * + * @param vertices + */ + public function setFromVertices(vertices:Vector.<Vertex>):void + { + var vertex :Vertex; + + if (!vertices || !vertices.length) + { + min.x = min.y = min.z = 0; + max.x = max.y = max.z = 0; + } + else + { + min.x = min.y = min.z = Number.MAX_VALUE; + max.x = max.y = max.z = -Number.MAX_VALUE; + + for each (vertex in vertices) + { + min.x = Math.min(min.x, vertex.x); + min.y = Math.min(min.y, vertex.y); + min.z = Math.min(min.z, vertex.z); + max.x = Math.max(max.x, vertex.x); + max.y = Math.max(max.y, vertex.y); + max.z = Math.max(max.z, vertex.z); + } + } + + origin.x = min.x + ((max.x - min.x) * 0.5); + origin.y = min.y + ((max.y - min.y) * 0.5); + origin.z = min.z + ((max.z - min.z) * 0.5); + } + + /** + * Creates a axis-aligned bounding box from a set of vertices. + * + * @param vertices + * + * @return The created bounding box. + */ + public static function createFromVertices(vertices:Vector.<Vertex>):AABoundingBox3D + { + var bbox :AABoundingBox3D = new AABoundingBox3D(); + + bbox.setFromVertices(vertices); + + return bbox; + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/math/BoundingSphere3D.as b/src/org/papervision3d/core/math/BoundingSphere3D.as new file mode 100644 index 0000000..1637cd2 --- /dev/null +++ b/src/org/papervision3d/core/math/BoundingSphere3D.as @@ -0,0 +1,119 @@ +package org.papervision3d.core.math +{ + import flash.geom.Vector3D; + + import org.papervision3d.core.geom.Vertex; + + public class BoundingSphere3D + { + /** */ + public var origin :Vector3D; + + /** */ + public var worldOrigin :Vector3D; + + /** */ + public var radius :Number; + + /** */ + public var worldRadius :Number; + + /** */ + private var _bbox :AABoundingBox3D; + + /** + * + */ + public function BoundingSphere3D(origin:Vector3D=null, radius:Number=0) + { + this.origin = origin || new Vector3D(); + this.worldOrigin = this.origin.clone(); + this.radius = radius; + this.worldRadius = radius; + } + + /** + * + */ + public function intersects(sphere:BoundingSphere3D):Boolean + { + // get the separating axis + var sepAxis :Vector3D = this.origin.subtract(sphere.worldOrigin); + //Vector3f vSepAxis = this->Center() - refSphere.Center(); + + // get the sum of the radii + var radiiSum :Number = this.radius + sphere.worldRadius; + //float fRadiiSum = this->Radius() + refSphere.Radius(); + + trace( sepAxis.lengthSquared + " " + (radiiSum*radiiSum)); + // if the distance between the centers is less than the sum + // of the radii, then we have an intersection + // we calculate this using the squared lengths for speed + if (sepAxis.lengthSquared < (radiiSum * radiiSum)) + return true; + //if(vSepAxis.getSqLength() < (fRadiiSum * fRadiiSum)) + // return(true); + // otherwise they are separated + return false; + } + /** + * + */ + public function setFromVertices(vertices:Vector.<Vertex>, fast:Boolean=true):void + { + var v:Vertex; + if (fast) + { + if (_bbox) + { + _bbox.setFromVertices(vertices); + } + else + { + _bbox = AABoundingBox3D.createFromVertices(vertices); + } + + origin.x = _bbox.origin.x; + origin.y = _bbox.origin.y; + origin.z = _bbox.origin.z; + + radius = _bbox.max.subtract(origin).length; + } + else + { + var vertex :Vector3D, dist :Vector3D; + var temp :Number, radiusSqr :Number = 0; + var n :int = 1 / vertices.length; + + origin.x = origin.y = origin.z = 0; + + for each (vertex in vertices) + { + origin.x += vertex.x; + origin.y += vertex.y; + origin.z += vertex.z; + } + + origin.x *= n; + origin.y *= n; + origin.z *= n; + + for each (vertex in vertices) + { + dist.x = vertex.x - origin.x; + dist.y = vertex.y - origin.y; + dist.z = vertex.z - origin.z; + + temp = dist.x * dist.x + dist.y * dist.y + dist.z * dist.z; + + if (temp > radiusSqr) + { + radiusSqr = temp; + } + } + + radius = Math.sqrt(radiusSqr); + } + } + } +} \ No newline at end of file diff --git a/src/org/papervision3d/core/math/Frustum3D.as b/src/org/papervision3d/core/math/Frustum3D.as new file mode 100644 index 0000000..9308eef --- /dev/null +++ b/src/org/papervision3d/core/math/Frustum3D.as @@ -0,0 +1,138 @@ +package org.papervision3d.core.math +{ + import flash.geom.Matrix3D; + import flash.geom.Vector3D; + + import org.papervision3d.cameras.Camera3D; + + public class Frustum3D + { + public static const WORLD_PLANES :uint = 0; + public static const VIEW_PLANES :uint = 1; + public static const SCREEN_PLANES :uint = 2; + + public static const NEAR :uint = 0; + public static const FAR :uint = 1; + public static const LEFT :uint = 2; + public static const RIGHT :uint = 3; + public static const TOP :uint = 4; + public static const BOTTOM :uint = 5; + + public var camera :Camera3D; + public var screenClippingPlanes :Vector.<Plane3D>; + public var viewClippingPlanes :Vector.<Plane3D>; + public var worldClippingPlanes :Vector.<Plane3D>; + + public var worldBoundingSphere :BoundingSphere3D; + + /** + * + */ + public function Frustum3D(camera:Camera3D) + { + this.camera = camera; + this.worldBoundingSphere = new BoundingSphere3D(); + initPlanes(); + } + + /** + * + */ + protected function initPlanes():void + { + var i :int; + + this.screenClippingPlanes = new Vector.<Plane3D>(6, true); + this.viewClippingPlanes = new Vector.<Plane3D>(6, true); + this.worldClippingPlanes = new Vector.<Plane3D>(6, true); + + for (i = 0; i < 6; i++) + { + this.screenClippingPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); + this.viewClippingPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); + this.worldClippingPlanes[i] = Plane3D.fromCoefficients(0, 0, 1, 0); + } + + this.screenClippingPlanes[ NEAR ].setCoefficients(0, 0, -1, 1); + this.screenClippingPlanes[ FAR ].setCoefficients(0, 0, 1, 1); + this.screenClippingPlanes[ LEFT ].setCoefficients(1, 0, 0, 1); + this.screenClippingPlanes[ RIGHT ].setCoefficients(-1, 0, 0, 1); + this.screenClippingPlanes[ TOP ].setCoefficients(0, -1, 0, 1); + this.screenClippingPlanes[ BOTTOM ].setCoefficients(0, 1, 0, 1); + } + + /** + * Extract frustum planes. + * + * @param matrix The matrix to extract the planes from (P for eye-space, M*P for world-space). + * @param planes The planes to extract to. + * @param normalize Whether to normalize the planes. Default is true. + * @param flipNormals Whether to flip the plane normals. Default is true. + * NDC is lefthanded (looking down +Z), eye-space is righthanded (looking down -Z). + * Setting @flipNormals to true makes the frustum looking down +Z. + */ + public function extractPlanes(matrix:Matrix3D, planes:Vector.<Plane3D>, normalize:Boolean=true, + flipNormals:Boolean=false) : void { + var m :Vector.<Number> = matrix.rawData; + var i :int; + + planes[TOP].setCoefficients( + -m[1] + m[3], + -m[5] + m[7], + -m[9] + m[11], + -m[13] + m[15] + ); + + planes[BOTTOM].setCoefficients( + m[1] + m[3], + m[5] + m[7], + m[9] + m[11], + m[13] + m[15] + ); + + planes[LEFT].setCoefficients( + m[0] + m[3], + m[4] + m[7], + m[8] + m[11], + m[12] + m[15] + ); + + planes[RIGHT].setCoefficients( + -m[0] + m[3], + -m[4] + m[7], + -m[8] + m[11], + -m[12] + m[15] + ); + + planes[NEAR].setCoefficients( + m[2] + m[3], + m[6] + m[7], + m[10] + m[11], + m[14] + m[15] + ); + + planes[FAR].setCoefficients( + -m[2] + m[3], + -m[6] + m[7], + -m[10] + m[11], + -m[14] + m[15] + ); + + if(normalize) + { + for (i = 0; i < 6; i++) + { + planes[i].normalize(); + } + } + + if(flipNormals) + { + for (i = 0; i < 6; i++) + { + planes[i].normal.negate(); + } + } + } + } +} \ No newline at end of file diff --git a/org/papervision3d/core/math/Plane3D.as b/src/org/papervision3d/core/math/Plane3D.as similarity index 100% rename from org/papervision3d/core/math/Plane3D.as rename to src/org/papervision3d/core/math/Plane3D.as diff --git a/org/papervision3d/core/math/Quaternion.as b/src/org/papervision3d/core/math/Quaternion.as similarity index 95% rename from org/papervision3d/core/math/Quaternion.as rename to src/org/papervision3d/core/math/Quaternion.as index fa50439..8d5cd79 100755 --- a/org/papervision3d/core/math/Quaternion.as +++ b/src/org/papervision3d/core/math/Quaternion.as @@ -1,527 +1,514 @@ package org.papervision3d.core.math { import flash.geom.Matrix3D; import flash.geom.Vector3D; /** * @author Tim Knip / floorplanner.com */ public class Quaternion { private var _matrix:Matrix3D; public static const EPSILON:Number = 0.000001; public static const DEGTORAD:Number = (Math.PI/180.0); public static const RADTODEG:Number = (180.0/Math.PI); /** */ public var x:Number; /** */ public var y:Number; /** */ public var z:Number; /** */ public var w:Number; /** * constructor. * * @param x * @param y * @param z * @param w * @return */ public function Quaternion( x:Number = 0, y:Number = 0, z:Number = 0, w:Number = 1 ) { this.x = x; this.y = y; this.z = z; this.w = w; _matrix = new Matrix3D(); } /** * Clone. * */ public function clone():Quaternion { return new Quaternion(this.x, this.y, this.z, this.w); } /** * Multiply. * * @param a * @param b */ public function calculateMultiply( a:Quaternion, b:Quaternion ):void { this.x = a.w*b.x + a.x*b.w + a.y*b.z - a.z*b.y; this.y = a.w*b.y - a.x*b.z + a.y*b.w + a.z*b.x; this.z = a.w*b.z + a.x*b.y - a.y*b.x + a.z*b.w; this.w = a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z; } /** * Creates a Quaternion from a axis and a angle. * * @param x X-axis * @param y Y-axis * @param z Z-axis * @param angle angle in radians. * * @return */ public function setFromAxisAngle( x:Number, y:Number, z:Number, angle:Number ):void { var sin:Number = Math.sin( angle / 2 ); var cos:Number = Math.cos( angle / 2 ); this.x = x * sin; this.y = y * sin; this.z = z * sin; this.w = cos; this.normalize(); } /** * Sets this Quaternion from Euler angles. * * @param ax X-angle in radians. * @param ay Y-angle in radians. * @param az Z-angle in radians. */ public function setFromEuler(ax:Number, ay:Number, az:Number, useDegrees:Boolean=false):void { if( useDegrees ) { ax *= DEGTORAD; ay *= DEGTORAD; az *= DEGTORAD; } var fSinPitch :Number = Math.sin( ax * 0.5 ); var fCosPitch :Number = Math.cos( ax * 0.5 ); var fSinYaw :Number = Math.sin( ay * 0.5 ); var fCosYaw :Number = Math.cos( ay * 0.5 ); var fSinRoll :Number = Math.sin( az * 0.5 ); var fCosRoll :Number = Math.cos( az * 0.5 ); var fCosPitchCosYaw :Number = fCosPitch * fCosYaw; var fSinPitchSinYaw :Number = fSinPitch * fSinYaw; this.x = fSinRoll * fCosPitchCosYaw - fCosRoll * fSinPitchSinYaw; this.y = fCosRoll * fSinPitch * fCosYaw + fSinRoll * fCosPitch * fSinYaw; this.z = fCosRoll * fCosPitch * fSinYaw - fSinRoll * fSinPitch * fCosYaw; this.w = fCosRoll * fCosPitchCosYaw + fSinRoll * fSinPitchSinYaw; } + public function setFromMatrix(matrix:Matrix3D):void + { + var quat:Quaternion = this; + + var v :Vector.<Number> = matrix.rawData; + var s:Number; + var q:Array = new Array(4); + var i:int, j:int, k:int; + + var tr :Number = v[0] + v[5] + v[10]; + + // check the diagonal + if (tr > 0.0) + { + s = Math.sqrt(tr + 1.0); + quat.w = s / 2.0; + s = 0.5 / s; + + quat.x = (v[9] - v[6]) * s; + quat.y = (v[2] - v[8]) * s; + quat.z = (v[4] - v[1]) * s; + } + else + { + // diagonal is negative + var nxt:Array = [1, 2, 0]; + + var m:Array = [ + [v[0], v[1], v[2], v[3]], + [v[4], v[5], v[6], v[7]], + [v[8], v[9], v[10], v[11]] + ]; + + i = 0; + + if (m[1][1] > m[0][0]) i = 1; + if (m[2][2] > m[i][i]) i = 2; + + j = nxt[i]; + k = nxt[j]; + s = Math.sqrt((m[i][i] - (m[j][j] + m[k][k])) + 1.0); + + q[i] = s * 0.5; + + if (s != 0.0) s = 0.5 / s; + + q[3] = (m[k][j] - m[j][k]) * s; + q[j] = (m[j][i] + m[i][j]) * s; + q[k] = (m[k][i] + m[i][k]) * s; + + quat.x = q[0]; + quat.y = q[1]; + quat.z = q[2]; + quat.w = q[3]; + } + } + /** * Modulo. * * @param a * @return */ public function get modulo():Number { return Math.sqrt(x*x + y*y + z*z + w*w); } /** * Conjugate. * * @param a * @return */ public static function conjugate( a:Quaternion ):Quaternion { var q:Quaternion = new Quaternion(); q.x = -a.x; q.y = -a.y; q.z = -a.z; q.w = a.w; return q; } /** * Creates a Quaternion from a axis and a angle. * * @param x X-axis * @param y Y-axis * @param z Z-axis * @param angle angle in radians. * * @return */ public static function createFromAxisAngle( x:Number, y:Number, z:Number, angle:Number ):Quaternion { var q:Quaternion = new Quaternion(); q.setFromAxisAngle(x, y, z, angle); return q; } /** * Creates a Quaternion from Euler angles. * * @param ax X-angle in radians. * @param ay Y-angle in radians. * @param az Z-angle in radians. * * @return */ public static function createFromEuler( ax:Number, ay:Number, az:Number, useDegrees:Boolean = false ):Quaternion { if( useDegrees ) { ax *= DEGTORAD; ay *= DEGTORAD; az *= DEGTORAD; } var fSinPitch :Number = Math.sin( ax * 0.5 ); var fCosPitch :Number = Math.cos( ax * 0.5 ); var fSinYaw :Number = Math.sin( ay * 0.5 ); var fCosYaw :Number = Math.cos( ay * 0.5 ); var fSinRoll :Number = Math.sin( az * 0.5 ); var fCosRoll :Number = Math.cos( az * 0.5 ); var fCosPitchCosYaw :Number = fCosPitch * fCosYaw; var fSinPitchSinYaw :Number = fSinPitch * fSinYaw; var q:Quaternion = new Quaternion(); q.x = fSinRoll * fCosPitchCosYaw - fCosRoll * fSinPitchSinYaw; q.y = fCosRoll * fSinPitch * fCosYaw + fSinRoll * fCosPitch * fSinYaw; q.z = fCosRoll * fCosPitch * fSinYaw - fSinRoll * fSinPitch * fCosYaw; q.w = fCosRoll * fCosPitchCosYaw + fSinRoll * fSinPitchSinYaw; return q; } /** * Creates a Quaternion from a matrix. * * @param matrix a matrix. @see org.papervision3d.core.Matrix3D * * @return the created Quaternion */ public static function createFromMatrix( matrix:Matrix3D ):Quaternion { var quat:Quaternion = new Quaternion(); - var v :Vector.<Number> = matrix.rawData; - var s:Number; - var q:Array = new Array(4); - var i:int, j:int, k:int; - - /* - 0 1 2 3 - 4 5 6 7 - 8 9 10 11 - 12 13 14 15 - - 11 12 13 14 - 21 22 23 24 - 31 32 33 34 - 41 42 43 44 - */ - //var tr:Number = matrix.n11 + matrix.n22 + matrix.n33; - var tr :Number = v[0] + v[5] + v[10]; + quat.setFromMatrix(matrix); - // check the diagonal - if (tr > 0.0) - { - s = Math.sqrt(tr + 1.0); - quat.w = s / 2.0; - s = 0.5 / s; - - quat.x = (v[9] - v[6]) * s; - quat.y = (v[2] - v[8]) * s; - quat.z = (v[4] - v[1]) * s; - //quat.x = (matrix.n32 - matrix.n23) * s; - //quat.y = (matrix.n13 - matrix.n31) * s; - //quat.z = (matrix.n21 - matrix.n12) * s; - } - else - { - // diagonal is negative - var nxt:Array = [1, 2, 0]; - /* - var m:Array = [ - [matrix.n11, matrix.n12, matrix.n13, matrix.n14], - [matrix.n21, matrix.n22, matrix.n23, matrix.n24], - [matrix.n31, matrix.n32, matrix.n33, matrix.n34] - ]; - */ - var m:Array = [ - [v[0], v[1], v[2], v[3]], - [v[4], v[5], v[6], v[7]], - [v[8], v[9], v[10], v[11]] - ]; - - i = 0; - - if (m[1][1] > m[0][0]) i = 1; - if (m[2][2] > m[i][i]) i = 2; - - j = nxt[i]; - k = nxt[j]; - s = Math.sqrt((m[i][i] - (m[j][j] + m[k][k])) + 1.0); - - q[i] = s * 0.5; - - if (s != 0.0) s = 0.5 / s; - - q[3] = (m[k][j] - m[j][k]) * s; - q[j] = (m[j][i] + m[i][j]) * s; - q[k] = (m[k][i] + m[i][k]) * s; - - quat.x = q[0]; - quat.y = q[1]; - quat.z = q[2]; - quat.w = q[3]; - } return quat; } /** * Creates a Quaternion from a orthonormal matrix. * * @param m a orthonormal matrix. @see org.papervision3d.core.Matrix3D * * @return the created Quaternion */ public static function createFromOrthoMatrix( m:Matrix3D ):Quaternion { var q:Quaternion = new Quaternion(); /* q.w = Math.sqrt( Math.max(0, 1 + m.n11 + m.n22 + m.n33) ) / 2; q.x = Math.sqrt( Math.max(0, 1 + m.n11 - m.n22 - m.n33) ) / 2; q.y = Math.sqrt( Math.max(0, 1 - m.n11 + m.n22 - m.n33) ) / 2; q.z = Math.sqrt( Math.max(0, 1 - m.n11 - m.n22 + m.n33) ) / 2; // recover signs q.x = m.n32 - m.n23 < 0 ? (q.x < 0 ? q.x : -q.x) : (q.x < 0 ? -q.x : q.x); q.y = m.n13 - m.n31 < 0 ? (q.y < 0 ? q.y : -q.y) : (q.y < 0 ? -q.y : q.y); q.z = m.n21 - m.n12 < 0 ? (q.z < 0 ? q.z : -q.z) : (q.z < 0 ? -q.z : q.z); */ return q; } /** * Dot product. * * @param a * @param b * * @return */ public static function dot( a:Quaternion, b:Quaternion ):Number { return (a.x * b.x) + (a.y * b.y) + (a.z * b.z) + (a.w * b.w); } /** * Multiply. * * @param a * @param b * @return */ public static function multiply( a:Quaternion, b:Quaternion ):Quaternion { var c:Quaternion = new Quaternion(); c.x = a.w*b.x + a.x*b.w + a.y*b.z - a.z*b.y; c.y = a.w*b.y - a.x*b.z + a.y*b.w + a.z*b.x; c.z = a.w*b.z + a.x*b.y - a.y*b.x + a.z*b.w; c.w = a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z; return c; } /** * Multiply by another Quaternion. * * @param b The Quaternion to multiply by. */ public function mult( b:Quaternion ):void { var aw:Number = this.w, ax:Number = this.x, ay:Number = this.y, az:Number = this.z; x = aw*b.x + ax*b.w + ay*b.z - az*b.y; y = aw*b.y - ax*b.z + ay*b.w + az*b.x; z = aw*b.z + ax*b.y - ay*b.x + az*b.w; w = aw*b.w - ax*b.x - ay*b.y - az*b.z; } public function toString():String{ return "Quaternion: x:"+this.x+" y:"+this.y+" z:"+this.z+" w:"+this.w; } /** * Normalize. * * @param a * * @return */ public function normalize():void { var len:Number = this.modulo; if( Math.abs(len) < EPSILON ) { x = y = z = 0.0; w = 1.0; } else { var m:Number = 1 / len; x *= m; y *= m; z *= m; w *= m; } } /** * SLERP (Spherical Linear intERPolation). @author Trevor Burton * * @param qa start quaternion * @param qb end quaternion * @param alpha a value between 0 and 1 * * @return the interpolated quaternion. */ public static function slerp( qa:Quaternion, qb:Quaternion, alpha:Number ):Quaternion { var angle:Number = qa.w * qb.w + qa.x * qb.x + qa.y * qb.y + qa.z * qb.z; if (angle < 0.0) { qa.x *= -1.0; qa.y *= -1.0; qa.z *= -1.0; qa.w *= -1.0; angle *= -1.0; } var scale:Number; var invscale:Number; if ((angle + 1.0) > EPSILON) // Take the shortest path { if ((1.0 - angle) >= EPSILON) // spherical interpolation { var theta:Number = Math.acos(angle); var invsintheta:Number = 1.0 / Math.sin(theta); scale = Math.sin(theta * (1.0-alpha)) * invsintheta; invscale = Math.sin(theta * alpha) * invsintheta; } else // linear interploation { scale = 1.0 - alpha; invscale = alpha; } } else // long way to go... { qb.y = -qa.y; qb.x = qa.x; qb.w = -qa.w; qb.z = qa.z; scale = Math.sin(Math.PI * (0.5 - alpha)); invscale = Math.sin(Math.PI * alpha); } return new Quaternion( scale * qa.x + invscale * qb.x, scale * qa.y + invscale * qb.y, scale * qa.z + invscale * qb.z, scale * qa.w + invscale * qb.w ); } public function toEuler():Vector3D { var euler :Vector3D = new Vector3D(); var q1 :Quaternion = this; var test :Number = q1.x*q1.y + q1.z*q1.w; if (test > 0.499) { // singularity at north pole euler.x = 2 * Math.atan2(q1.x,q1.w); euler.y = Math.PI/2; euler.z = 0; return euler; } if (test < -0.499) { // singularity at south pole euler.x = -2 * Math.atan2(q1.x,q1.w); euler.y = - Math.PI/2; euler.z = 0; return euler; } var sqx :Number = q1.x*q1.x; var sqy :Number = q1.y*q1.y; var sqz :Number = q1.z*q1.z; euler.x = Math.atan2(2*q1.y*q1.w-2*q1.x*q1.z , 1 - 2*sqy - 2*sqz); euler.y = Math.asin(2*test); euler.z = Math.atan2(2*q1.x*q1.w-2*q1.y*q1.z , 1 - 2*sqx - 2*sqz); return euler; } /** * Gets the matrix representation of this Quaternion. * * @return matrix. @see org.papervision3d.core.Matrix3D */ public function get matrix():Matrix3D { var xx:Number = x * x; var xy:Number = x * y; var xz:Number = x * z; var xw:Number = x * w; var yy:Number = y * y; var yz:Number = y * z; var yw:Number = y * w; var zz:Number = z * z; var zw:Number = z * w; var v :Vector.<Number> = _matrix.rawData; v[0] = 1 - 2 * ( yy + zz ); v[1] = 2 * ( xy - zw ); v[2] = 2 * ( xz + yw ); v[4] = 2 * ( xy + zw ); v[5] = 1 - 2 * ( xx + zz ); v[6] = 2 * ( yz - xw ); v[8] = 2 * ( xz - yw ); v[9] = 2 * ( yz + xw ); v[10] = 1 - 2 * ( xx + yy ); _matrix.rawData = v; return _matrix; } public static function sub(a:Quaternion, b:Quaternion):Quaternion { return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } public static function add(a:Quaternion, b:Quaternion):Quaternion { return new Quaternion(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } } } \ No newline at end of file diff --git a/org/papervision3d/core/math/utils/MathUtil.as b/src/org/papervision3d/core/math/utils/MathUtil.as similarity index 100% rename from org/papervision3d/core/math/utils/MathUtil.as rename to src/org/papervision3d/core/math/utils/MathUtil.as diff --git a/src/org/papervision3d/core/math/utils/MatrixUtil.as b/src/org/papervision3d/core/math/utils/MatrixUtil.as new file mode 100755 index 0000000..a09f0e2 --- /dev/null +++ b/src/org/papervision3d/core/math/utils/MatrixUtil.as @@ -0,0 +1,186 @@ +package org.papervision3d.core.math.utils +{ + import flash.geom.Matrix3D; + import flash.geom.Vector3D; + + public class MatrixUtil + { + private static var _f :Vector3D = new Vector3D(); + private static var _s :Vector3D = new Vector3D(); + private static var _u :Vector3D = new Vector3D(); + + /** + * + */ + public static function createLookAtMatrix(eye:Vector3D, target:Vector3D, up:Vector3D, resultMatrix:Matrix3D=null):Matrix3D + { + resultMatrix = resultMatrix || new Matrix3D(); + + _f.x = target.x - eye.x; + _f.y = target.y - eye.y; + _f.z = target.z - eye.z; + _f.normalize(); + + _s.x = (up.y * _f.z) - (up.z * _f.y); + _s.y = (up.z * _f.x) - (up.x * _f.z); + _s.z = (up.x * _f.y) - (up.y * _f.x); + _s.normalize(); + + _u.x = (_s.y * _f.z) - (_s.z * _f.y); + _u.y = (_s.z * _f.x) - (_s.x * _f.z); + _u.z = (_s.x * _f.y) - (_s.y * _f.x); + _u.normalize(); + + resultMatrix.rawData = Vector.<Number>([ + _s.x, _s.y, _s.z, 0, + _u.x, _u.y, _u.z, 0, + -_f.x, -_f.y, -_f.z, 0, + 0, 0, 0, 1 + ]); + + return resultMatrix; + } + + /** + * Creates a projection matrix. + * + * @param fovY + * @param aspectRatio + * @param near + * @param far + */ + public static function createProjectionMatrix(fovy:Number, aspect:Number, zNear:Number, zFar:Number):Matrix3D + { + var sine :Number, cotangent :Number, deltaZ :Number; + var radians :Number = (fovy / 2) * (Math.PI / 180); + + deltaZ = zFar - zNear; + sine = Math.sin(radians); + if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) + { + return null; + } + cotangent = Math.cos(radians) / sine; + + var v:Vector.<Number> = Vector.<Number>([ + cotangent / aspect, 0, 0, 0, + 0, cotangent, 0, 0, + 0, 0, -(zFar + zNear) / deltaZ, -1, + 0, 0, -(2 * zFar * zNear) / deltaZ, 0 + ]); + return new Matrix3D(v); + } + + /** + * + */ + public static function createOrthoMatrix(left:Number, right:Number, top:Number, bottom:Number, zNear:Number, zFar:Number) : Matrix3D { + var tx :Number = (right + left) / (right - left); + var ty :Number = (top + bottom) / (top - bottom); + var tz :Number = (zFar+zNear) / (zFar-zNear); + var v:Vector.<Number> = Vector.<Number>([ + 2 / (right - left), 0, 0, 0, + 0, 2 / (top - bottom), 0, 0, + 0, 0, -2 / (zFar-zNear), 0, + tx, ty, tz, 1 + ]); + return new Matrix3D(v); + } + + public static function __gluMakeIdentityd(m : Vector.<Number>) :void { + m[0+4*0] = 1; m[0+4*1] = 0; m[0+4*2] = 0; m[0+4*3] = 0; + m[1+4*0] = 0; m[1+4*1] = 1; m[1+4*2] = 0; m[1+4*3] = 0; + m[2+4*0] = 0; m[2+4*1] = 0; m[2+4*2] = 1; m[2+4*3] = 0; + m[3+4*0] = 0; m[3+4*1] = 0; m[3+4*2] = 0; m[3+4*3] = 1; + } + + public static function __gluMultMatricesd(a:Vector.<Number>, b:Vector.<Number>, r:Vector.<Number>):void { + var i :int, j :int; + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + r[int(i*4+j)] = + a[int(i*4+0)]*b[int(0*4+j)] + + a[int(i*4+1)]*b[int(1*4+j)] + + a[int(i*4+2)]*b[int(2*4+j)] + + a[int(i*4+3)]*b[int(3*4+j)]; + } + } + } + + public static function __gluMultMatrixVecd(matrix : Vector.<Number>, a : Vector.<Number> , out : Vector.<Number>) : void { + var i :int; + for (i=0; i<4; i++) { + out[i] = + a[0] * matrix[int(0*4+i)] + + a[1] * matrix[int(1*4+i)] + + a[2] * matrix[int(2*4+i)] + + a[3] * matrix[int(3*4+i)]; + } + } + + public static function __gluInvertMatrixd(src : Vector.<Number>, inverse : Vector.<Number>):Boolean { + var i :int, j :int, k :int, swap :int; + var t :Number; + var temp :Vector.<Vector.<Number>> = new Vector.<Vector.<Number>>(4); + + for (i=0; i<4; i++) { + temp[i] = new Vector.<Number>(4, true); + for (j=0; j<4; j++) { + temp[i][j] = src[i*4+j]; + } + } + __gluMakeIdentityd(inverse); + + for (i = 0; i < 4; i++) { + /* + ** Look for largest element in column + */ + swap = i; + for (j = i + 1; j < 4; j++) { + if (Math.abs(temp[j][i]) > Math.abs(temp[i][i])) { + swap = j; + } + } + + if (swap != i) { + /* + ** Swap rows. + */ + for (k = 0; k < 4; k++) { + t = temp[i][k]; + temp[i][k] = temp[swap][k]; + temp[swap][k] = t; + + t = inverse[i*4+k]; + inverse[i*4+k] = inverse[swap*4+k]; + inverse[swap*4+k] = t; + } + } + + if (temp[i][i] == 0) { + /* + ** No non-zero pivot. The matrix is singular, which shouldn't + ** happen. This means the user gave us a bad matrix. + */ + return false; + } + + t = temp[i][i]; + for (k = 0; k < 4; k++) { + temp[i][k] /= t; + inverse[i*4+k] /= t; + } + for (j = 0; j < 4; j++) { + if (j != i) { + t = temp[j][i]; + for (k = 0; k < 4; k++) { + temp[j][k] -= temp[i][k]*t; + inverse[j*4+k] -= inverse[i*4+k]*t; + } + } + } + } + return true; + } + } +} \ No newline at end of file diff --git a/org/papervision3d/core/ns/pv3d.as b/src/org/papervision3d/core/ns/pv3d.as similarity index 100% rename from org/papervision3d/core/ns/pv3d.as rename to src/org/papervision3d/core/ns/pv3d.as diff --git a/org/papervision3d/core/proto/DisplayObjectContainer3D.as b/src/org/papervision3d/core/proto/DisplayObjectContainer3D.as similarity index 100% rename from org/papervision3d/core/proto/DisplayObjectContainer3D.as rename to src/org/papervision3d/core/proto/DisplayObjectContainer3D.as diff --git a/org/papervision3d/core/proto/Transform3D.as b/src/org/papervision3d/core/proto/Transform3D.as similarity index 100% rename from org/papervision3d/core/proto/Transform3D.as rename to src/org/papervision3d/core/proto/Transform3D.as diff --git a/org/papervision3d/core/render/clipping/ClipFlags.as b/src/org/papervision3d/core/render/clipping/ClipFlags.as similarity index 100% rename from org/papervision3d/core/render/clipping/ClipFlags.as rename to src/org/papervision3d/core/render/clipping/ClipFlags.as diff --git a/org/papervision3d/core/render/clipping/IPolygonClipper.as b/src/org/papervision3d/core/render/clipping/IPolygonClipper.as similarity index 100% rename from org/papervision3d/core/render/clipping/IPolygonClipper.as rename to src/org/papervision3d/core/render/clipping/IPolygonClipper.as diff --git a/org/papervision3d/core/render/clipping/SutherlandHodgmanClipper.as b/src/org/papervision3d/core/render/clipping/SutherlandHodgmanClipper.as similarity index 100% rename from org/papervision3d/core/render/clipping/SutherlandHodgmanClipper.as rename to src/org/papervision3d/core/render/clipping/SutherlandHodgmanClipper.as diff --git a/org/papervision3d/core/render/data/RenderData.as b/src/org/papervision3d/core/render/data/RenderData.as similarity index 100% rename from org/papervision3d/core/render/data/RenderData.as rename to src/org/papervision3d/core/render/data/RenderData.as diff --git a/org/papervision3d/core/render/draw/items/AbstractDrawable.as b/src/org/papervision3d/core/render/draw/items/AbstractDrawable.as similarity index 100% rename from org/papervision3d/core/render/draw/items/AbstractDrawable.as rename to src/org/papervision3d/core/render/draw/items/AbstractDrawable.as diff --git a/org/papervision3d/core/render/draw/items/IDrawable.as b/src/org/papervision3d/core/render/draw/items/IDrawable.as similarity index 100% rename from org/papervision3d/core/render/draw/items/IDrawable.as rename to src/org/papervision3d/core/render/draw/items/IDrawable.as diff --git a/org/papervision3d/core/render/draw/items/TriangleDrawable.as b/src/org/papervision3d/core/render/draw/items/TriangleDrawable.as similarity index 100% rename from org/papervision3d/core/render/draw/items/TriangleDrawable.as rename to src/org/papervision3d/core/render/draw/items/TriangleDrawable.as diff --git a/org/papervision3d/core/render/draw/list/AbstractDrawableList.as b/src/org/papervision3d/core/render/draw/list/AbstractDrawableList.as similarity index 100% rename from org/papervision3d/core/render/draw/list/AbstractDrawableList.as rename to src/org/papervision3d/core/render/draw/list/AbstractDrawableList.as diff --git a/org/papervision3d/core/render/draw/list/DrawableList.as b/src/org/papervision3d/core/render/draw/list/DrawableList.as similarity index 100% rename from org/papervision3d/core/render/draw/list/DrawableList.as rename to src/org/papervision3d/core/render/draw/list/DrawableList.as diff --git a/org/papervision3d/core/render/draw/list/IDrawableList.as b/src/org/papervision3d/core/render/draw/list/IDrawableList.as similarity index 100% rename from org/papervision3d/core/render/draw/list/IDrawableList.as rename to src/org/papervision3d/core/render/draw/list/IDrawableList.as diff --git a/org/papervision3d/core/render/engine/AbstractRenderEngine.as b/src/org/papervision3d/core/render/engine/AbstractRenderEngine.as similarity index 100% rename from org/papervision3d/core/render/engine/AbstractRenderEngine.as rename to src/org/papervision3d/core/render/engine/AbstractRenderEngine.as diff --git a/org/papervision3d/core/render/engine/IRenderEngine.as b/src/org/papervision3d/core/render/engine/IRenderEngine.as similarity index 100% rename from org/papervision3d/core/render/engine/IRenderEngine.as rename to src/org/papervision3d/core/render/engine/IRenderEngine.as diff --git a/org/papervision3d/core/render/pipeline/BasicPipeline.as b/src/org/papervision3d/core/render/pipeline/BasicPipeline.as similarity index 100% rename from org/papervision3d/core/render/pipeline/BasicPipeline.as rename to src/org/papervision3d/core/render/pipeline/BasicPipeline.as diff --git a/org/papervision3d/core/render/pipeline/IRenderPipeline.as b/src/org/papervision3d/core/render/pipeline/IRenderPipeline.as similarity index 100% rename from org/papervision3d/core/render/pipeline/IRenderPipeline.as rename to src/org/papervision3d/core/render/pipeline/IRenderPipeline.as diff --git a/org/papervision3d/core/render/raster/DefaultRasterizer.as b/src/org/papervision3d/core/render/raster/DefaultRasterizer.as similarity index 100% rename from org/papervision3d/core/render/raster/DefaultRasterizer.as rename to src/org/papervision3d/core/render/raster/DefaultRasterizer.as diff --git a/org/papervision3d/core/render/raster/IRasterizer.as b/src/org/papervision3d/core/render/raster/IRasterizer.as similarity index 100% rename from org/papervision3d/core/render/raster/IRasterizer.as rename to src/org/papervision3d/core/render/raster/IRasterizer.as diff --git a/org/papervision3d/materials/AbstractMaterial.as b/src/org/papervision3d/materials/AbstractMaterial.as similarity index 100% rename from org/papervision3d/materials/AbstractMaterial.as rename to src/org/papervision3d/materials/AbstractMaterial.as diff --git a/org/papervision3d/materials/WireframeMaterial.as b/src/org/papervision3d/materials/WireframeMaterial.as similarity index 100% rename from org/papervision3d/materials/WireframeMaterial.as rename to src/org/papervision3d/materials/WireframeMaterial.as diff --git a/org/papervision3d/objects/DisplayObject3D.as b/src/org/papervision3d/objects/DisplayObject3D.as similarity index 72% rename from org/papervision3d/objects/DisplayObject3D.as rename to src/org/papervision3d/objects/DisplayObject3D.as index fbac03c..fb6273f 100755 --- a/org/papervision3d/objects/DisplayObject3D.as +++ b/src/org/papervision3d/objects/DisplayObject3D.as @@ -1,34 +1,33 @@ package org.papervision3d.objects { import __AS3__.vec.Vector; import org.papervision3d.core.geom.provider.VertexGeometry; import org.papervision3d.core.proto.DisplayObjectContainer3D; import org.papervision3d.materials.AbstractMaterial; /** * */ public class DisplayObject3D extends DisplayObjectContainer3D { /** * - */ + */ + public var material:AbstractMaterial; + public var geometry:VertexGeometry; - public var material:AbstractMaterial; - public var geometry:VertexGeometry; - - public var viewVertexData :Vector.<Number>; - public var screenVertexData :Vector.<Number>; - + public var viewVertexData :Vector.<Number>; + public var screenVertexData :Vector.<Number>; + + /** + * + */ public function DisplayObject3D(name:String=null) { super(name); viewVertexData = new Vector.<Number>(); screenVertexData = new Vector.<Number>(); - } - - } } \ No newline at end of file diff --git a/org/papervision3d/objects/primitives/Cube.as b/src/org/papervision3d/objects/primitives/Cube.as similarity index 97% rename from org/papervision3d/objects/primitives/Cube.as rename to src/org/papervision3d/objects/primitives/Cube.as index 1b5f832..9e05ca9 100755 --- a/org/papervision3d/objects/primitives/Cube.as +++ b/src/org/papervision3d/objects/primitives/Cube.as @@ -1,83 +1,80 @@ package org.papervision3d.objects.primitives { import org.papervision3d.core.geom.Triangle; import org.papervision3d.core.geom.UVCoord; import org.papervision3d.core.geom.Vertex; import org.papervision3d.core.geom.provider.TriangleGeometry; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.materials.AbstractMaterial; /** * */ public class Cube extends DisplayObject3D { /** * */ - - private var triGeometry : TriangleGeometry; + private var triGeometry : TriangleGeometry; public function Cube(material:AbstractMaterial, size:Number = 100, name:String=null) { super(name); this.material = material; geometry = triGeometry = new TriangleGeometry(); create(size); } - - - + /** * */ protected function create(size:Number):void { var sz : Number = size / 2; var v :Array = [ new Vertex(-sz, sz, -sz), new Vertex(sz, sz, -sz), new Vertex(sz, -sz, -sz), new Vertex(-sz, -sz, -sz), new Vertex(-sz, sz, sz), new Vertex(sz, sz, sz), new Vertex(sz, -sz, sz), new Vertex(-sz, -sz, sz) ]; var vertex : Vertex; for each(vertex in v) { this.geometry.addVertex(vertex); } var uv0 :UVCoord = new UVCoord(0, 1); var uv1 :UVCoord = new UVCoord(0, 0); var uv2 :UVCoord = new UVCoord(1, 0); var uv3 :UVCoord = new UVCoord(1, 1); // top triGeometry.addTriangle(new Triangle(v[0], v[4], v[5], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(v[0], v[5], v[1], uv0, uv2, uv3) ); // bottom triGeometry.addTriangle(new Triangle(v[6], v[7], v[3], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(v[6], v[3], v[2], uv2, uv0, uv3) ); // left triGeometry.addTriangle(new Triangle(v[0], v[3], v[7], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(v[0], v[7], v[4], uv1, uv3, uv2) ); // right triGeometry.addTriangle(new Triangle(v[5], v[6], v[2], uv1, uv0, uv3) ); triGeometry.addTriangle(new Triangle(v[5], v[2], v[1], uv1, uv3, uv2) ); // front triGeometry.addTriangle(new Triangle(v[0], v[1], v[2], uv2, uv1, uv0) ); triGeometry.addTriangle(new Triangle(v[0], v[2], v[3], uv2, uv0, uv3) ); // back triGeometry.addTriangle(new Triangle(v[6], v[5], v[4], uv0, uv1, uv2) ); triGeometry.addTriangle(new Triangle(v[6], v[4], v[7], uv0, uv2, uv3) ); } } } \ No newline at end of file diff --git a/src/org/papervision3d/objects/primitives/Plane.as b/src/org/papervision3d/objects/primitives/Plane.as new file mode 100644 index 0000000..f5f8b05 --- /dev/null +++ b/src/org/papervision3d/objects/primitives/Plane.as @@ -0,0 +1,55 @@ +package org.papervision3d.objects.primitives +{ + import org.papervision3d.core.geom.Triangle; + import org.papervision3d.core.geom.UVCoord; + import org.papervision3d.core.geom.Vertex; + import org.papervision3d.objects.DisplayObject3D; + + public class Plane extends DisplayObject3D + { + public function Plane(name:String=null, width:Number=100, height:Number=100, segX:Number=1, segY:Number=1) + { + super(name); + + create(width, height, segX, segY); + } + + protected function create(width:Number, height:Number, segX:Number=1, segY:Number=1):void + { + var sizeX : Number = width / 2; + var sizeZ : Number = height / 2; + var stepX :Number = width / segX; + var stepZ :Number = height / segY; + var curX :Number = -sizeX; + var curZ :Number = sizeZ; + var curU :Number = 0; + var curV :Number = 0; + + var i :int, j :int; + + for (i = 0; i < segX; i++) + { + curX = -sizeX + (i * stepX); + for (j = 0; j < segY; j++) + { + curZ = sizeZ - (j * stepZ); + + var v0 :Vertex = new Vertex(curX, 0, curZ); + var v1 :Vertex = new Vertex(curX + stepX, 0, curZ); + var v2 :Vertex = new Vertex(curX + stepX, 0, curZ - stepZ); + var v3 :Vertex = new Vertex(curX, 0, curZ - stepZ); + + var uv0 :UVCoord = new UVCoord(0, 1); + var uv1 :UVCoord = new UVCoord(0, 0); + var uv2 :UVCoord = new UVCoord(1, 0); + var uv3 :UVCoord = new UVCoord(1, 1); + + addTriangle( new Triangle(v0, v1, v2, uv0, uv1, uv2) ); + addTriangle( new Triangle(v0, v2, v3, uv0, uv2, uv3) ); + } + } + + mergeVertices(); + } + } +} \ No newline at end of file diff --git a/org/papervision3d/render/BasicRenderEngine.as b/src/org/papervision3d/render/BasicRenderEngine.as similarity index 100% rename from org/papervision3d/render/BasicRenderEngine.as rename to src/org/papervision3d/render/BasicRenderEngine.as diff --git a/org/papervision3d/view/Viewport3D.as b/src/org/papervision3d/view/Viewport3D.as similarity index 100% rename from org/papervision3d/view/Viewport3D.as rename to src/org/papervision3d/view/Viewport3D.as
ches/plex-vimcasts
9ea08fbe81c3905a9d4cd6b3192037aa42cf9959
Document installation from official Channel Directory
diff --git a/README.rst b/README.rst index 757723e..d4647f9 100644 --- a/README.rst +++ b/README.rst @@ -1,69 +1,75 @@ ============= Plex-Vimcasts ============= A simple Plex_ plugin for vimcasts.org_, allowing you to view the screencasts from the comfort of your media center. Installation ============ -Assuming you already have a working Plex installation, grab the latest release -from `the downloads`_ and double-click to install. +The plugin is accepted in Plex's official channel directory—just browse the +Channel Directory section in the Plex Home Theater app and you can install it +from there. Building From Source ==================== +If you want to hack on the plugin, this should get you going. Pull requests +are welcome, I'll try to get enhancements upstreamed to Plex, but the plugin +submission process is not self-service and to be honest isn't very transparent, +so it may take some time. + The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: - Git_ - Ruby_ & Rake_ (Both are bundled with OS X) With those tools installed, get a copy of the source and install the plugin:: $ git clone git://github.com/ches/plex-vimcasts.git $ cd plex-vimcasts $ rake install If you'd like to remove the plugin later, use:: $ rake uninstall Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data. If you wish to package your own double-clickable plugin installer, you'll need two additional build dependencies: - The `Plex App Maker`_ - The rb-appscript_ RubyGem (``gem install rb-appscript``) Then, just run ``rake package`` and check the ``dist`` directory. License ======= Under the same terms as Plex, GPLv2. Thanks ====== This, my first Plex plugin, began as a bunch of copy and paste! (Please Plex, update the documentation for plugin developers one of these days...). - Basically a clone of David Leatherman's `Railscasts plugin`_. - Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably overkill for this simple plugin, but it's a nice generalized example for other plugins to follow :-) .. _Plex: http://plexapp.com/ .. _vimcasts.org: http://vimcasts.org/ .. _the downloads: http://github.com/ches/plex-vimcasts/downloads .. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3 .. _Ruby: http://www.ruby-lang.org/ .. _Rake: http://rake.rubyforge.org/ .. _Plex App Maker: http://forums.plexapp.com/index.php?/topic/10180-plex-app-maker/ .. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html .. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin .. _MLB plugin: http://github.com/rfletcher/plex-mlb
ches/plex-vimcasts
960dc94bc673848e8a710254009fb8afdad08b9a
Use the JSON feed Drew kindly set up. Calling this 1.0.0
diff --git a/README.rst b/README.rst index 5f05fbc..757723e 100644 --- a/README.rst +++ b/README.rst @@ -1,73 +1,69 @@ ============= Plex-Vimcasts ============= A simple Plex_ plugin for vimcasts.org_, allowing you to view the screencasts from the comfort of your media center. Installation ============ Assuming you already have a working Plex installation, grab the latest release from `the downloads`_ and double-click to install. Building From Source ==================== The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: - Git_ - Ruby_ & Rake_ (Both are bundled with OS X) With those tools installed, get a copy of the source and install the plugin:: $ git clone git://github.com/ches/plex-vimcasts.git $ cd plex-vimcasts $ rake install If you'd like to remove the plugin later, use:: $ rake uninstall Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data. If you wish to package your own double-clickable plugin installer, you'll need two additional build dependencies: - The `Plex App Maker`_ - The rb-appscript_ RubyGem (``gem install rb-appscript``) Then, just run ``rake package`` and check the ``dist`` directory. -To Do -===== - -- More reliable method of finding episode thumbnails - License ======= Under the same terms as Plex, GPLv2. Thanks ====== -This, my first Plex plugin, is essentially a bunch of copy and paste! +This, my first Plex plugin, began as a bunch of copy and paste! (Please Plex, +update the documentation for plugin developers one of these days...). - Basically a clone of David Leatherman's `Railscasts plugin`_. - Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably overkill for this simple plugin, but it's a nice generalized example for other plugins to follow :-) .. _Plex: http://plexapp.com/ .. _vimcasts.org: http://vimcasts.org/ .. _the downloads: http://github.com/ches/plex-vimcasts/downloads .. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3 .. _Ruby: http://www.ruby-lang.org/ .. _Rake: http://rake.rubyforge.org/ .. _Plex App Maker: http://forums.plexapp.com/index.php?/topic/10180-plex-app-maker/ .. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html .. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin .. _MLB plugin: http://github.com/rfletcher/plex-mlb diff --git a/bundle/Contents/Code/__init__.py b/bundle/Contents/Code/__init__.py index a9edc4f..be864cf 100644 --- a/bundle/Contents/Code/__init__.py +++ b/bundle/Contents/Code/__init__.py @@ -1,69 +1,68 @@ import htmlentitydefs import re -from urlparse import urlparse +from datetime import datetime +from email.utils import parsedate -VIMCASTS_FEED_URL = 'http://vimcasts.org/feeds/quicktime' -VIMCASTS_EP_THUMB = 'http://vimcasts.org/images/posters/%s.png' +VIMCASTS_FEED_URL = 'http://vimcasts.org/episodes.json' VIMCASTS_ICON = 'icon-default.png' VIMCASTS_ART = 'art-default.png' ############################################################################### def Start(): Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items") MediaContainer.title1 = L('vimcasts') MediaContainer.art = R(VIMCASTS_ART) HTTP.CacheTime = CACHE_1HOUR @handler('/video/vimcasts', L('vimcasts')) def VideoMenu(): dir = MediaContainer(mediaType='video', viewGroup='Details') - feed_items = XML.ElementFromURL(VIMCASTS_FEED_URL).xpath('//item') - for item in feed_items: + episodes = JSON.ObjectFromURL(VIMCASTS_FEED_URL)['episodes'] + episodes.reverse() # Newest first + for episode in episodes: try: - url = item.find('enclosure').get('url') + url = episode['quicktime']['url'] + title = F('episode', episode['episode_number'], episode['title']) + date = parsedate(episode['published_at']) + date = datetime(*date[:6]) + summary = dehtmlize(episode['abstract'].strip()) + thumb = episode['poster'] + dir.Append(VideoItem(url, title=title, summary=summary, thumb=thumb, + subtitle=date.strftime('%A, %B %e %Y'))) except AttributeError: - # Probably the feed has an entry without an enclosure - pass - else: - # Example path: /videos/24/vimrc_on_the_fly.m4v - path_parts = urlparse(url).path.split('/')[1:] - title = F('episode', path_parts[1], item.find('title').text) - date = item.find('pubDate').text - description = dehtmlize(item.find('description').text.strip()) - thumb = VIMCASTS_EP_THUMB % path_parts[-1].split('.')[0] - dir.Append(VideoItem(url, title=title, summary=description, - subtitle=date[0:-15], thumb=thumb)) + Log("Something odd with episode, skipping: %s" % + episode, debugOnly=False) return dir ## # Removes HTML tags from a text string and converts character entities. # Adapted from: # http://effbot.org/zone/re-sub.htm#strip-html # # @param text The HTML source. # @return The plain text. If the HTML source contains non-ASCII # entities or character references, this is a Unicode string. def dehtmlize(text): def convert_entities(m): text = m.group(0) if text[:2] == "&#": try: if text[:3] == "&#x": return unichr(int(text[3:-1], 16)) else: return unichr(int(text[2:-1])) except ValueError: pass elif text[:1] == "&": entity = htmlentitydefs.entitydefs.get(text[1:-1]) if entity: if entity[:2] == "&#": try: return unichr(int(entity[2:-1])) except ValueError: pass else: return unicode(entity, "iso-8859-1") return text # leave as is return String.StripTags(re.sub("&#?\w+;", convert_entities, text)) diff --git a/bundle/Contents/config.yml b/bundle/Contents/config.yml index ccb38dc..9caac19 100644 --- a/bundle/Contents/config.yml +++ b/bundle/Contents/config.yml @@ -1,43 +1,43 @@ # Plugin configuration # # This configuration setup allows for easy, environment-specific configuration. # Its settings can be inserted into other files at build-time, or loaded by # python code at run-time with PyYAML. # Default settings. This is never read directly. Instead, it's extended by # other sections below. default: &default PLUGIN_ID: com.plexapp.plugins.vimcasts PLUGIN_NAME: Vimcasts PLUGIN_PREFIX: /video/vimcasts - PLUGIN_VERSION: 0.9.1 + PLUGIN_VERSION: 1.0.0 PLUGIN_AUTHOR: Ches Martin <[email protected]> PLUGIN_DESCRIPTION: | Vimcasts publishes regular screencasts about the Vim text editor. Episodes are kept short – typically less than 5 minutes, never more than 10. The aim is to provide something in each episode that you can take away and use. Vimcasts is produced by Drew Neil (aka nelstrom). VERSION_IN_PLUGIN_NAME: false CACHE_TTL: 3600 PLIST_DEBUG: 0 PLIST_DEV_MODE: 0 # override some values when building a dev release development: <<: *default VERSION_IN_PLUGIN_NAME: true # disable caching CACHE_TTL: 0 # turn on dev mode (no auto-updates), and debug PLIST_DEBUG: 1 PLIST_DEV_MODE: 1 # release version inherits defaults release: <<: *default
ches/plex-vimcasts
a514b23d4fd4587052b786294e6a084e880b8ad2
Fix dumb build bugs
diff --git a/Rakefile b/Rakefile index 8d290fc..fc6bb89 100644 --- a/Rakefile +++ b/Rakefile @@ -1,282 +1,285 @@ # Lifted and adapted from Rick Fletcher's MLB plugin, hat tip is due: # http://github.com/rfletcher/plex-mlb # Overkill for this plugin really, but it's a nice general example build setup. require 'pathname' require 'rake' require 'rake/clean' require 'rake/packagetask' require 'tempfile' require 'yaml' require 'rubygems' # Base Paths PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)).expand_path PLUGIN_BUNDLE_DIR = PLUGIN_ROOT + 'bundle' PLUGIN_BUILD_DIR = PLUGIN_ROOT + 'build' PLUGIN_DIST_DIR = PLUGIN_ROOT + 'dist' PLUGIN_TEMPLATE_DIR = PLUGIN_ROOT + 'templates' # Plex and Plex Media Server paths APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support").expand_path PLEX_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex' PMS_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex Media Server' PMS_PLUGIN_DIR = PMS_SUPPORT_DIR + 'Plug-ins' PMS_PLUGIN_DATA_DIR = PMS_SUPPORT_DIR + 'Plug-in Support' PMS_BIN = PLEX_SUPPORT_DIR + 'Plex Media Server.app/Contents/MacOS/Plex Media Server' def config(env=:release) - @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml')[env.to_s] + @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml') + @config[env.to_s] end PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_" # files to blow away with a `rake clean` and `clobber`. Clobber also cleans. CLEAN.include(PLUGIN_BUILD_DIR.to_s) CLOBBER.include(PLUGIN_DIST_DIR) # ============================================================================== # = HELPERS # ============================================================================== class File def self.binary?(name) fstat = stat(name) if !fstat.file? false else open(name) do |file| blk = file.read(fstat.blksize) blk.size == 0 || blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0 end end end def self.rm_if_exists(name) rm_rf name if self.exists? name end end def add_env_file(env, bundle_dir) File.open(File.join(bundle_dir, 'Contents', 'env'), 'w') do |f| f.write env.to_s end end def bundle_name(config) (config['PLUGIN_BUNDLE_NAME'] ? config['PLUGIN_BUNDLE_NAME'] : config['PLUGIN_NAME']) + '.bundle' end # Really lo-fi 'erb' :-) -def erb(config, file) +def erb(cfg, file) warning = <<-EOW DO NOT EDIT THIS FILE It was generated from a template. Your changes will be overwritten EOW comment = case File.extname(file).sub(/^\./, '').to_sym when :html, :xml, :plist then ['<!--', '-->'] when :py then ['"""', '"""'] when :rb then ['=begin', '=end'] end temp = Tempfile.new("erb") temp << '<?xml version="1.0" encoding="UTF-8"?>' << "\n" if File.extname(file) === ".xml" temp << [comment.first, warning].join("\n") << comment.last << "\n" File.open(file).each_line do |line| temp << line.gsub(/<%=(.*?)%>/) do prop = $1.strip - if value = config[prop] + if value = cfg[prop] value else raise "couldn't find property `#{prop}' (in #{file})" end end end temp.close mv(temp.path, file, :verbose => false) end # ============================================================================== # = TASKS # ============================================================================== task :default => :build namespace :build do - def build_templates(config, build_dir) + def build_templates(cfg, build_dir) FileList[PLUGIN_TEMPLATE_DIR + '**/*'].each do |file| if File.file?(file) dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.to_s.length + 1, file.length]) dest_file = File.join dest_dir, File.basename(file) mkdir_p dest_dir cp file, dest_dir - erb(config, dest_file) unless File.binary?(dest_file) + erb(cfg, dest_file) unless File.binary?(dest_file) end end end - def build(env, config) + def build(env, cfg) File.rm_if_exists PLUGIN_BUILD_DIR mkdir_p PLUGIN_BUILD_DIR - bundle_dir = PLUGIN_BUILD_DIR + bundle_name(config) + bundle_dir = PLUGIN_BUILD_DIR + bundle_name(cfg) cp_r PLUGIN_BUNDLE_DIR, bundle_dir add_env_file env, bundle_dir rm FileList[PLUGIN_BUILD_DIR + '**/*.pyc'] readme = Dir['README*'].first cp_r(readme, PLUGIN_BUILD_DIR + 'README.txt') if readme end desc 'Build a dev distribution.' task :development do - build_templates config(:development), PLUGIN_BUNDLE_DIR build :development, config(:development) + build_templates config(:development), PLUGIN_BUNDLE_DIR end task :dev => :development desc 'Build a release distribution.' task :release do - build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config)) build :release, config + build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config)) end end desc 'Alias for build:development' task :build => 'build:development' namespace :package do def package(config) require 'appscript' File.rm_if_exists PLUGIN_DIST_DIR mkdir_p PLUGIN_DIST_DIR Appscript.app('AppMaker').activate se = Appscript.app('System Events') am = se.processes['AppMaker'] am_window = am.windows['AppMaker'] am_window.actions['AXRaise'].perform [ PLUGIN_BUILD_DIR + bundle_name(config), config['PLUGIN_NAME'], config['PLUGIN_AUTHOR'], config['PLUGIN_VERSION'], config['PLUGIN_DESCRIPTION'] ].each_with_index do |value, i| i += 1 am_window.text_fields[i].value.set(value.to_s) am_window.text_fields[i].focused.set(true) if i == 1 am_window.text_fields[i].actions['AXConfirm'].perform else am_window.text_fields[i].key_code(124) am_window.text_fields[i].keystroke(" \b") end end am_window.UI_elements['Create Package'].click am.keystroke('g', :using => [ :command_down, :shift_down ]) am.keystroke(PLUGIN_DIST_DIR.to_s + "\r") am.keystroke((config['PLUGIN_NAME'] + '-' + config['PLUGIN_VERSION'].to_s).gsub(' ', '_') + "\r") # wait for save am_window.text_fields[1].focused.set(true) Appscript.app('AppMaker').quit end desc 'Create a dev-mode, installable Plex app' task :development => 'build:development' do package config(:development) end task :dev => :development desc 'Create an installable Plex app' task :release => 'build:release' do package config(:release) end end desc 'Alias for package:release' task :package => 'package:release' namespace :pms do + desc 'Restart Plex Media Server' task :restart => [ :stop, :start ] desc 'Start Plex Media Server' task :start do exec '"' + PMS_BIN + '"' end + desc 'Stop Plex Media Server' task :stop do system 'killall', 'Plex Media Server' end end task :pms => 'pms:restart' namespace :install do desc 'Install a clean copy (do an uninstall:hard first)' task :clean => [ 'uninstall:hard', :install ] desc 'Install a development version of the plugin' task :development => [ 'build:development', :uninstall ] do ln_sf(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development))) add_env_file :development, PLUGIN_BUNDLE_DIR end task :dev => :development desc 'Install a release version of the plugin' task :release => [ 'build:release', :uninstall ] do mkdir_p(PMS_PLUGIN_DIR + bundle_name(config)) cp_r(PLUGIN_BUILD_DIR + bundle_name(config), PMS_PLUGIN_DIR) add_env_file :release, PLUGIN_BUNDLE_DIR end end desc 'Alias for install:release' task :install => 'install:release' namespace :uninstall do desc 'Remove the installed bundle, but leave data behind.' task :soft do File.rm_if_exists(PMS_PLUGIN_DIR + bundle_name(config)) end desc 'Remove the installed bundle and data.' task :hard => :soft do files = FileList[ PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}.*", PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}" ] rm_rf files unless files.empty? end end desc 'Alias for uninstall:soft' task :uninstall => 'uninstall:soft' namespace :tail do logs = { :plex => [ 'Plex', File.expand_path("~/Library/Logs/Plex.log") ], :plugin => [ 'the plugin', File.expand_path("~/Library/Logs/PMS Plugin Logs/#{config['PLUGIN_ID']}.log") ] } def tail(logs) system "tail -f " << logs.collect { |log| "\"#{log}\"" }.join( ' ' ) end logs.each do |k,v| desc "Tail #{v[0]}'s log file" task(k) { tail [v[1]] } end desc 'Tail log files' task :all do tail logs.collect { |k,v| v[1] } end end desc 'Alias for tail:all' task :tail => 'tail:all'
ches/plex-vimcasts
556aed3a257d3dd148c9ea85a21f1bde47f9bae3
Distinguish building from source versus packaging an installer.
diff --git a/README.rst b/README.rst index 09389d1..5f05fbc 100644 --- a/README.rst +++ b/README.rst @@ -1,64 +1,73 @@ ============= Plex-Vimcasts ============= A simple Plex_ plugin for vimcasts.org_, allowing you to view the screencasts from the comfort of your media center. Installation ============ Assuming you already have a working Plex installation, grab the latest release from `the downloads`_ and double-click to install. Building From Source ==================== -The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: +The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and +``templates/`` directories. To build the bundle you'll need: - Git_ - Ruby_ & Rake_ (Both are bundled with OS X) -- The rb-appscript_ RubyGem (``gem install rb-appscript``) With those tools installed, get a copy of the source and install the plugin:: $ git clone git://github.com/ches/plex-vimcasts.git $ cd plex-vimcasts $ rake install If you'd like to remove the plugin later, use:: $ rake uninstall Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data. +If you wish to package your own double-clickable plugin installer, you'll need +two additional build dependencies: + +- The `Plex App Maker`_ +- The rb-appscript_ RubyGem (``gem install rb-appscript``) + +Then, just run ``rake package`` and check the ``dist`` directory. + To Do ===== - More reliable method of finding episode thumbnails License ======= Under the same terms as Plex, GPLv2. Thanks ====== This, my first Plex plugin, is essentially a bunch of copy and paste! - Basically a clone of David Leatherman's `Railscasts plugin`_. - Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably overkill for this simple plugin, but it's a nice generalized example for other plugins to follow :-) .. _Plex: http://plexapp.com/ .. _vimcasts.org: http://vimcasts.org/ .. _the downloads: http://github.com/ches/plex-vimcasts/downloads .. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3 .. _Ruby: http://www.ruby-lang.org/ .. _Rake: http://rake.rubyforge.org/ +.. _Plex App Maker: http://forums.plexapp.com/index.php?/topic/10180-plex-app-maker/ .. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html .. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin .. _MLB plugin: http://github.com/rfletcher/plex-mlb diff --git a/Rakefile b/Rakefile index f42216c..8d290fc 100644 --- a/Rakefile +++ b/Rakefile @@ -1,281 +1,282 @@ # Lifted and adapted from Rick Fletcher's MLB plugin, hat tip is due: # http://github.com/rfletcher/plex-mlb # Overkill for this plugin really, but it's a nice general example build setup. require 'pathname' require 'rake' require 'rake/clean' require 'rake/packagetask' require 'tempfile' require 'yaml' require 'rubygems' -require 'appscript' # Base Paths PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)).expand_path PLUGIN_BUNDLE_DIR = PLUGIN_ROOT + 'bundle' PLUGIN_BUILD_DIR = PLUGIN_ROOT + 'build' PLUGIN_DIST_DIR = PLUGIN_ROOT + 'dist' PLUGIN_TEMPLATE_DIR = PLUGIN_ROOT + 'templates' # Plex and Plex Media Server paths APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support").expand_path PLEX_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex' PMS_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex Media Server' PMS_PLUGIN_DIR = PMS_SUPPORT_DIR + 'Plug-ins' PMS_PLUGIN_DATA_DIR = PMS_SUPPORT_DIR + 'Plug-in Support' PMS_BIN = PLEX_SUPPORT_DIR + 'Plex Media Server.app/Contents/MacOS/Plex Media Server' def config(env=:release) @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml')[env.to_s] end PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_" # files to blow away with a `rake clean` and `clobber`. Clobber also cleans. CLEAN.include(PLUGIN_BUILD_DIR.to_s) CLOBBER.include(PLUGIN_DIST_DIR) # ============================================================================== # = HELPERS # ============================================================================== class File def self.binary?(name) fstat = stat(name) if !fstat.file? false else open(name) do |file| blk = file.read(fstat.blksize) blk.size == 0 || blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0 end end end def self.rm_if_exists(name) rm_rf name if self.exists? name end end def add_env_file(env, bundle_dir) File.open(File.join(bundle_dir, 'Contents', 'env'), 'w') do |f| f.write env.to_s end end def bundle_name(config) (config['PLUGIN_BUNDLE_NAME'] ? config['PLUGIN_BUNDLE_NAME'] : config['PLUGIN_NAME']) + '.bundle' end # Really lo-fi 'erb' :-) def erb(config, file) warning = <<-EOW DO NOT EDIT THIS FILE It was generated from a template. Your changes will be overwritten EOW comment = case File.extname(file).sub(/^\./, '').to_sym when :html, :xml, :plist then ['<!--', '-->'] when :py then ['"""', '"""'] when :rb then ['=begin', '=end'] end temp = Tempfile.new("erb") temp << '<?xml version="1.0" encoding="UTF-8"?>' << "\n" if File.extname(file) === ".xml" temp << [comment.first, warning].join("\n") << comment.last << "\n" File.open(file).each_line do |line| temp << line.gsub(/<%=(.*?)%>/) do prop = $1.strip if value = config[prop] value else raise "couldn't find property `#{prop}' (in #{file})" end end end temp.close mv(temp.path, file, :verbose => false) end # ============================================================================== # = TASKS # ============================================================================== task :default => :build namespace :build do def build_templates(config, build_dir) FileList[PLUGIN_TEMPLATE_DIR + '**/*'].each do |file| if File.file?(file) dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.to_s.length + 1, file.length]) dest_file = File.join dest_dir, File.basename(file) mkdir_p dest_dir cp file, dest_dir erb(config, dest_file) unless File.binary?(dest_file) end end end def build(env, config) File.rm_if_exists PLUGIN_BUILD_DIR mkdir_p PLUGIN_BUILD_DIR bundle_dir = PLUGIN_BUILD_DIR + bundle_name(config) cp_r PLUGIN_BUNDLE_DIR, bundle_dir add_env_file env, bundle_dir rm FileList[PLUGIN_BUILD_DIR + '**/*.pyc'] readme = Dir['README*'].first cp_r(readme, PLUGIN_BUILD_DIR + 'README.txt') if readme end desc 'Build a dev distribution.' task :development do build_templates config(:development), PLUGIN_BUNDLE_DIR build :development, config(:development) end task :dev => :development desc 'Build a release distribution.' task :release do build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config)) build :release, config end end desc 'Alias for build:development' task :build => 'build:development' namespace :package do def package(config) + require 'appscript' File.rm_if_exists PLUGIN_DIST_DIR mkdir_p PLUGIN_DIST_DIR Appscript.app('AppMaker').activate se = Appscript.app('System Events') am = se.processes['AppMaker'] am_window = am.windows['AppMaker'] am_window.actions['AXRaise'].perform [ PLUGIN_BUILD_DIR + bundle_name(config), config['PLUGIN_NAME'], config['PLUGIN_AUTHOR'], config['PLUGIN_VERSION'], config['PLUGIN_DESCRIPTION'] ].each_with_index do |value, i| i += 1 am_window.text_fields[i].value.set(value.to_s) am_window.text_fields[i].focused.set(true) if i == 1 am_window.text_fields[i].actions['AXConfirm'].perform else am_window.text_fields[i].key_code(124) am_window.text_fields[i].keystroke(" \b") end end am_window.UI_elements['Create Package'].click am.keystroke('g', :using => [ :command_down, :shift_down ]) am.keystroke(PLUGIN_DIST_DIR.to_s + "\r") am.keystroke((config['PLUGIN_NAME'] + '-' + config['PLUGIN_VERSION'].to_s).gsub(' ', '_') + "\r") # wait for save am_window.text_fields[1].focused.set(true) Appscript.app('AppMaker').quit end desc 'Create a dev-mode, installable Plex app' task :development => 'build:development' do package config(:development) end task :dev => :development desc 'Create an installable Plex app' task :release => 'build:release' do package config(:release) end end +desc 'Alias for package:release' task :package => 'package:release' namespace :pms do task :restart => [ :stop, :start ] desc 'Start Plex Media Server' task :start do exec '"' + PMS_BIN + '"' end task :stop do system 'killall', 'Plex Media Server' end end task :pms => 'pms:restart' namespace :install do desc 'Install a clean copy (do an uninstall:hard first)' task :clean => [ 'uninstall:hard', :install ] desc 'Install a development version of the plugin' task :development => [ 'build:development', :uninstall ] do ln_sf(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development))) add_env_file :development, PLUGIN_BUNDLE_DIR end task :dev => :development desc 'Install a release version of the plugin' task :release => [ 'build:release', :uninstall ] do mkdir_p(PMS_PLUGIN_DIR + bundle_name(config)) cp_r(PLUGIN_BUILD_DIR + bundle_name(config), PMS_PLUGIN_DIR) add_env_file :release, PLUGIN_BUNDLE_DIR end end desc 'Alias for install:release' task :install => 'install:release' namespace :uninstall do desc 'Remove the installed bundle, but leave data behind.' task :soft do File.rm_if_exists(PMS_PLUGIN_DIR + bundle_name(config)) end desc 'Remove the installed bundle and data.' task :hard => :soft do files = FileList[ PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}.*", PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}" ] rm_rf files unless files.empty? end end desc 'Alias for uninstall:soft' task :uninstall => 'uninstall:soft' namespace :tail do logs = { :plex => [ 'Plex', File.expand_path("~/Library/Logs/Plex.log") ], :plugin => [ 'the plugin', File.expand_path("~/Library/Logs/PMS Plugin Logs/#{config['PLUGIN_ID']}.log") ] } def tail(logs) system "tail -f " << logs.collect { |log| "\"#{log}\"" }.join( ' ' ) end logs.each do |k,v| desc "Tail #{v[0]}'s log file" task(k) { tail [v[1]] } end desc 'Tail log files' task :all do tail logs.collect { |k,v| v[1] } end end desc 'Alias for tail:all' task :tail => 'tail:all'
ches/plex-vimcasts
81e54808d6e454735256dc3c0ec50bf4119c98ed
Bump version to package with real artwork
diff --git a/bundle/Contents/config.yml b/bundle/Contents/config.yml index bf5a1de..ccb38dc 100644 --- a/bundle/Contents/config.yml +++ b/bundle/Contents/config.yml @@ -1,43 +1,43 @@ # Plugin configuration # # This configuration setup allows for easy, environment-specific configuration. # Its settings can be inserted into other files at build-time, or loaded by # python code at run-time with PyYAML. # Default settings. This is never read directly. Instead, it's extended by # other sections below. default: &default PLUGIN_ID: com.plexapp.plugins.vimcasts PLUGIN_NAME: Vimcasts PLUGIN_PREFIX: /video/vimcasts - PLUGIN_VERSION: 0.9.0 + PLUGIN_VERSION: 0.9.1 PLUGIN_AUTHOR: Ches Martin <[email protected]> PLUGIN_DESCRIPTION: | Vimcasts publishes regular screencasts about the Vim text editor. Episodes are kept short – typically less than 5 minutes, never more than 10. The aim is to provide something in each episode that you can take away and use. Vimcasts is produced by Drew Neil (aka nelstrom). VERSION_IN_PLUGIN_NAME: false CACHE_TTL: 3600 PLIST_DEBUG: 0 PLIST_DEV_MODE: 0 # override some values when building a dev release development: <<: *default VERSION_IN_PLUGIN_NAME: true # disable caching CACHE_TTL: 0 # turn on dev mode (no auto-updates), and debug PLIST_DEBUG: 1 PLIST_DEV_MODE: 1 # release version inherits defaults release: <<: *default
ches/plex-vimcasts
fbb7d832ad5f08c548730d06e163cba9fdde89e9
Proper Vimcasts artwork from Drew, woot
diff --git a/README.rst b/README.rst index 18d400c..09389d1 100644 --- a/README.rst +++ b/README.rst @@ -1,64 +1,64 @@ ============= Plex-Vimcasts ============= A simple Plex_ plugin for vimcasts.org_, allowing you to view the screencasts from the comfort of your media center. Installation ============ Assuming you already have a working Plex installation, grab the latest release from `the downloads`_ and double-click to install. Building From Source ==================== The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: - Git_ - Ruby_ & Rake_ (Both are bundled with OS X) - The rb-appscript_ RubyGem (``gem install rb-appscript``) With those tools installed, get a copy of the source and install the plugin:: $ git clone git://github.com/ches/plex-vimcasts.git $ cd plex-vimcasts $ rake install If you'd like to remove the plugin later, use:: $ rake uninstall Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data. To Do ===== -- Proper plugin artwork, instead of stealing Railscasts' +- More reliable method of finding episode thumbnails License ======= Under the same terms as Plex, GPLv2. Thanks ====== This, my first Plex plugin, is essentially a bunch of copy and paste! - Basically a clone of David Leatherman's `Railscasts plugin`_. - Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably overkill for this simple plugin, but it's a nice generalized example for other plugins to follow :-) .. _Plex: http://plexapp.com/ .. _vimcasts.org: http://vimcasts.org/ .. _the downloads: http://github.com/ches/plex-vimcasts/downloads .. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3 .. _Ruby: http://www.ruby-lang.org/ .. _Rake: http://rake.rubyforge.org/ .. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html .. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin .. _MLB plugin: http://github.com/rfletcher/plex-mlb diff --git a/bundle/Contents/Resources/art-default.png b/bundle/Contents/Resources/art-default.png index 2859fa6..d9654c2 100644 Binary files a/bundle/Contents/Resources/art-default.png and b/bundle/Contents/Resources/art-default.png differ diff --git a/bundle/Contents/Resources/icon-default.png b/bundle/Contents/Resources/icon-default.png index e653edd..bd91f6c 100644 Binary files a/bundle/Contents/Resources/icon-default.png and b/bundle/Contents/Resources/icon-default.png differ
ches/plex-vimcasts
bce04fd5d4d9084a93afe16d1bedfa0c24a7bbc7
Forcefully re-symlink in `install:dev` rake task
diff --git a/Rakefile b/Rakefile index 2b050c2..f42216c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,281 +1,281 @@ # Lifted and adapted from Rick Fletcher's MLB plugin, hat tip is due: # http://github.com/rfletcher/plex-mlb # Overkill for this plugin really, but it's a nice general example build setup. require 'pathname' require 'rake' require 'rake/clean' require 'rake/packagetask' require 'tempfile' require 'yaml' require 'rubygems' require 'appscript' # Base Paths PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)).expand_path PLUGIN_BUNDLE_DIR = PLUGIN_ROOT + 'bundle' PLUGIN_BUILD_DIR = PLUGIN_ROOT + 'build' PLUGIN_DIST_DIR = PLUGIN_ROOT + 'dist' PLUGIN_TEMPLATE_DIR = PLUGIN_ROOT + 'templates' # Plex and Plex Media Server paths APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support").expand_path PLEX_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex' PMS_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex Media Server' PMS_PLUGIN_DIR = PMS_SUPPORT_DIR + 'Plug-ins' PMS_PLUGIN_DATA_DIR = PMS_SUPPORT_DIR + 'Plug-in Support' PMS_BIN = PLEX_SUPPORT_DIR + 'Plex Media Server.app/Contents/MacOS/Plex Media Server' def config(env=:release) @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml')[env.to_s] end PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_" # files to blow away with a `rake clean` and `clobber`. Clobber also cleans. CLEAN.include(PLUGIN_BUILD_DIR.to_s) CLOBBER.include(PLUGIN_DIST_DIR) # ============================================================================== # = HELPERS # ============================================================================== class File def self.binary?(name) fstat = stat(name) if !fstat.file? false else open(name) do |file| blk = file.read(fstat.blksize) blk.size == 0 || blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0 end end end def self.rm_if_exists(name) rm_rf name if self.exists? name end end def add_env_file(env, bundle_dir) File.open(File.join(bundle_dir, 'Contents', 'env'), 'w') do |f| f.write env.to_s end end def bundle_name(config) (config['PLUGIN_BUNDLE_NAME'] ? config['PLUGIN_BUNDLE_NAME'] : config['PLUGIN_NAME']) + '.bundle' end # Really lo-fi 'erb' :-) def erb(config, file) warning = <<-EOW DO NOT EDIT THIS FILE It was generated from a template. Your changes will be overwritten EOW comment = case File.extname(file).sub(/^\./, '').to_sym when :html, :xml, :plist then ['<!--', '-->'] when :py then ['"""', '"""'] when :rb then ['=begin', '=end'] end temp = Tempfile.new("erb") temp << '<?xml version="1.0" encoding="UTF-8"?>' << "\n" if File.extname(file) === ".xml" temp << [comment.first, warning].join("\n") << comment.last << "\n" File.open(file).each_line do |line| temp << line.gsub(/<%=(.*?)%>/) do prop = $1.strip if value = config[prop] value else raise "couldn't find property `#{prop}' (in #{file})" end end end temp.close mv(temp.path, file, :verbose => false) end # ============================================================================== # = TASKS # ============================================================================== task :default => :build namespace :build do def build_templates(config, build_dir) FileList[PLUGIN_TEMPLATE_DIR + '**/*'].each do |file| if File.file?(file) dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.to_s.length + 1, file.length]) dest_file = File.join dest_dir, File.basename(file) mkdir_p dest_dir cp file, dest_dir erb(config, dest_file) unless File.binary?(dest_file) end end end def build(env, config) File.rm_if_exists PLUGIN_BUILD_DIR mkdir_p PLUGIN_BUILD_DIR bundle_dir = PLUGIN_BUILD_DIR + bundle_name(config) cp_r PLUGIN_BUNDLE_DIR, bundle_dir add_env_file env, bundle_dir rm FileList[PLUGIN_BUILD_DIR + '**/*.pyc'] readme = Dir['README*'].first cp_r(readme, PLUGIN_BUILD_DIR + 'README.txt') if readme end desc 'Build a dev distribution.' task :development do build_templates config(:development), PLUGIN_BUNDLE_DIR build :development, config(:development) end task :dev => :development desc 'Build a release distribution.' task :release do build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config)) build :release, config end end desc 'Alias for build:development' task :build => 'build:development' namespace :package do def package(config) File.rm_if_exists PLUGIN_DIST_DIR mkdir_p PLUGIN_DIST_DIR Appscript.app('AppMaker').activate se = Appscript.app('System Events') am = se.processes['AppMaker'] am_window = am.windows['AppMaker'] am_window.actions['AXRaise'].perform [ PLUGIN_BUILD_DIR + bundle_name(config), config['PLUGIN_NAME'], config['PLUGIN_AUTHOR'], config['PLUGIN_VERSION'], config['PLUGIN_DESCRIPTION'] ].each_with_index do |value, i| i += 1 am_window.text_fields[i].value.set(value.to_s) am_window.text_fields[i].focused.set(true) if i == 1 am_window.text_fields[i].actions['AXConfirm'].perform else am_window.text_fields[i].key_code(124) am_window.text_fields[i].keystroke(" \b") end end am_window.UI_elements['Create Package'].click am.keystroke('g', :using => [ :command_down, :shift_down ]) am.keystroke(PLUGIN_DIST_DIR.to_s + "\r") am.keystroke((config['PLUGIN_NAME'] + '-' + config['PLUGIN_VERSION'].to_s).gsub(' ', '_') + "\r") # wait for save am_window.text_fields[1].focused.set(true) Appscript.app('AppMaker').quit end desc 'Create a dev-mode, installable Plex app' task :development => 'build:development' do package config(:development) end task :dev => :development desc 'Create an installable Plex app' task :release => 'build:release' do package config(:release) end end task :package => 'package:release' namespace :pms do task :restart => [ :stop, :start ] desc 'Start Plex Media Server' task :start do exec '"' + PMS_BIN + '"' end task :stop do system 'killall', 'Plex Media Server' end end task :pms => 'pms:restart' namespace :install do desc 'Install a clean copy (do an uninstall:hard first)' task :clean => [ 'uninstall:hard', :install ] desc 'Install a development version of the plugin' task :development => [ 'build:development', :uninstall ] do - ln_s(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development))) + ln_sf(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development))) add_env_file :development, PLUGIN_BUNDLE_DIR end task :dev => :development desc 'Install a release version of the plugin' task :release => [ 'build:release', :uninstall ] do mkdir_p(PMS_PLUGIN_DIR + bundle_name(config)) cp_r(PLUGIN_BUILD_DIR + bundle_name(config), PMS_PLUGIN_DIR) add_env_file :release, PLUGIN_BUNDLE_DIR end end desc 'Alias for install:release' task :install => 'install:release' namespace :uninstall do desc 'Remove the installed bundle, but leave data behind.' task :soft do File.rm_if_exists(PMS_PLUGIN_DIR + bundle_name(config)) end desc 'Remove the installed bundle and data.' task :hard => :soft do files = FileList[ PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}.*", PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}" ] rm_rf files unless files.empty? end end desc 'Alias for uninstall:soft' task :uninstall => 'uninstall:soft' namespace :tail do logs = { :plex => [ 'Plex', File.expand_path("~/Library/Logs/Plex.log") ], :plugin => [ 'the plugin', File.expand_path("~/Library/Logs/PMS Plugin Logs/#{config['PLUGIN_ID']}.log") ] } def tail(logs) system "tail -f " << logs.collect { |log| "\"#{log}\"" }.join( ' ' ) end logs.each do |k,v| desc "Tail #{v[0]}'s log file" task(k) { tail [v[1]] } end desc 'Tail log files' task :all do tail logs.collect { |k,v| v[1] } end end desc 'Alias for tail:all' task :tail => 'tail:all'
ches/plex-vimcasts
00b8d603f0503e0cfae4acda8cf6528163bfb795
docs: explain how to install packaged build in README
diff --git a/README.rst b/README.rst index c7b5bd4..18d400c 100644 --- a/README.rst +++ b/README.rst @@ -1,57 +1,64 @@ ============= Plex-Vimcasts ============= A simple Plex_ plugin for vimcasts.org_, allowing you to view the screencasts from the comfort of your media center. +Installation +============ + +Assuming you already have a working Plex installation, grab the latest release +from `the downloads`_ and double-click to install. + Building From Source ==================== The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: - Git_ - Ruby_ & Rake_ (Both are bundled with OS X) - The rb-appscript_ RubyGem (``gem install rb-appscript``) With those tools installed, get a copy of the source and install the plugin:: $ git clone git://github.com/ches/plex-vimcasts.git $ cd plex-vimcasts $ rake install If you'd like to remove the plugin later, use:: $ rake uninstall Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data. To Do ===== - Proper plugin artwork, instead of stealing Railscasts' License ======= Under the same terms as Plex, GPLv2. Thanks ====== This, my first Plex plugin, is essentially a bunch of copy and paste! - Basically a clone of David Leatherman's `Railscasts plugin`_. - Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably overkill for this simple plugin, but it's a nice generalized example for other plugins to follow :-) .. _Plex: http://plexapp.com/ .. _vimcasts.org: http://vimcasts.org/ +.. _the downloads: http://github.com/ches/plex-vimcasts/downloads .. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3 .. _Ruby: http://www.ruby-lang.org/ .. _Rake: http://rake.rubyforge.org/ .. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html .. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin .. _MLB plugin: http://github.com/rfletcher/plex-mlb
ches/plex-vimcasts
e32d5dc98b43f811cfcab38effe83b289f9e5ff3
Alias `install` rake task to `install:release`, not `development`
diff --git a/Rakefile b/Rakefile index 7870e01..2b050c2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,281 +1,281 @@ # Lifted and adapted from Rick Fletcher's MLB plugin, hat tip is due: # http://github.com/rfletcher/plex-mlb # Overkill for this plugin really, but it's a nice general example build setup. require 'pathname' require 'rake' require 'rake/clean' require 'rake/packagetask' require 'tempfile' require 'yaml' require 'rubygems' require 'appscript' # Base Paths PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)).expand_path PLUGIN_BUNDLE_DIR = PLUGIN_ROOT + 'bundle' PLUGIN_BUILD_DIR = PLUGIN_ROOT + 'build' PLUGIN_DIST_DIR = PLUGIN_ROOT + 'dist' PLUGIN_TEMPLATE_DIR = PLUGIN_ROOT + 'templates' # Plex and Plex Media Server paths APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support").expand_path PLEX_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex' PMS_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex Media Server' PMS_PLUGIN_DIR = PMS_SUPPORT_DIR + 'Plug-ins' PMS_PLUGIN_DATA_DIR = PMS_SUPPORT_DIR + 'Plug-in Support' PMS_BIN = PLEX_SUPPORT_DIR + 'Plex Media Server.app/Contents/MacOS/Plex Media Server' def config(env=:release) @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml')[env.to_s] end PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_" # files to blow away with a `rake clean` and `clobber`. Clobber also cleans. CLEAN.include(PLUGIN_BUILD_DIR.to_s) CLOBBER.include(PLUGIN_DIST_DIR) # ============================================================================== # = HELPERS # ============================================================================== class File def self.binary?(name) fstat = stat(name) if !fstat.file? false else open(name) do |file| blk = file.read(fstat.blksize) blk.size == 0 || blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0 end end end def self.rm_if_exists(name) rm_rf name if self.exists? name end end def add_env_file(env, bundle_dir) File.open(File.join(bundle_dir, 'Contents', 'env'), 'w') do |f| f.write env.to_s end end def bundle_name(config) (config['PLUGIN_BUNDLE_NAME'] ? config['PLUGIN_BUNDLE_NAME'] : config['PLUGIN_NAME']) + '.bundle' end # Really lo-fi 'erb' :-) def erb(config, file) warning = <<-EOW DO NOT EDIT THIS FILE It was generated from a template. Your changes will be overwritten EOW comment = case File.extname(file).sub(/^\./, '').to_sym when :html, :xml, :plist then ['<!--', '-->'] when :py then ['"""', '"""'] when :rb then ['=begin', '=end'] end temp = Tempfile.new("erb") temp << '<?xml version="1.0" encoding="UTF-8"?>' << "\n" if File.extname(file) === ".xml" temp << [comment.first, warning].join("\n") << comment.last << "\n" File.open(file).each_line do |line| temp << line.gsub(/<%=(.*?)%>/) do prop = $1.strip if value = config[prop] value else raise "couldn't find property `#{prop}' (in #{file})" end end end temp.close mv(temp.path, file, :verbose => false) end # ============================================================================== # = TASKS # ============================================================================== task :default => :build namespace :build do def build_templates(config, build_dir) FileList[PLUGIN_TEMPLATE_DIR + '**/*'].each do |file| if File.file?(file) dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.to_s.length + 1, file.length]) dest_file = File.join dest_dir, File.basename(file) mkdir_p dest_dir cp file, dest_dir erb(config, dest_file) unless File.binary?(dest_file) end end end def build(env, config) File.rm_if_exists PLUGIN_BUILD_DIR mkdir_p PLUGIN_BUILD_DIR bundle_dir = PLUGIN_BUILD_DIR + bundle_name(config) cp_r PLUGIN_BUNDLE_DIR, bundle_dir add_env_file env, bundle_dir rm FileList[PLUGIN_BUILD_DIR + '**/*.pyc'] readme = Dir['README*'].first cp_r(readme, PLUGIN_BUILD_DIR + 'README.txt') if readme end desc 'Build a dev distribution.' task :development do build_templates config(:development), PLUGIN_BUNDLE_DIR build :development, config(:development) end task :dev => :development desc 'Build a release distribution.' task :release do build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config)) build :release, config end end desc 'Alias for build:development' task :build => 'build:development' namespace :package do def package(config) File.rm_if_exists PLUGIN_DIST_DIR mkdir_p PLUGIN_DIST_DIR Appscript.app('AppMaker').activate se = Appscript.app('System Events') am = se.processes['AppMaker'] am_window = am.windows['AppMaker'] am_window.actions['AXRaise'].perform [ PLUGIN_BUILD_DIR + bundle_name(config), config['PLUGIN_NAME'], config['PLUGIN_AUTHOR'], config['PLUGIN_VERSION'], config['PLUGIN_DESCRIPTION'] ].each_with_index do |value, i| i += 1 am_window.text_fields[i].value.set(value.to_s) am_window.text_fields[i].focused.set(true) if i == 1 am_window.text_fields[i].actions['AXConfirm'].perform else am_window.text_fields[i].key_code(124) am_window.text_fields[i].keystroke(" \b") end end am_window.UI_elements['Create Package'].click am.keystroke('g', :using => [ :command_down, :shift_down ]) am.keystroke(PLUGIN_DIST_DIR.to_s + "\r") am.keystroke((config['PLUGIN_NAME'] + '-' + config['PLUGIN_VERSION'].to_s).gsub(' ', '_') + "\r") # wait for save am_window.text_fields[1].focused.set(true) Appscript.app('AppMaker').quit end desc 'Create a dev-mode, installable Plex app' task :development => 'build:development' do package config(:development) end task :dev => :development desc 'Create an installable Plex app' task :release => 'build:release' do package config(:release) end end task :package => 'package:release' namespace :pms do task :restart => [ :stop, :start ] desc 'Start Plex Media Server' task :start do exec '"' + PMS_BIN + '"' end task :stop do system 'killall', 'Plex Media Server' end end task :pms => 'pms:restart' namespace :install do desc 'Install a clean copy (do an uninstall:hard first)' task :clean => [ 'uninstall:hard', :install ] desc 'Install a development version of the plugin' task :development => [ 'build:development', :uninstall ] do ln_s(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development))) add_env_file :development, PLUGIN_BUNDLE_DIR end task :dev => :development desc 'Install a release version of the plugin' task :release => [ 'build:release', :uninstall ] do mkdir_p(PMS_PLUGIN_DIR + bundle_name(config)) cp_r(PLUGIN_BUILD_DIR + bundle_name(config), PMS_PLUGIN_DIR) add_env_file :release, PLUGIN_BUNDLE_DIR end end -desc 'Alias for install:development' -task :install => 'install:development' +desc 'Alias for install:release' +task :install => 'install:release' namespace :uninstall do desc 'Remove the installed bundle, but leave data behind.' task :soft do File.rm_if_exists(PMS_PLUGIN_DIR + bundle_name(config)) end desc 'Remove the installed bundle and data.' task :hard => :soft do files = FileList[ PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}.*", PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}" ] rm_rf files unless files.empty? end end desc 'Alias for uninstall:soft' task :uninstall => 'uninstall:soft' namespace :tail do logs = { :plex => [ 'Plex', File.expand_path("~/Library/Logs/Plex.log") ], :plugin => [ 'the plugin', File.expand_path("~/Library/Logs/PMS Plugin Logs/#{config['PLUGIN_ID']}.log") ] } def tail(logs) system "tail -f " << logs.collect { |log| "\"#{log}\"" }.join( ' ' ) end logs.each do |k,v| desc "Tail #{v[0]}'s log file" task(k) { tail [v[1]] } end desc 'Tail log files' task :all do tail logs.collect { |k,v| v[1] } end end desc 'Alias for tail:all' task :tail => 'tail:all'
ches/plex-vimcasts
aa52ff4f9343ccfb5bb557ace5972da59cbd0f4b
build config refactoring; ready for initial release 0.9.0
diff --git a/.gitignore b/.gitignore index 21304f0..6eee3e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ .DS_Store *.pyc build +dist Framework +bundle/Contents/env # files generated from templates/ bundle/Contents/Info.plist diff --git a/README.rst b/README.rst index 0167af8..c7b5bd4 100644 --- a/README.rst +++ b/README.rst @@ -1,50 +1,57 @@ ============= Plex-Vimcasts ============= -A simple `Plex`_ plugin for `vimcasts.org`_, allowing you to view the +A simple Plex_ plugin for vimcasts.org_, allowing you to view the screencasts from the comfort of your media center. Building From Source ==================== -The `Plex-Vimcasts`_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: +The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need: -* Git_ -* Ruby_ & Rake_ (Both are bundled with OS X) +- Git_ +- Ruby_ & Rake_ (Both are bundled with OS X) +- The rb-appscript_ RubyGem (``gem install rb-appscript``) With those tools installed, get a copy of the source and install the plugin:: $ git clone git://github.com/ches/plex-vimcasts.git $ cd plex-vimcasts $ rake install If you'd like to remove the plugin later, use:: $ rake uninstall Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data. +To Do +===== + +- Proper plugin artwork, instead of stealing Railscasts' + License ======= Under the same terms as Plex, GPLv2. Thanks ====== This, my first Plex plugin, is essentially a bunch of copy and paste! - Basically a clone of David Leatherman's `Railscasts plugin`_. - Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably - overkill for this simple plugin, but especially as a Rubyist it may prove a - useful model for future plugins :-) + overkill for this simple plugin, but it's a nice generalized example for other + plugins to follow :-) .. _Plex: http://plexapp.com/ .. _vimcasts.org: http://vimcasts.org/ .. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3 .. _Ruby: http://www.ruby-lang.org/ .. _Rake: http://rake.rubyforge.org/ +.. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html .. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin .. _MLB plugin: http://github.com/rfletcher/plex-mlb diff --git a/Rakefile b/Rakefile index 0965d6d..7870e01 100644 --- a/Rakefile +++ b/Rakefile @@ -1,271 +1,281 @@ -# Lifted from Rick Fletcher's MLB plugin, hat tip is due: +# Lifted and adapted from Rick Fletcher's MLB plugin, hat tip is due: # http://github.com/rfletcher/plex-mlb +# Overkill for this plugin really, but it's a nice general example build setup. require 'pathname' require 'rake' require 'rake/clean' require 'rake/packagetask' require 'tempfile' require 'yaml' require 'rubygems' require 'appscript' # Base Paths -PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)) +PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)).expand_path PLUGIN_BUNDLE_DIR = PLUGIN_ROOT + 'bundle' PLUGIN_BUILD_DIR = PLUGIN_ROOT + 'build' +PLUGIN_DIST_DIR = PLUGIN_ROOT + 'dist' PLUGIN_TEMPLATE_DIR = PLUGIN_ROOT + 'templates' # Plex and Plex Media Server paths -APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support") +APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support").expand_path PLEX_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex' PMS_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex Media Server' PMS_PLUGIN_DIR = PMS_SUPPORT_DIR + 'Plug-ins' PMS_PLUGIN_DATA_DIR = PMS_SUPPORT_DIR + 'Plug-in Support' PMS_BIN = PLEX_SUPPORT_DIR + 'Plex Media Server.app/Contents/MacOS/Plex Media Server' +def config(env=:release) + @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml')[env.to_s] +end + +PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_" + +# files to blow away with a `rake clean` and `clobber`. Clobber also cleans. +CLEAN.include(PLUGIN_BUILD_DIR.to_s) +CLOBBER.include(PLUGIN_DIST_DIR) + +# ============================================================================== +# = HELPERS +# ============================================================================== + class File def self.binary?(name) fstat = stat(name) if !fstat.file? false else open(name) do |file| blk = file.read(fstat.blksize) blk.size == 0 || blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0 end end end def self.rm_if_exists(name) rm_rf name if self.exists? name end end -def add_env(env, bundle_dir) +def add_env_file(env, bundle_dir) File.open(File.join(bundle_dir, 'Contents', 'env'), 'w') do |f| f.write env.to_s end end def bundle_name(config) (config['PLUGIN_BUNDLE_NAME'] ? config['PLUGIN_BUNDLE_NAME'] : config['PLUGIN_NAME']) + '.bundle' end +# Really lo-fi 'erb' :-) def erb(config, file) warning = <<-EOW DO NOT EDIT THIS FILE It was generated from a template. Your changes will be overwritten EOW comment = case File.extname(file).sub(/^\./, '').to_sym when :html, :xml, :plist then ['<!--', '-->'] when :py then ['"""', '"""'] when :rb then ['=begin', '=end'] end temp = Tempfile.new("erb") temp << '<?xml version="1.0" encoding="UTF-8"?>' << "\n" if File.extname(file) === ".xml" temp << [comment.first, warning].join("\n") << comment.last << "\n" File.open(file).each_line do |line| temp << line.gsub(/<%=(.*?)%>/) do prop = $1.strip if value = config[prop] value else raise "couldn't find property `#{prop}' (in #{file})" end end end temp.close mv(temp.path, file, :verbose => false) end -def load_config(env=:release) - YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml'))[env.to_s] -end - -config = load_config - -PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_" - -# files to blow away with a `rake clobber` -CLOBBER.include(PLUGIN_BUILD_DIR, "#{PLUGIN_PACKAGE_NAME}.tar.gz") +# ============================================================================== +# = TASKS +# ============================================================================== task :default => :build namespace :build do def build_templates(config, build_dir) FileList[PLUGIN_TEMPLATE_DIR + '**/*'].each do |file| if File.file?(file) - dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.length + 1, file.length]) + dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.to_s.length + 1, file.length]) dest_file = File.join dest_dir, File.basename(file) mkdir_p dest_dir cp file, dest_dir erb(config, dest_file) unless File.binary?(dest_file) end end end def build(env, config) - File.rm_if_exists File.join(PLUGIN_BUILD_DIR) + File.rm_if_exists PLUGIN_BUILD_DIR mkdir_p PLUGIN_BUILD_DIR bundle_dir = PLUGIN_BUILD_DIR + bundle_name(config) cp_r PLUGIN_BUNDLE_DIR, bundle_dir - add_env env, bundle_dir + add_env_file env, bundle_dir rm FileList[PLUGIN_BUILD_DIR + '**/*.pyc'] readme = Dir['README*'].first cp_r(readme, PLUGIN_BUILD_DIR + 'README.txt') if readme end desc 'Build a dev distribution.' task :development do - build_templates load_config(:development), PLUGIN_BUNDLE_DIR - build :development, load_config(:development) + build_templates config(:development), PLUGIN_BUNDLE_DIR + build :development, config(:development) end task :dev => :development desc 'Build a release distribution.' task :release do + build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config)) build :release, config - build_templates config, File.join( PLUGIN_BUILD_DIR, bundle_name(config)) end end -desc 'Alias for build:release' -task :build => 'build:release' +desc 'Alias for build:development' +task :build => 'build:development' namespace :package do def package(config) + File.rm_if_exists PLUGIN_DIST_DIR + mkdir_p PLUGIN_DIST_DIR + Appscript.app('AppMaker').activate se = Appscript.app('System Events') am = se.processes['AppMaker'] am_window = am.windows['AppMaker'] am_window.actions['AXRaise'].perform [ PLUGIN_BUILD_DIR + bundle_name(config), config['PLUGIN_NAME'], config['PLUGIN_AUTHOR'], config['PLUGIN_VERSION'], config['PLUGIN_DESCRIPTION'] ].each_with_index do |value, i| i += 1 am_window.text_fields[i].value.set(value.to_s) am_window.text_fields[i].focused.set(true) if i == 1 am_window.text_fields[i].actions['AXConfirm'].perform else am_window.text_fields[i].key_code(124) am_window.text_fields[i].keystroke(" \b") end end am_window.UI_elements['Create Package'].click am.keystroke('g', :using => [ :command_down, :shift_down ]) - am.keystroke(PLUGIN_BUILD_DIR + "\r") + am.keystroke(PLUGIN_DIST_DIR.to_s + "\r") am.keystroke((config['PLUGIN_NAME'] + '-' + config['PLUGIN_VERSION'].to_s).gsub(' ', '_') + "\r") # wait for save am_window.text_fields[1].focused.set(true) Appscript.app('AppMaker').quit - end desc 'Create a dev-mode, installable Plex app' task :development => 'build:development' do - package load_config(:development) + package config(:development) end task :dev => :development desc 'Create an installable Plex app' task :release => 'build:release' do - package config + package config(:release) end end -task :package => 'package:release' do -end +task :package => 'package:release' namespace :pms do task :restart => [ :stop, :start ] desc 'Start Plex Media Server' task :start do exec '"' + PMS_BIN + '"' end task :stop do - system 'killall', 'Plex Media Server' + system 'killall', 'Plex Media Server' end end task :pms => 'pms:restart' namespace :install do desc 'Install a clean copy (do an uninstall:hard first)' task :clean => [ 'uninstall:hard', :install ] desc 'Install a development version of the plugin' task :development => [ 'build:development', :uninstall ] do - config = load_config :development - ln_s(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config)) - add_env :development, PLUGIN_BUNDLE_DIR + ln_s(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development))) + add_env_file :development, PLUGIN_BUNDLE_DIR end task :dev => :development desc 'Install a release version of the plugin' task :release => [ 'build:release', :uninstall ] do mkdir_p(PMS_PLUGIN_DIR + bundle_name(config)) cp_r(PLUGIN_BUILD_DIR + bundle_name(config), PMS_PLUGIN_DIR) - add_env :release, PLUGIN_BUNDLE_DIR + add_env_file :release, PLUGIN_BUNDLE_DIR end end -desc 'Alias for install:release' -task :install => 'install:release' +desc 'Alias for install:development' +task :install => 'install:development' namespace :uninstall do desc 'Remove the installed bundle, but leave data behind.' task :soft do File.rm_if_exists(PMS_PLUGIN_DIR + bundle_name(config)) end desc 'Remove the installed bundle and data.' task :hard => :soft do files = FileList[ PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}.*", PMS_PLUGIN_DATA_DIR + "*/#{config['PLUGIN_ID']}" ] rm_rf files unless files.empty? end end desc 'Alias for uninstall:soft' task :uninstall => 'uninstall:soft' namespace :tail do logs = { :plex => [ 'Plex', File.expand_path("~/Library/Logs/Plex.log") ], :plugin => [ 'the plugin', File.expand_path("~/Library/Logs/PMS Plugin Logs/#{config['PLUGIN_ID']}.log") ] } def tail(logs) system "tail -f " << logs.collect { |log| "\"#{log}\"" }.join( ' ' ) end logs.each do |k,v| desc "Tail #{v[0]}'s log file" task(k) { tail [v[1]] } end desc 'Tail log files' task :all do tail logs.collect { |k,v| v[1] } end end desc 'Alias for tail:all' task :tail => 'tail:all' diff --git a/bundle/Contents/config.yml b/bundle/Contents/config.yml new file mode 100644 index 0000000..bf5a1de --- /dev/null +++ b/bundle/Contents/config.yml @@ -0,0 +1,43 @@ +# Plugin configuration +# +# This configuration setup allows for easy, environment-specific configuration. +# Its settings can be inserted into other files at build-time, or loaded by +# python code at run-time with PyYAML. + +# Default settings. This is never read directly. Instead, it's extended by +# other sections below. +default: &default + PLUGIN_ID: com.plexapp.plugins.vimcasts + PLUGIN_NAME: Vimcasts + PLUGIN_PREFIX: /video/vimcasts + PLUGIN_VERSION: 0.9.0 + PLUGIN_AUTHOR: Ches Martin <[email protected]> + PLUGIN_DESCRIPTION: | + Vimcasts publishes regular screencasts about the Vim text editor. Episodes + are kept short – typically less than 5 minutes, never more than 10. The aim + is to provide something in each episode that you can take away and use. + + Vimcasts is produced by Drew Neil (aka nelstrom). + + VERSION_IN_PLUGIN_NAME: false + + CACHE_TTL: 3600 + + PLIST_DEBUG: 0 + PLIST_DEV_MODE: 0 + +# override some values when building a dev release +development: + <<: *default + VERSION_IN_PLUGIN_NAME: true + + # disable caching + CACHE_TTL: 0 + + # turn on dev mode (no auto-updates), and debug + PLIST_DEBUG: 1 + PLIST_DEV_MODE: 1 + +# release version inherits defaults +release: + <<: *default diff --git a/templates/Contents/Info.plist b/templates/Contents/Info.plist index 2c9a598..60b193b 100644 --- a/templates/Contents/Info.plist +++ b/templates/Contents/Info.plist @@ -1,28 +1,28 @@ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>Hello</string> <key>CFBundleIdentifier</key> <string><%= PLUGIN_ID %></string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundlePackageType</key> <string>AAPL</string> <key>CFBundleSignature</key> <string>hook</string> <key>CFBundleVersion</key> <string>1.0</string> <key>PlexPluginMode</key> <string>AlwaysOn</string> <key>PlexFrameworkVersion</key> - <string>1</string> + <string>2</string> <key>PlexPluginDebug</key> <string><%= PLIST_DEBUG %></string> <key>PlexPluginDevMode</key> <string><%= PLIST_DEV_MODE %></string> </dict> </plist> \ No newline at end of file
fabiokr/cakephp-load_url-component
3581db5327a4f092b0618e085f7544a9fae89642
refactor as plugin
diff --git a/controllers/components/load_url.php b/controllers/components/load_url.php new file mode 100644 index 0000000..6e04b27 --- /dev/null +++ b/controllers/components/load_url.php @@ -0,0 +1,214 @@ +<?php + +/** + * Load URL Component component + */ + +class LoadUrlComponent extends Object { + + /** + * See http://www.bin-co.com/php/scripts/load/ + * Version : 2.00.A + */ + function load($url,$options=array()) { + $default_options = array( + 'method' => 'get', + 'return_info' => false, + 'return_body' => true, + 'cache' => false, + 'referer' => '', + 'headers' => array(), + 'session' => false, + 'session_close' => false, + ); + // Sets the default options. + foreach($default_options as $opt=>$value) { + if(!isset($options[$opt])) $options[$opt] = $value; + } + + if(strrpos($url, 'http')===false) { + $url = 'http://'.$url; + } + + $url_parts = parse_url($url); + $ch = false; + $info = array(//Currently only supported by curl. + 'http_code' => 200 + ); + $response = ''; + + $send_header = array( + 'Accept' => 'text/*', + 'User-Agent' => 'BinGet/1.00.A (http://www.bin-co.com/php/scripts/load/)' + ) + $options['headers']; // Add custom headers provided by the user. + + if($options['cache']) { + $cache_folder = '/tmp/php-load-function/'; + if(isset($options['cache_folder'])) $cache_folder = $options['cache_folder']; + if(!file_exists($cache_folder)) { + $old_umask = umask(0); // Or the folder will not get write permission for everybody. + mkdir($cache_folder, 0777); + umask($old_umask); + } + + $cache_file_name = md5($url) . '.cache'; + $cache_file = joinPath($cache_folder, $cache_file_name); //Don't change the variable name - used at the end of the function. + + if(file_exists($cache_file)) { // Cached file exists - return that. + $response = file_get_contents($cache_file); + + //Seperate header and content + $separator_position = strpos($response,"\r\n\r\n"); + $header_text = substr($response,0,$separator_position); + $body = substr($response,$separator_position+4); + + foreach(explode("\n",$header_text) as $line) { + $parts = explode(": ",$line); + if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); + } + $headers['cached'] = true; + + if(!$options['return_info']) return $body; + else return array('headers' => $headers, 'body' => $body, 'info' => array('cached'=>true)); + } + } + + ///////////////////////////// Curl ///////////////////////////////////// + //If curl is available, use curl to get the data. + if(function_exists("curl_init") + and (!(isset($options['use']) and $options['use'] == 'fsocketopen'))) { //Don't use curl if it is specifically stated to use fsocketopen in the options + + if(isset($options['post_data'])) { //There is an option to specify some data to be posted. + $page = $url; + $options['method'] = 'post'; + + if(is_array($options['post_data'])) { //The data is in array format. + $post_data = array(); + foreach($options['post_data'] as $key=>$value) { + $post_data[] = "$key=" . urlencode($value); + } + $url_parts['query'] = implode('&', $post_data); + + } else { //Its a string + $url_parts['query'] = $options['post_data']; + } + } else { + if(isset($options['method']) and $options['method'] == 'post') { + $page = $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path']; + } else { + $page = $url; + } + } + + if($options['session'] and isset($GLOBALS['_binget_curl_session'])) $ch = $GLOBALS['_binget_curl_session']; //Session is stored in a global variable + else $ch = curl_init($url_parts['host']); + + curl_setopt($ch, CURLOPT_URL, $page) or die("Invalid cURL Handle Resouce"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Just return the data - not print the whole thing. + curl_setopt($ch, CURLOPT_HEADER, true); //We need the headers + curl_setopt($ch, CURLOPT_NOBODY, !($options['return_body'])); //The content - if true, will not download the contents. There is a ! operation - don't remove it. + if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) { + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $url_parts['query']); + } + //Set the headers our spiders sends + curl_setopt($ch, CURLOPT_USERAGENT, $send_header['User-Agent']); //The Name of the UserAgent we will be using ;) + $custom_headers = array("Accept: " . $send_header['Accept'] ); + if(isset($options['modified_since'])) + array_push($custom_headers,"If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since']))); + curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); + if($options['referer']) curl_setopt($ch, CURLOPT_REFERER, $options['referer']); + + curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/binget-cookie.txt"); //If ever needed... + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 5); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + if(isset($url_parts['user']) and isset($url_parts['pass'])) { + $custom_headers = array("Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass'])); + curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); + } + + $response = curl_exec($ch); + $info = curl_getinfo($ch); //Some information on the fetch + + if($options['session'] and !$options['session_close']) $GLOBALS['_binget_curl_session'] = $ch; //Dont close the curl session. We may need it later - save it to a global variable + else curl_close($ch); //If the session option is not set, close the session. + + //////////////////////////////////////////// FSockOpen ////////////////////////////// + } else { //If there is no curl, use fsocketopen - but keep in mind that most advanced features will be lost with this approch. + if(isset($url_parts['query'])) { + if(isset($options['method']) and $options['method'] == 'post') + $page = $url_parts['path']; + else + $page = $url_parts['path'] . '?' . $url_parts['query']; + } else { + $page = $url_parts['path']; + } + + if(!isset($url_parts['port'])) $url_parts['port'] = 80; + $fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, 30); + if ($fp) { + $out = ''; + if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) { + $out .= "POST $page HTTP/1.1\r\n"; + } else { + $out .= "GET $page HTTP/1.0\r\n"; //HTTP/1.0 is much easier to handle than HTTP/1.1 + } + $out .= "Host: $url_parts[host]\r\n"; + $out .= "Accept: $send_header[Accept]\r\n"; + $out .= "User-Agent: {$send_header['User-Agent']}\r\n"; + if(isset($options['modified_since'])) + $out .= "If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since'])) ."\r\n"; + + $out .= "Connection: Close\r\n"; + + //HTTP Basic Authorization support + if(isset($url_parts['user']) and isset($url_parts['pass'])) { + $out .= "Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass']) . "\r\n"; + } + + //If the request is post - pass the data in a special way. + if(isset($options['method']) and $options['method'] == 'post' and $url_parts['query']) { + $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $out .= 'Content-Length: ' . strlen($url_parts['query']) . "\r\n"; + $out .= "\r\n" . $url_parts['query']; + } + $out .= "\r\n"; + + fwrite($fp, $out); + while (!feof($fp)) { + $response .= fgets($fp, 128); + } + fclose($fp); + } + } + + //Get the headers in an associative array + $headers = array(); + + if($info['http_code'] == 404) { + $body = ""; + $headers['Status'] = 404; + } else { + //Seperate header and content + $header_text = substr($response, 0, $info['header_size']); + $body = substr($response, $info['header_size']); + + foreach(explode("\n",$header_text) as $line) { + $parts = explode(": ",$line); + if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); + } + } + + if(isset($cache_file)) { //Should we cache the URL? + file_put_contents($cache_file, $response); + } + + if($options['return_info']) return array('headers' => $headers, 'body' => $body, 'info' => $info, 'curl_handle'=>$ch); + return $body; + } + +} + +?>
fabiokr/cakephp-load_url-component
52c44f04e0999e9da4b612dd8d8022eef4d608ad
Added http to address if don't exists
diff --git a/load_url.php b/load_url.php index 39e208d..6e04b27 100644 --- a/load_url.php +++ b/load_url.php @@ -1,210 +1,214 @@ <?php /** * Load URL Component component */ class LoadUrlComponent extends Object { /** * See http://www.bin-co.com/php/scripts/load/ * Version : 2.00.A */ function load($url,$options=array()) { $default_options = array( 'method' => 'get', 'return_info' => false, 'return_body' => true, 'cache' => false, 'referer' => '', 'headers' => array(), 'session' => false, 'session_close' => false, ); // Sets the default options. foreach($default_options as $opt=>$value) { if(!isset($options[$opt])) $options[$opt] = $value; } + + if(strrpos($url, 'http')===false) { + $url = 'http://'.$url; + } $url_parts = parse_url($url); $ch = false; $info = array(//Currently only supported by curl. 'http_code' => 200 ); $response = ''; $send_header = array( 'Accept' => 'text/*', 'User-Agent' => 'BinGet/1.00.A (http://www.bin-co.com/php/scripts/load/)' ) + $options['headers']; // Add custom headers provided by the user. if($options['cache']) { $cache_folder = '/tmp/php-load-function/'; if(isset($options['cache_folder'])) $cache_folder = $options['cache_folder']; if(!file_exists($cache_folder)) { $old_umask = umask(0); // Or the folder will not get write permission for everybody. mkdir($cache_folder, 0777); umask($old_umask); } $cache_file_name = md5($url) . '.cache'; $cache_file = joinPath($cache_folder, $cache_file_name); //Don't change the variable name - used at the end of the function. if(file_exists($cache_file)) { // Cached file exists - return that. $response = file_get_contents($cache_file); //Seperate header and content $separator_position = strpos($response,"\r\n\r\n"); $header_text = substr($response,0,$separator_position); $body = substr($response,$separator_position+4); foreach(explode("\n",$header_text) as $line) { $parts = explode(": ",$line); if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); } $headers['cached'] = true; if(!$options['return_info']) return $body; else return array('headers' => $headers, 'body' => $body, 'info' => array('cached'=>true)); } } ///////////////////////////// Curl ///////////////////////////////////// //If curl is available, use curl to get the data. if(function_exists("curl_init") and (!(isset($options['use']) and $options['use'] == 'fsocketopen'))) { //Don't use curl if it is specifically stated to use fsocketopen in the options if(isset($options['post_data'])) { //There is an option to specify some data to be posted. $page = $url; $options['method'] = 'post'; if(is_array($options['post_data'])) { //The data is in array format. $post_data = array(); foreach($options['post_data'] as $key=>$value) { $post_data[] = "$key=" . urlencode($value); } $url_parts['query'] = implode('&', $post_data); } else { //Its a string $url_parts['query'] = $options['post_data']; } } else { if(isset($options['method']) and $options['method'] == 'post') { $page = $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path']; } else { $page = $url; } } if($options['session'] and isset($GLOBALS['_binget_curl_session'])) $ch = $GLOBALS['_binget_curl_session']; //Session is stored in a global variable else $ch = curl_init($url_parts['host']); curl_setopt($ch, CURLOPT_URL, $page) or die("Invalid cURL Handle Resouce"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Just return the data - not print the whole thing. curl_setopt($ch, CURLOPT_HEADER, true); //We need the headers curl_setopt($ch, CURLOPT_NOBODY, !($options['return_body'])); //The content - if true, will not download the contents. There is a ! operation - don't remove it. if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $url_parts['query']); } //Set the headers our spiders sends curl_setopt($ch, CURLOPT_USERAGENT, $send_header['User-Agent']); //The Name of the UserAgent we will be using ;) $custom_headers = array("Accept: " . $send_header['Accept'] ); if(isset($options['modified_since'])) array_push($custom_headers,"If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since']))); curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); if($options['referer']) curl_setopt($ch, CURLOPT_REFERER, $options['referer']); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/binget-cookie.txt"); //If ever needed... curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if(isset($url_parts['user']) and isset($url_parts['pass'])) { $custom_headers = array("Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass'])); curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); } $response = curl_exec($ch); $info = curl_getinfo($ch); //Some information on the fetch if($options['session'] and !$options['session_close']) $GLOBALS['_binget_curl_session'] = $ch; //Dont close the curl session. We may need it later - save it to a global variable else curl_close($ch); //If the session option is not set, close the session. //////////////////////////////////////////// FSockOpen ////////////////////////////// } else { //If there is no curl, use fsocketopen - but keep in mind that most advanced features will be lost with this approch. if(isset($url_parts['query'])) { if(isset($options['method']) and $options['method'] == 'post') $page = $url_parts['path']; else $page = $url_parts['path'] . '?' . $url_parts['query']; } else { $page = $url_parts['path']; } if(!isset($url_parts['port'])) $url_parts['port'] = 80; $fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, 30); if ($fp) { $out = ''; if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) { $out .= "POST $page HTTP/1.1\r\n"; } else { $out .= "GET $page HTTP/1.0\r\n"; //HTTP/1.0 is much easier to handle than HTTP/1.1 } $out .= "Host: $url_parts[host]\r\n"; $out .= "Accept: $send_header[Accept]\r\n"; $out .= "User-Agent: {$send_header['User-Agent']}\r\n"; if(isset($options['modified_since'])) $out .= "If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since'])) ."\r\n"; $out .= "Connection: Close\r\n"; //HTTP Basic Authorization support if(isset($url_parts['user']) and isset($url_parts['pass'])) { $out .= "Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass']) . "\r\n"; } //If the request is post - pass the data in a special way. if(isset($options['method']) and $options['method'] == 'post' and $url_parts['query']) { $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= 'Content-Length: ' . strlen($url_parts['query']) . "\r\n"; $out .= "\r\n" . $url_parts['query']; } $out .= "\r\n"; fwrite($fp, $out); while (!feof($fp)) { $response .= fgets($fp, 128); } fclose($fp); } } //Get the headers in an associative array $headers = array(); if($info['http_code'] == 404) { $body = ""; $headers['Status'] = 404; } else { //Seperate header and content $header_text = substr($response, 0, $info['header_size']); $body = substr($response, $info['header_size']); foreach(explode("\n",$header_text) as $line) { $parts = explode(": ",$line); if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); } } if(isset($cache_file)) { //Should we cache the URL? file_put_contents($cache_file, $response); } if($options['return_info']) return array('headers' => $headers, 'body' => $body, 'info' => $info, 'curl_handle'=>$ch); return $body; } } ?>
fabiokr/cakephp-load_url-component
d1bd00c5d9653569b37843ac393f3ce11b2b1156
Started component
diff --git a/load_url.php b/load_url.php new file mode 100644 index 0000000..39e208d --- /dev/null +++ b/load_url.php @@ -0,0 +1,210 @@ +<?php + +/** + * Load URL Component component + */ + +class LoadUrlComponent extends Object { + + /** + * See http://www.bin-co.com/php/scripts/load/ + * Version : 2.00.A + */ + function load($url,$options=array()) { + $default_options = array( + 'method' => 'get', + 'return_info' => false, + 'return_body' => true, + 'cache' => false, + 'referer' => '', + 'headers' => array(), + 'session' => false, + 'session_close' => false, + ); + // Sets the default options. + foreach($default_options as $opt=>$value) { + if(!isset($options[$opt])) $options[$opt] = $value; + } + + $url_parts = parse_url($url); + $ch = false; + $info = array(//Currently only supported by curl. + 'http_code' => 200 + ); + $response = ''; + + $send_header = array( + 'Accept' => 'text/*', + 'User-Agent' => 'BinGet/1.00.A (http://www.bin-co.com/php/scripts/load/)' + ) + $options['headers']; // Add custom headers provided by the user. + + if($options['cache']) { + $cache_folder = '/tmp/php-load-function/'; + if(isset($options['cache_folder'])) $cache_folder = $options['cache_folder']; + if(!file_exists($cache_folder)) { + $old_umask = umask(0); // Or the folder will not get write permission for everybody. + mkdir($cache_folder, 0777); + umask($old_umask); + } + + $cache_file_name = md5($url) . '.cache'; + $cache_file = joinPath($cache_folder, $cache_file_name); //Don't change the variable name - used at the end of the function. + + if(file_exists($cache_file)) { // Cached file exists - return that. + $response = file_get_contents($cache_file); + + //Seperate header and content + $separator_position = strpos($response,"\r\n\r\n"); + $header_text = substr($response,0,$separator_position); + $body = substr($response,$separator_position+4); + + foreach(explode("\n",$header_text) as $line) { + $parts = explode(": ",$line); + if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); + } + $headers['cached'] = true; + + if(!$options['return_info']) return $body; + else return array('headers' => $headers, 'body' => $body, 'info' => array('cached'=>true)); + } + } + + ///////////////////////////// Curl ///////////////////////////////////// + //If curl is available, use curl to get the data. + if(function_exists("curl_init") + and (!(isset($options['use']) and $options['use'] == 'fsocketopen'))) { //Don't use curl if it is specifically stated to use fsocketopen in the options + + if(isset($options['post_data'])) { //There is an option to specify some data to be posted. + $page = $url; + $options['method'] = 'post'; + + if(is_array($options['post_data'])) { //The data is in array format. + $post_data = array(); + foreach($options['post_data'] as $key=>$value) { + $post_data[] = "$key=" . urlencode($value); + } + $url_parts['query'] = implode('&', $post_data); + + } else { //Its a string + $url_parts['query'] = $options['post_data']; + } + } else { + if(isset($options['method']) and $options['method'] == 'post') { + $page = $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path']; + } else { + $page = $url; + } + } + + if($options['session'] and isset($GLOBALS['_binget_curl_session'])) $ch = $GLOBALS['_binget_curl_session']; //Session is stored in a global variable + else $ch = curl_init($url_parts['host']); + + curl_setopt($ch, CURLOPT_URL, $page) or die("Invalid cURL Handle Resouce"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Just return the data - not print the whole thing. + curl_setopt($ch, CURLOPT_HEADER, true); //We need the headers + curl_setopt($ch, CURLOPT_NOBODY, !($options['return_body'])); //The content - if true, will not download the contents. There is a ! operation - don't remove it. + if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) { + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $url_parts['query']); + } + //Set the headers our spiders sends + curl_setopt($ch, CURLOPT_USERAGENT, $send_header['User-Agent']); //The Name of the UserAgent we will be using ;) + $custom_headers = array("Accept: " . $send_header['Accept'] ); + if(isset($options['modified_since'])) + array_push($custom_headers,"If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since']))); + curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); + if($options['referer']) curl_setopt($ch, CURLOPT_REFERER, $options['referer']); + + curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/binget-cookie.txt"); //If ever needed... + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 5); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + if(isset($url_parts['user']) and isset($url_parts['pass'])) { + $custom_headers = array("Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass'])); + curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); + } + + $response = curl_exec($ch); + $info = curl_getinfo($ch); //Some information on the fetch + + if($options['session'] and !$options['session_close']) $GLOBALS['_binget_curl_session'] = $ch; //Dont close the curl session. We may need it later - save it to a global variable + else curl_close($ch); //If the session option is not set, close the session. + + //////////////////////////////////////////// FSockOpen ////////////////////////////// + } else { //If there is no curl, use fsocketopen - but keep in mind that most advanced features will be lost with this approch. + if(isset($url_parts['query'])) { + if(isset($options['method']) and $options['method'] == 'post') + $page = $url_parts['path']; + else + $page = $url_parts['path'] . '?' . $url_parts['query']; + } else { + $page = $url_parts['path']; + } + + if(!isset($url_parts['port'])) $url_parts['port'] = 80; + $fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, 30); + if ($fp) { + $out = ''; + if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) { + $out .= "POST $page HTTP/1.1\r\n"; + } else { + $out .= "GET $page HTTP/1.0\r\n"; //HTTP/1.0 is much easier to handle than HTTP/1.1 + } + $out .= "Host: $url_parts[host]\r\n"; + $out .= "Accept: $send_header[Accept]\r\n"; + $out .= "User-Agent: {$send_header['User-Agent']}\r\n"; + if(isset($options['modified_since'])) + $out .= "If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since'])) ."\r\n"; + + $out .= "Connection: Close\r\n"; + + //HTTP Basic Authorization support + if(isset($url_parts['user']) and isset($url_parts['pass'])) { + $out .= "Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass']) . "\r\n"; + } + + //If the request is post - pass the data in a special way. + if(isset($options['method']) and $options['method'] == 'post' and $url_parts['query']) { + $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $out .= 'Content-Length: ' . strlen($url_parts['query']) . "\r\n"; + $out .= "\r\n" . $url_parts['query']; + } + $out .= "\r\n"; + + fwrite($fp, $out); + while (!feof($fp)) { + $response .= fgets($fp, 128); + } + fclose($fp); + } + } + + //Get the headers in an associative array + $headers = array(); + + if($info['http_code'] == 404) { + $body = ""; + $headers['Status'] = 404; + } else { + //Seperate header and content + $header_text = substr($response, 0, $info['header_size']); + $body = substr($response, $info['header_size']); + + foreach(explode("\n",$header_text) as $line) { + $parts = explode(": ",$line); + if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); + } + } + + if(isset($cache_file)) { //Should we cache the URL? + file_put_contents($cache_file, $response); + } + + if($options['return_info']) return array('headers' => $headers, 'body' => $body, 'info' => $info, 'curl_handle'=>$ch); + return $body; + } + +} + +?>
raskhadafi/radiant-reservation-extension
7e8d35093e5c4d5a0e18f0d2b24a45995879b63d
admin area works fine now
diff --git a/app/controllers/admin/reservations_controller.rb b/app/controllers/admin/reservations_controller.rb index 72b79f4..8bdb9cd 100644 --- a/app/controllers/admin/reservations_controller.rb +++ b/app/controllers/admin/reservations_controller.rb @@ -1,41 +1,56 @@ class Admin::ReservationsController < ApplicationController def index @reservation_items = ReservationItem.find(:all) @reservation_subscribers = ReservationSubscriber.find(:all) render(:action => 'index') end def new @reservation = Reservation.new @reservation_subscriber = ReservationSubscriber.find(:all) @reservation_item = ReservationItem.find(params[:id]) render(:action => 'edit') end + + def edit + @reservation = Reservation.find(params[:id]) + @reservation_item = ReservationItem.find(@reservation.reservation_item_id) + @reservation_subscriber = ReservationSubscriber.find(:all) + render(:action => 'edit') + end def create + @reservation_item = ReservationItem.find(params[:reservation][:reservation_item]) + params[:reservation][:reservation_item] = @reservation_item + @reservation_subscriber = ReservationSubscriber.find(:all) + params[:reservation][:reservation_subscriber] = ReservationSubscriber.find(params[:reservation][:reservation_subscriber]) + params[:reservation][:from] @reservation = Reservation.new(params[:reservation]) if @reservation.save - redirect_to(:back) + redirect_to(edit_admin_reservation_item_url(@reservation_item)) else render(:action => 'edit') end end def update @reservation = Reservation.find(params[:id]) + @reservation_item = ReservationItem.find(params[:reservation][:reservation_item]) + params[:reservation][:reservation_item] = @reservation_item + params[:reservation][:reservation_subscriber] = ReservationSubscriber.find(params[:reservation][:reservation_subscriber]) if @reservation.update_attributes(params[:reservation]) - redirect_to(:back) + redirect_to(edit_admin_reservation_item_url(@reservation_item)) else render(:action => 'edit') end end def destroy @reservation = Reservation.find(params[:id]) @reservation.destroy flash[:error] = "The reservation was deleted." redirect_to(:back) end end diff --git a/app/models/reservation_subscriber.rb b/app/models/reservation_subscriber.rb index 4a97e08..ef21249 100644 --- a/app/models/reservation_subscriber.rb +++ b/app/models/reservation_subscriber.rb @@ -1,9 +1,9 @@ class ReservationSubscriber < ActiveRecord::Base validates_presence_of :user_name validates_uniqueness_of :user_name validates_presence_of :email validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i has_many :reservations - + end diff --git a/app/views/admin/reservation_items/edit.html.haml b/app/views/admin/reservation_items/edit.html.haml index f1cb7e5..37a2649 100644 --- a/app/views/admin/reservation_items/edit.html.haml +++ b/app/views/admin/reservation_items/edit.html.haml @@ -1,60 +1,70 @@ - include_javascript 'admin/reservation' - content_for 'page_css' do :sass p.new a color: #000 border: 1px solid #ddf padding: 6px text-decoration: none &:hover background: #efefff p.title margin: 10px 0 !important #content .form-area div.error-with-field input.textbox font-family: Georgia,Palatino,"Times New Roman",Times,serif font-size: 200% width: 100% table.index th font-weight: bold %h1= @reservation_item.new_record? ? 'New Item' : 'Edit Item' - form_for [:admin, @reservation_item] do |f| .form-area %p.title %label Name = f.text_field :name, :class => 'textbox' %p.title %label Description = f.text_area :description, :class => 'textbox' %p.buttons - button_text = @reservation_item.new_record? ? 'Create' : 'Save Changes' = submit_tag button_text, :class => 'button' or = link_to 'Cancel', admin_reservations_url %table#reservation_item.index{:summary => "Listing of Reservations"} %thead %tr %th Subscriber %th From %th To + %th Edit %tbody - if @reservation_item.reservations.empty? %tr - %td.note{:colspan => 3} No reservations + %td.note{:colspan => 4} No reservations - else - @reservation_item.reservations.each do |reservation| %tr.node.level-1{:id => "reservation-#{reservation.id}"} %td.page %span.w1 - = link_to reservation.name, edit_admin_reservation_url(reservation) + = link_to reservation.reservation_subscriber.first_name, edit_admin_reservation_url(reservation) + %td.page + %span + = reservation.from.strftime("%d. %B %Y [%H:%m]") + %td.page + %span + = reservation.to.strftime("%d. %B %Y [%H:%m]") + %td.remove + = link_to("#{image('minus.png')} Remove", admin_reservation_url(reservation), :method => :delete, :alt => 'remove item', :confirm => 'Are you sure? This will delete the reservation!') + %p.new= link_to 'New Reservation', :id => @reservation_item.id, :controller => 'reservations', :action => :new diff --git a/app/views/admin/reservations/edit.html.haml b/app/views/admin/reservations/edit.html.haml index e809444..24ab47c 100644 --- a/app/views/admin/reservations/edit.html.haml +++ b/app/views/admin/reservations/edit.html.haml @@ -1,32 +1,33 @@ - content_for 'page_css' do :sass p.title margin: 10px 0 !important #content .form-area div.error-with-field input.textbox font-family: Georgia,Palatino,"Times New Roman",Times,serif font-size: 200% width: 100% = calendar_date_select_includes %h1= @reservation.new_record? ? 'New Reservation of '+@reservation_item.name : 'Edit Reservation of '+@reservation_item.name - form_for [:admin, @reservation] do |f| .form-area %p.title %label Subscriber = f.select :reservation_subscriber, @reservation_subscriber.collect{|l| [l.first_name+' '+l.last_name, l.id]} %p.title %label From = calendar_date_select :reservation, :from, :time => true, :embedded => true, :class => 'textbox' %p.title %label To = calendar_date_select :reservation, :to, :time => true, :embedded => true, :class => 'textbox' + = f.hidden_field :reservation_item, :value => @reservation_item.id %p.buttons - button_text = @reservation.new_record? ? 'Create' : 'Save Changes' = submit_tag button_text, :class => 'button' or = link_to('Cancel', :back)
raskhadafi/radiant-reservation-extension
aab58384187be58e41be4428705ed0e0f567ab25
change the password to password_field
diff --git a/app/views/admin/reservation_subscribers/edit.html.haml b/app/views/admin/reservation_subscribers/edit.html.haml index f0a8454..2d30676 100644 --- a/app/views/admin/reservation_subscribers/edit.html.haml +++ b/app/views/admin/reservation_subscribers/edit.html.haml @@ -1,42 +1,42 @@ - content_for 'page_css' do :sass p.title margin: 10px 0 !important #content .form-area div.error-with-field input.textbox font-family: Georgia,Palatino,"Times New Roman",Times,serif font-size: 200% width: 100% %h1= @reservation_subscriber.new_record? ? 'New Subscriber' : 'Edit Subscriber' - form_for [:admin, @reservation_subscriber] do |f| .form-area %p.title %label User name = f.text_field :user_name, :class => 'textbox' %p.title %label Password - = f.text_field :password, :class => 'textbox', :type => "password" + = f.password_field :password, :class => 'textbox', :type => "password" %p.title %label First name = f.text_field :first_name, :class => 'textbox' %p.title %label Last name = f.text_field :last_name, :class => 'textbox' %p.title %label Phone number = f.text_field :phone, :class => 'textbox' %p.title %label E-Mail = f.text_field :email, :class => 'textbox' %p.title %label Addresse = f.text_area :address, :class => 'textbox' %p.buttons - button_text = @reservation_subscriber.new_record? ? 'Create' : 'Save Changes' = submit_tag button_text, :class => 'button' or = link_to 'Cancel', admin_reservations_url
raskhadafi/radiant-reservation-extension
770eaa2590259df73f4777cc8a975b1a5fc9bb79
expanded the validation of reservation_subscriber model
diff --git a/app/models/reservation_subscriber.rb b/app/models/reservation_subscriber.rb index 3127142..4a97e08 100644 --- a/app/models/reservation_subscriber.rb +++ b/app/models/reservation_subscriber.rb @@ -1,8 +1,9 @@ class ReservationSubscriber < ActiveRecord::Base validates_presence_of :user_name validates_uniqueness_of :user_name validates_presence_of :email validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i + has_many :reservations end
raskhadafi/radiant-reservation-extension
1bc2e0292f791ed9aaa0cb40bd4710119f6fe088
expanded the validation of reservation_subscriber model
diff --git a/public/javascripts/admin/reservation.js b/public/javascripts/admin/reservation.js new file mode 100644 index 0000000..59b2ed2 --- /dev/null +++ b/public/javascripts/admin/reservation.js @@ -0,0 +1,10 @@ +document.observe("dom:loaded", function() { + + $('a#new-reservation').observe('click', respondToClick); + +}); + +function respondToClick(event) { + var element = event.element(); + element.addClassName('active'); +}
raskhadafi/radiant-reservation-extension
2eeaed8994623167b010d25e6d9214681f7c00bd
new reservation model
diff --git a/app/models/reservation.rb b/app/models/reservation.rb new file mode 100644 index 0000000..1969532 --- /dev/null +++ b/app/models/reservation.rb @@ -0,0 +1,9 @@ +class Reservation < ActiveRecord::Base + belongs_to :reservation_item + belongs_to :reservation_subscriber + validates_presence_of :reservation_item + validates_presence_of :reservation_subscriber + validates_presence_of :from + validates_presence_of :to + +end diff --git a/app/views/admin/reservations/edit.html.haml b/app/views/admin/reservations/edit.html.haml new file mode 100644 index 0000000..e809444 --- /dev/null +++ b/app/views/admin/reservations/edit.html.haml @@ -0,0 +1,32 @@ +- content_for 'page_css' do + :sass + p.title + margin: 10px 0 !important + + #content .form-area div.error-with-field + input.textbox + font-family: Georgia,Palatino,"Times New Roman",Times,serif + font-size: 200% + width: 100% + += calendar_date_select_includes + +%h1= @reservation.new_record? ? 'New Reservation of '+@reservation_item.name : 'Edit Reservation of '+@reservation_item.name + +- form_for [:admin, @reservation] do |f| + .form-area + %p.title + %label Subscriber + = f.select :reservation_subscriber, @reservation_subscriber.collect{|l| [l.first_name+' '+l.last_name, l.id]} + %p.title + %label From + = calendar_date_select :reservation, :from, :time => true, :embedded => true, :class => 'textbox' + %p.title + %label To + = calendar_date_select :reservation, :to, :time => true, :embedded => true, :class => 'textbox' + + %p.buttons + - button_text = @reservation.new_record? ? 'Create' : 'Save Changes' + = submit_tag button_text, :class => 'button' + or + = link_to('Cancel', :back) diff --git a/app/views/admin/reservations/index.html.haml b/app/views/admin/reservations/index.html.haml index b152e75..9e73210 100644 --- a/app/views/admin/reservations/index.html.haml +++ b/app/views/admin/reservations/index.html.haml @@ -1,91 +1,91 @@ - content_for 'page_css' do :sass #content p.new a color: #000 border: 1px solid #ddf padding: 6px text-decoration: none &:hover background: #efefff table.index th font-weight: bold .remove width: 100px td.remove width: 100px font-size: 0.8em vertical-align: center a text-decoration: none color: #000 img margin-bottom: 3px #content #reservation-items.index .page .info top: 0 %h1 Reservation items %table#reservation-items.index{:summary => "Listing of Reservation Items"} %thead %tr %th.name Name %th.description Description %th.modify Remove %tbody - if @reservation_items.empty? %tr %td.note{:colspan => 3} No items - else - @reservation_items.each do |reservation_item| - %tr.node.level-1{:id => "event-#{reservation_item.id}"} + %tr.node.level-1{:id => "reservation-#{reservation_item.id}"} %td.page %span.w1 = link_to reservation_item.name, edit_admin_reservation_item_url(reservation_item) %td.reservation-item= reservation_item.description %td.remove = link_to("#{image('minus.png')} Remove", admin_reservation_item_url(reservation_item), :method => :delete, :alt => 'remove item', :confirm => 'Are you sure? This will delete the item!') %p.new= link_to('New Item', new_admin_reservation_item_url) %br %h1 Subscriber %table#reservation-subscriber.index{:summary => "Listing of all Subscribers"} %thead %tr %th.name Name %th.phone Phone number %th.email E-Mail %th.modify Remove %tbody - if @reservation_subscribers.empty? %tr %td.note{:colspan => 3} No reservation_subscribers - else - @reservation_subscribers.each do |reservation_subscriber| %tr.node.level-1{:id => "event-#{reservation_subscriber.id}"} %td.page %span.w1 = link_to reservation_subscriber.first_name, edit_admin_reservation_subscriber_url(reservation_subscriber) %td %span = reservation_subscriber.phone %td.page %span = link_to(reservation_subscriber.email, "mailto://"+reservation_subscriber.email) %td.remove = link_to("#{image('minus.png')} Remove", admin_reservation_subscriber_url(reservation_subscriber), :method => :delete, :alt => 'remove subscriber', :confirm => 'Are you sure? This will delete this subscriber!') %p.new= link_to('New Subscriber', new_admin_reservation_subscriber_url) diff --git a/db/migrate/003_create_reservations.rb b/db/migrate/003_create_reservations.rb new file mode 100644 index 0000000..78840be --- /dev/null +++ b/db/migrate/003_create_reservations.rb @@ -0,0 +1,16 @@ +class CreateReservations < ActiveRecord::Migration + def self.up + create_table :reservations do |t| + t.references :reservation_item + t.references :reservation_subscriber + t.datetime :from + t.datetime :to + + t.timestamps + end + end + + def self.down + drop_table :reservations + end +end diff --git a/spec/models/reservation_spec.rb b/spec/models/reservation_spec.rb new file mode 100644 index 0000000..08418a8 --- /dev/null +++ b/spec/models/reservation_spec.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Reservation do + before(:each) do + @reservation = Reservation.new + end + + it "should be valid" do + @reservation.should be_valid + end +end
raskhadafi/radiant-reservation-extension
6c6e54d4294910a0b1b3bb9d462a436ba68329eb
new model reservation_item
diff --git a/app/models/reservation_item.rb b/app/models/reservation_item.rb index fb4e165..04be701 100644 --- a/app/models/reservation_item.rb +++ b/app/models/reservation_item.rb @@ -1,12 +1,13 @@ class ReservationItem < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name + has_many :reservations def self.upcoming self.find(:all) end def self.next self.find(:first) end end diff --git a/app/views/admin/reservation_items/edit.html.haml b/app/views/admin/reservation_items/edit.html.haml index fc5447e..f1cb7e5 100644 --- a/app/views/admin/reservation_items/edit.html.haml +++ b/app/views/admin/reservation_items/edit.html.haml @@ -1,27 +1,60 @@ +- include_javascript 'admin/reservation' - content_for 'page_css' do :sass + p.new + a + color: #000 + border: 1px solid #ddf + padding: 6px + text-decoration: none + + &:hover + background: #efefff p.title margin: 10px 0 !important - #content .form-area div.error-with-field - input.textbox - font-family: Georgia,Palatino,"Times New Roman",Times,serif - font-size: 200% - width: 100% + #content + .form-area + div.error-with-field + input.textbox + font-family: Georgia,Palatino,"Times New Roman",Times,serif + font-size: 200% + width: 100% + table.index + th + font-weight: bold %h1= @reservation_item.new_record? ? 'New Item' : 'Edit Item' - form_for [:admin, @reservation_item] do |f| .form-area %p.title %label Name = f.text_field :name, :class => 'textbox' %p.title %label Description = f.text_area :description, :class => 'textbox' - %p.buttons - button_text = @reservation_item.new_record? ? 'Create' : 'Save Changes' = submit_tag button_text, :class => 'button' or = link_to 'Cancel', admin_reservations_url + +%table#reservation_item.index{:summary => "Listing of Reservations"} + %thead + %tr + %th Subscriber + %th From + %th To + %tbody + - if @reservation_item.reservations.empty? + %tr + %td.note{:colspan => 3} No reservations + - else + - @reservation_item.reservations.each do |reservation| + %tr.node.level-1{:id => "reservation-#{reservation.id}"} + %td.page + %span.w1 + = link_to reservation.name, edit_admin_reservation_url(reservation) + +%p.new= link_to 'New Reservation', :id => @reservation_item.id, :controller => 'reservations', :action => :new
raskhadafi/radiant-reservation-extension
590442c261efa23bbbf1bca6bf885d27431bde5a
new reserations controller
diff --git a/app/controllers/admin/reservations_controller.rb b/app/controllers/admin/reservations_controller.rb index 9efb276..72b79f4 100644 --- a/app/controllers/admin/reservations_controller.rb +++ b/app/controllers/admin/reservations_controller.rb @@ -1,14 +1,41 @@ class Admin::ReservationsController < ApplicationController def index @reservation_items = ReservationItem.find(:all) @reservation_subscribers = ReservationSubscriber.find(:all) render(:action => 'index') end def new @reservation = Reservation.new + @reservation_subscriber = ReservationSubscriber.find(:all) + @reservation_item = ReservationItem.find(params[:id]) render(:action => 'edit') end + def create + @reservation = Reservation.new(params[:reservation]) + if @reservation.save + redirect_to(:back) + else + render(:action => 'edit') + end + end + + def update + @reservation = Reservation.find(params[:id]) + if @reservation.update_attributes(params[:reservation]) + redirect_to(:back) + else + render(:action => 'edit') + end + end + + def destroy + @reservation = Reservation.find(params[:id]) + @reservation.destroy + flash[:error] = "The reservation was deleted." + redirect_to(:back) + end + end
raskhadafi/radiant-reservation-extension
1fc2c270130227c43caea8164ae1523f6d83a359
new license and readme
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2a748ba --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2009 Roman Simecek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README b/README index e69de29..a0b33ef 100644 --- a/README +++ b/README @@ -0,0 +1,18 @@ +Radiant *Reservation* Extension +====================================== +<table> + <tr> + <td>Author</td> + <td>Roman Simecek</td> + </tr> + <tr> + <td>Contact:</td> + <td>roman AT good2go DOT ch</td> + </tr> +</table> + +License +------- + +This extension is released under the MIT license, see the [LICENSE](master/LICENSE) for more +information.
raskhadafi/radiant-reservation-extension
f932627f1b6559f150d962305d22dab7aa314b86
new model reservation created
diff --git a/app/controllers/admin/reservations_controller.rb b/app/controllers/admin/reservations_controller.rb index a25489b..9efb276 100644 --- a/app/controllers/admin/reservations_controller.rb +++ b/app/controllers/admin/reservations_controller.rb @@ -1,14 +1,14 @@ class Admin::ReservationsController < ApplicationController def index @reservation_items = ReservationItem.find(:all) @reservation_subscribers = ReservationSubscriber.find(:all) render(:action => 'index') end def new @reservation = Reservation.new - render(:action => 'index') + render(:action => 'edit') end end
raskhadafi/radiant-reservation-extension
8c36b6910cec9dc86a01de4d1ed54e06022a86fc
changed the tab name to Reservations
diff --git a/reservation_extension.rb b/reservation_extension.rb index 9340bdc..e94cf51 100644 --- a/reservation_extension.rb +++ b/reservation_extension.rb @@ -1,23 +1,23 @@ # Uncomment this if you reference any of your controllers in activate # require_dependency 'application' class ReservationExtension < Radiant::Extension version "0.1" description "Small Reservation System" url "http://github.com/simerom/radiant-reservation-extension" define_routes do |map| map.namespace :admin, :member => { :remove => :get } do |admin| admin.resources :reservations, :reservation_items, :reservation_subscribers end end def activate - admin.tabs.add "Reservation Sytem", "/admin/reservations", :after => "Layouts", :visibility => [:all] + admin.tabs.add "Reservations", "/admin/reservations", :after => "Layouts", :visibility => [:all] end def deactivate - admin.tabs.remove "Reservation System" + admin.tabs.remove "Reservations" end end
raskhadafi/radiant-reservation-extension
08d9296295eebd391f885ac4de85acc4d14e3bb8
reservation item & subscriber models added with functionality create, update and delete
diff --git a/app/controllers/admin/reservation_items_controller.rb b/app/controllers/admin/reservation_items_controller.rb index a3f55e2..b9be20a 100644 --- a/app/controllers/admin/reservation_items_controller.rb +++ b/app/controllers/admin/reservation_items_controller.rb @@ -1,45 +1,38 @@ class Admin::ReservationItemsController < ApplicationController - def index - @reservation_items = ReservationItem.find(:all) - render(:action => 'index') - end def new @reservation_item = ReservationItem.new render(:action => 'edit') end + def edit + @reservation_item = ReservationItem.find(params[:id]) + render(:action => 'edit') + end + def create @reservation_item = ReservationItem.new(params[:reservation_item]) if @reservation_item.save - flash[:notice] = "Successfully added a new ReservationItem." - redirect_to(admin_reservation_items_path) + redirect_to(admin_reservations_path) else - flash[:error] = "Validation errors occurred while processing this form. Please take a moment to review the form and correct any input errors before continuing." render(:action => 'edit') end end - def edit - @reservation_item = ReservationItem.find(params[:id]) - render(:action => 'edit') - end - def update @reservation_item = ReservationItem.find(params[:id]) if @reservation_item.update_attributes(params[:reservation_item]) - flash[:notice] = "Successfully updated the ReservationItem details." - redirect_to(admin_reservation_items_path) + redirect_to(admin_reservations_path) else - flash[:error] = "Validation errors occurred while processing this form. Please take a moment to review the form and correct any input errors before continuing." render(:action => 'edit') end end def destroy @reservation_item = ReservationItem.find(params[:id]) @reservation_item.destroy - flash[:error] = "The ReservationItem was deleted." - redirect_to(admin_reservation_items_path) + flash[:error] = "The item was deleted." + redirect_to(admin_reservations_path) end + end diff --git a/app/controllers/admin/reservation_subscribers_controller.rb b/app/controllers/admin/reservation_subscribers_controller.rb new file mode 100644 index 0000000..f31a920 --- /dev/null +++ b/app/controllers/admin/reservation_subscribers_controller.rb @@ -0,0 +1,31 @@ +class Admin::ReservationSubscribersController < ApplicationController + + def new + @reservation_subscriber = ReservationSubscriber.new + render(:action => 'edit') + end + + def edit + @reservation_subscriber = ReservationSubscriber.find(params[:id]) + render(:action => 'edit') + end + + def create + @reservation_subscriber = ReservationSubscriber.new(params[:reservation_subscriber]) + if @reservation_subscriber.save + redirect_to(admin_reservations_path) + else + render(:action => 'edit') + end + end + + def update + @reservation_subscriber = ReservationSubscriber.find(params[:id]) + if @reservation_subscriber.update_attributes(params[:reservation_subscriber]) + redirect_to(admin_reservations_path) + else + render(:action => 'edit') + end + end + +end diff --git a/app/controllers/admin/reservations_controller.rb b/app/controllers/admin/reservations_controller.rb new file mode 100644 index 0000000..a25489b --- /dev/null +++ b/app/controllers/admin/reservations_controller.rb @@ -0,0 +1,14 @@ +class Admin::ReservationsController < ApplicationController + + def index + @reservation_items = ReservationItem.find(:all) + @reservation_subscribers = ReservationSubscriber.find(:all) + render(:action => 'index') + end + + def new + @reservation = Reservation.new + render(:action => 'index') + end + +end diff --git a/app/models/reservation_item.rb b/app/models/reservation_item.rb index 4eac8ab..fb4e165 100644 --- a/app/models/reservation_item.rb +++ b/app/models/reservation_item.rb @@ -1,12 +1,12 @@ class ReservationItem < ActiveRecord::Base - validates_presence_of :name, :description + validates_presence_of :name validates_uniqueness_of :name def self.upcoming self.find(:all) end def self.next self.find(:first) end end diff --git a/app/models/reservation_subscriber.rb b/app/models/reservation_subscriber.rb index 28921e8..3127142 100644 --- a/app/models/reservation_subscriber.rb +++ b/app/models/reservation_subscriber.rb @@ -1,12 +1,8 @@ class ReservationSubscriber < ActiveRecord::Base - validates_presence_of :name, :description - validates_uniqueness_of :name + validates_presence_of :user_name + validates_uniqueness_of :user_name + validates_presence_of :email + validates_format_of :email, + :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i - def self.upcoming - self.find(:all) - end - - def self.next - self.find(:first) - end end diff --git a/app/views/admin/reservation_items/edit.html.haml b/app/views/admin/reservation_items/edit.html.haml index e2c288e..fc5447e 100644 --- a/app/views/admin/reservation_items/edit.html.haml +++ b/app/views/admin/reservation_items/edit.html.haml @@ -1,29 +1,27 @@ - content_for 'page_css' do :sass p.title margin: 10px 0 !important #content .form-area div.error-with-field input.textbox font-family: Georgia,Palatino,"Times New Roman",Times,serif font-size: 200% width: 100% -= calendar_date_select_includes - %h1= @reservation_item.new_record? ? 'New Item' : 'Edit Item' - form_for [:admin, @reservation_item] do |f| .form-area %p.title %label Name = f.text_field :name, :class => 'textbox' %p.title %label Description = f.text_area :description, :class => 'textbox' %p.buttons - button_text = @reservation_item.new_record? ? 'Create' : 'Save Changes' = submit_tag button_text, :class => 'button' or - = link_to 'Cancel', admin_reservation_items_url + = link_to 'Cancel', admin_reservations_url diff --git a/app/views/admin/reservation_items/index.html.haml b/app/views/admin/reservation_items/index.html.haml deleted file mode 100644 index 9ab3991..0000000 --- a/app/views/admin/reservation_items/index.html.haml +++ /dev/null @@ -1,68 +0,0 @@ -- content_for 'page_css' do - :sass - p.new - a - color: #000 - border: 1px solid #ddf - padding: 6px - text-decoration: none - - &:hover - background: #efefff - - th.remove - width: 100px - - td.remove - width: 100px - font-size: 0.8em - vertical-align: center - - a - text-decoration: none - color: #000 - - img - margin-bottom: 3px - - #content #reservation-items.index .page .info - top: 0 - -%h1 Reservation items - -%table#reservation-items.index{:summary => "Listing of Reservation Items"} - %thead - %tr - %th.name Name - %th.description Description - %th.modify Remove - %tbody - - if @reservation_items.empty? - %tr - %td.note{:colspan => 3} No items - - else - - @reservation_items.each do |reservation_item| - %tr.node.level-1{:id => "event-#{reservation_item.id}"} - %td.page - %span.w1 - = link_to reservation_item.name, edit_admin_reservation_item_url(reservation_item) - - %td.reservation-item= reservation_item.description - %td.remove - = link_to("#{image('minus.png')} Remove", admin_reservation_item_url(reservation_item), :method => :delete, :alt => 'remove item', :confirm => 'Are you sure? This will delete the item!') - -%p.new= link_to('New Item', new_admin_reservation_item_url) - -%br - -%h1 Subscriber - -%table#reservation-subscriber.index{:summary => "Listing of all Subscribers"} - %thead - %tr - %th.name Name - %th.phone Phone number - %th.modify Remove - %tbody - -%p.new= link_to('New Subscriber', new_admin_reservation_subscriber_url) diff --git a/app/views/admin/reservation_subscribers/edit.html.haml b/app/views/admin/reservation_subscribers/edit.html.haml index b75f0d1..f0a8454 100644 --- a/app/views/admin/reservation_subscribers/edit.html.haml +++ b/app/views/admin/reservation_subscribers/edit.html.haml @@ -1,27 +1,42 @@ - content_for 'page_css' do :sass p.title margin: 10px 0 !important #content .form-area div.error-with-field input.textbox font-family: Georgia,Palatino,"Times New Roman",Times,serif font-size: 200% width: 100% %h1= @reservation_subscriber.new_record? ? 'New Subscriber' : 'Edit Subscriber' - form_for [:admin, @reservation_subscriber] do |f| .form-area %p.title - %label Name + %label User name + = f.text_field :user_name, :class => 'textbox' + %p.title + %label Password + = f.text_field :password, :class => 'textbox', :type => "password" + %p.title + %label First name = f.text_field :first_name, :class => 'textbox' %p.title - %label Description - = f.text_area :note, :class => 'textbox' + %label Last name + = f.text_field :last_name, :class => 'textbox' + %p.title + %label Phone number + = f.text_field :phone, :class => 'textbox' + %p.title + %label E-Mail + = f.text_field :email, :class => 'textbox' + %p.title + %label Addresse + = f.text_area :address, :class => 'textbox' %p.buttons - button_text = @reservation_subscriber.new_record? ? 'Create' : 'Save Changes' = submit_tag button_text, :class => 'button' or - = link_to 'Cancel', admin_reservation_subscribers_url + = link_to 'Cancel', admin_reservations_url diff --git a/app/views/admin/reservations/index.html.haml b/app/views/admin/reservations/index.html.haml new file mode 100644 index 0000000..b152e75 --- /dev/null +++ b/app/views/admin/reservations/index.html.haml @@ -0,0 +1,91 @@ +- content_for 'page_css' do + :sass + #content + p.new + a + color: #000 + border: 1px solid #ddf + padding: 6px + text-decoration: none + + &:hover + background: #efefff + table.index + th + font-weight: bold + .remove + width: 100px + + td.remove + width: 100px + font-size: 0.8em + vertical-align: center + + a + text-decoration: none + color: #000 + + img + margin-bottom: 3px + + #content #reservation-items.index .page .info + top: 0 + +%h1 Reservation items + +%table#reservation-items.index{:summary => "Listing of Reservation Items"} + %thead + %tr + %th.name Name + %th.description Description + %th.modify Remove + %tbody + - if @reservation_items.empty? + %tr + %td.note{:colspan => 3} No items + - else + - @reservation_items.each do |reservation_item| + %tr.node.level-1{:id => "event-#{reservation_item.id}"} + %td.page + %span.w1 + = link_to reservation_item.name, edit_admin_reservation_item_url(reservation_item) + + %td.reservation-item= reservation_item.description + %td.remove + = link_to("#{image('minus.png')} Remove", admin_reservation_item_url(reservation_item), :method => :delete, :alt => 'remove item', :confirm => 'Are you sure? This will delete the item!') + +%p.new= link_to('New Item', new_admin_reservation_item_url) + +%br + +%h1 Subscriber + +%table#reservation-subscriber.index{:summary => "Listing of all Subscribers"} + %thead + %tr + %th.name Name + %th.phone Phone number + %th.email E-Mail + %th.modify Remove + %tbody + - if @reservation_subscribers.empty? + %tr + %td.note{:colspan => 3} No reservation_subscribers + - else + - @reservation_subscribers.each do |reservation_subscriber| + %tr.node.level-1{:id => "event-#{reservation_subscriber.id}"} + %td.page + %span.w1 + = link_to reservation_subscriber.first_name, edit_admin_reservation_subscriber_url(reservation_subscriber) + %td + %span + = reservation_subscriber.phone + %td.page + %span + = link_to(reservation_subscriber.email, "mailto://"+reservation_subscriber.email) + %td.remove + = link_to("#{image('minus.png')} Remove", admin_reservation_subscriber_url(reservation_subscriber), :method => :delete, :alt => 'remove subscriber', :confirm => 'Are you sure? This will delete this subscriber!') + + + +%p.new= link_to('New Subscriber', new_admin_reservation_subscriber_url) diff --git a/db/migrate/002_create_reservation_subscibers.rb b/db/migrate/002_create_reservation_subscribers.rb similarity index 56% rename from db/migrate/002_create_reservation_subscibers.rb rename to db/migrate/002_create_reservation_subscribers.rb index 871cec0..8d95ecd 100644 --- a/db/migrate/002_create_reservation_subscibers.rb +++ b/db/migrate/002_create_reservation_subscribers.rb @@ -1,16 +1,19 @@ class CreateReservationSubscribers < ActiveRecord::Migration def self.up create_table :reservation_subscribers do |t| - t.string :first_name - t.string :last_name - t.string :phone - t.string :email - t.text :notes + t.string :first_name + t.string :last_name + t.string :user_name + t.string :password + t.string :phone + t.string :email + t.text :address + t.timestamps end end def self.down drop_table :reservation_subscribers end end diff --git a/reservation_extension.rb b/reservation_extension.rb index 5e5356c..9340bdc 100644 --- a/reservation_extension.rb +++ b/reservation_extension.rb @@ -1,23 +1,23 @@ # Uncomment this if you reference any of your controllers in activate # require_dependency 'application' class ReservationExtension < Radiant::Extension version "0.1" description "Small Reservation System" url "http://github.com/simerom/radiant-reservation-extension" define_routes do |map| map.namespace :admin, :member => { :remove => :get } do |admin| - admin.resources :reservation_items, :reservation_subscribers + admin.resources :reservations, :reservation_items, :reservation_subscribers end end def activate - admin.tabs.add "Reservation", "/admin/reservation_items", :after => "Layouts", :visibility => [:all] + admin.tabs.add "Reservation Sytem", "/admin/reservations", :after => "Layouts", :visibility => [:all] end def deactivate - admin.tabs.remove "Reservation" + admin.tabs.remove "Reservation System" end end diff --git a/spec/controllers/reservation_subscribers_controller_spec.rb b/spec/controllers/reservation_subscribers_controller_spec.rb new file mode 100644 index 0000000..f8c5ae5 --- /dev/null +++ b/spec/controllers/reservation_subscribers_controller_spec.rb @@ -0,0 +1,25 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe ReservationSubscribersController do + + #Delete these examples and add some real ones + it "should use ReservationSubscribersController" do + controller.should be_an_instance_of(ReservationSubscribersController) + end + + + it "GET 'new' should be successful" do + get 'new' + response.should be_success + end + + it "GET 'edit' should be successful" do + get 'edit' + response.should be_success + end + + it "GET 'list' should be successful" do + get 'list' + response.should be_success + end +end diff --git a/spec/controllers/reservations_controller_spec.rb b/spec/controllers/reservations_controller_spec.rb new file mode 100644 index 0000000..099e836 --- /dev/null +++ b/spec/controllers/reservations_controller_spec.rb @@ -0,0 +1,25 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe ReservationsController do + + #Delete these examples and add some real ones + it "should use ReservationsController" do + controller.should be_an_instance_of(ReservationsController) + end + + + it "GET 'new_reservation' should be successful" do + get 'new_reservation' + response.should be_success + end + + it "GET 'new_user' should be successful" do + get 'new_user' + response.should be_success + end + + it "GET 'new_reservation_item' should be successful" do + get 'new_reservation_item' + response.should be_success + end +end diff --git a/spec/helpers/reservation_subscribers_helper_spec.rb b/spec/helpers/reservation_subscribers_helper_spec.rb new file mode 100644 index 0000000..44a6b3a --- /dev/null +++ b/spec/helpers/reservation_subscribers_helper_spec.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe ReservationSubscribersHelper do + + #Delete this example and add some real ones or delete this file + it "should include the ReservationSubscribersHelper" do + included_modules = self.metaclass.send :included_modules + included_modules.should include(ReservationSubscribersHelper) + end + +end diff --git a/spec/helpers/reservations_helper_spec.rb b/spec/helpers/reservations_helper_spec.rb new file mode 100644 index 0000000..fede9e5 --- /dev/null +++ b/spec/helpers/reservations_helper_spec.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe ReservationsHelper do + + #Delete this example and add some real ones or delete this file + it "should include the ReservationsHelper" do + included_modules = self.metaclass.send :included_modules + included_modules.should include(ReservationsHelper) + end + +end diff --git a/spec/models/reservation_subscriber_spec.rb b/spec/models/reservation_subscriber_spec.rb new file mode 100644 index 0000000..291426b --- /dev/null +++ b/spec/models/reservation_subscriber_spec.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe ReservationSubscriber do + before(:each) do + @reservation_subscriber = ReservationSubscriber.new + end + + it "should be valid" do + @reservation_subscriber.should be_valid + end +end diff --git a/spec/views/reservation_subscribers/edit_view_spec.rb b/spec/views/reservation_subscribers/edit_view_spec.rb new file mode 100644 index 0000000..2e5bf1d --- /dev/null +++ b/spec/views/reservation_subscribers/edit_view_spec.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/reservation_subscribers/edit" do + before do + render 'reservation_subscribers/edit' + end + + #Delete this example and add some real ones or delete this file + it "should tell you where to find the file" do + response.should have_tag('p', 'Find me in app/views/reservation_subscribers/edit.rhtml') + end +end diff --git a/spec/views/reservation_subscribers/list_view_spec.rb b/spec/views/reservation_subscribers/list_view_spec.rb new file mode 100644 index 0000000..ec1ead3 --- /dev/null +++ b/spec/views/reservation_subscribers/list_view_spec.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/reservation_subscribers/list" do + before do + render 'reservation_subscribers/list' + end + + #Delete this example and add some real ones or delete this file + it "should tell you where to find the file" do + response.should have_tag('p', 'Find me in app/views/reservation_subscribers/list.rhtml') + end +end diff --git a/spec/views/reservation_subscribers/new_view_spec.rb b/spec/views/reservation_subscribers/new_view_spec.rb new file mode 100644 index 0000000..2300fdf --- /dev/null +++ b/spec/views/reservation_subscribers/new_view_spec.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/reservation_subscribers/new" do + before do + render 'reservation_subscribers/new' + end + + #Delete this example and add some real ones or delete this file + it "should tell you where to find the file" do + response.should have_tag('p', 'Find me in app/views/reservation_subscribers/new.rhtml') + end +end diff --git a/spec/views/reservations/new_reservation_item_view_spec.rb b/spec/views/reservations/new_reservation_item_view_spec.rb new file mode 100644 index 0000000..a220fff --- /dev/null +++ b/spec/views/reservations/new_reservation_item_view_spec.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/reservations/new_reservation_item" do + before do + render 'reservations/new_reservation_item' + end + + #Delete this example and add some real ones or delete this file + it "should tell you where to find the file" do + response.should have_tag('p', 'Find me in app/views/reservations/new_reservation_item.rhtml') + end +end diff --git a/spec/views/reservations/new_reservation_view_spec.rb b/spec/views/reservations/new_reservation_view_spec.rb new file mode 100644 index 0000000..ee0825c --- /dev/null +++ b/spec/views/reservations/new_reservation_view_spec.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/reservations/new_reservation" do + before do + render 'reservations/new_reservation' + end + + #Delete this example and add some real ones or delete this file + it "should tell you where to find the file" do + response.should have_tag('p', 'Find me in app/views/reservations/new_reservation.rhtml') + end +end diff --git a/spec/views/reservations/new_user_view_spec.rb b/spec/views/reservations/new_user_view_spec.rb new file mode 100644 index 0000000..a6e4e59 --- /dev/null +++ b/spec/views/reservations/new_user_view_spec.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "/reservations/new_user" do + before do + render 'reservations/new_user' + end + + #Delete this example and add some real ones or delete this file + it "should tell you where to find the file" do + response.should have_tag('p', 'Find me in app/views/reservations/new_user.rhtml') + end +end
raskhadafi/radiant-reservation-extension
ba928e56bdce548bf22254d0687d31471481b222
initial reservation extension commit
diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..1266576 --- /dev/null +++ b/Rakefile @@ -0,0 +1,120 @@ +# I think this is the one that should be moved to the extension Rakefile template + +# In rails 1.2, plugins aren't available in the path until they're loaded. +# Check to see if the rspec plugin is installed first and require +# it if it is. If not, use the gem version. + +# Determine where the RSpec plugin is by loading the boot +unless defined? RADIANT_ROOT + ENV["RAILS_ENV"] = "test" + case + when ENV["RADIANT_ENV_FILE"] + require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot" + when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions} + require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot" + else + require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot" + end +end + +require 'rake' +require 'rake/rdoctask' +require 'rake/testtask' + +rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib') +$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base) +require 'spec/rake/spectask' +# require 'spec/translator' + +# Cleanup the RADIANT_ROOT constant so specs will load the environment +Object.send(:remove_const, :RADIANT_ROOT) + +extension_root = File.expand_path(File.dirname(__FILE__)) + +task :default => :spec +task :stats => "spec:statsetup" + +desc "Run all specs in spec directory" +Spec::Rake::SpecTask.new(:spec) do |t| + t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""] + t.spec_files = FileList['spec/**/*_spec.rb'] +end + +namespace :spec do + desc "Run all specs in spec directory with RCov" + Spec::Rake::SpecTask.new(:rcov) do |t| + t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""] + t.spec_files = FileList['spec/**/*_spec.rb'] + t.rcov = true + t.rcov_opts = ['--exclude', 'spec', '--rails'] + end + + desc "Print Specdoc for all specs" + Spec::Rake::SpecTask.new(:doc) do |t| + t.spec_opts = ["--format", "specdoc", "--dry-run"] + t.spec_files = FileList['spec/**/*_spec.rb'] + end + + [:models, :controllers, :views, :helpers].each do |sub| + desc "Run the specs under spec/#{sub}" + Spec::Rake::SpecTask.new(sub) do |t| + t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""] + t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] + end + end + + # Hopefully no one has written their extensions in pre-0.9 style + # desc "Translate specs from pre-0.9 to 0.9 style" + # task :translate do + # translator = ::Spec::Translator.new + # dir = RAILS_ROOT + '/spec' + # translator.translate(dir, dir) + # end + + # Setup specs for stats + task :statsetup do + require 'code_statistics' + ::STATS_DIRECTORIES << %w(Model\ specs spec/models) + ::STATS_DIRECTORIES << %w(View\ specs spec/views) + ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) + ::STATS_DIRECTORIES << %w(Helper\ specs spec/views) + ::CodeStatistics::TEST_TYPES << "Model specs" + ::CodeStatistics::TEST_TYPES << "View specs" + ::CodeStatistics::TEST_TYPES << "Controller specs" + ::CodeStatistics::TEST_TYPES << "Helper specs" + ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/} + end + + namespace :db do + namespace :fixtures do + desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y" + task :load => :environment do + require 'active_record/fixtures' + ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| + Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*')) + end + end + end + end +end + +desc 'Generate documentation for the reservation extension.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'ReservationExtension' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +# For extensions that are in transition +desc 'Test the reservation extension.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.pattern = 'test/**/*_test.rb' + t.verbose = true +end + +# Load any custom rakefiles for extension +Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f } \ No newline at end of file diff --git a/app/controllers/admin/reservation_items_controller.rb b/app/controllers/admin/reservation_items_controller.rb new file mode 100644 index 0000000..a3f55e2 --- /dev/null +++ b/app/controllers/admin/reservation_items_controller.rb @@ -0,0 +1,45 @@ +class Admin::ReservationItemsController < ApplicationController + def index + @reservation_items = ReservationItem.find(:all) + render(:action => 'index') + end + + def new + @reservation_item = ReservationItem.new + render(:action => 'edit') + end + + def create + @reservation_item = ReservationItem.new(params[:reservation_item]) + if @reservation_item.save + flash[:notice] = "Successfully added a new ReservationItem." + redirect_to(admin_reservation_items_path) + else + flash[:error] = "Validation errors occurred while processing this form. Please take a moment to review the form and correct any input errors before continuing." + render(:action => 'edit') + end + end + + def edit + @reservation_item = ReservationItem.find(params[:id]) + render(:action => 'edit') + end + + def update + @reservation_item = ReservationItem.find(params[:id]) + if @reservation_item.update_attributes(params[:reservation_item]) + flash[:notice] = "Successfully updated the ReservationItem details." + redirect_to(admin_reservation_items_path) + else + flash[:error] = "Validation errors occurred while processing this form. Please take a moment to review the form and correct any input errors before continuing." + render(:action => 'edit') + end + end + + def destroy + @reservation_item = ReservationItem.find(params[:id]) + @reservation_item.destroy + flash[:error] = "The ReservationItem was deleted." + redirect_to(admin_reservation_items_path) + end +end diff --git a/app/models/reservation_item.rb b/app/models/reservation_item.rb new file mode 100644 index 0000000..4eac8ab --- /dev/null +++ b/app/models/reservation_item.rb @@ -0,0 +1,12 @@ +class ReservationItem < ActiveRecord::Base + validates_presence_of :name, :description + validates_uniqueness_of :name + + def self.upcoming + self.find(:all) + end + + def self.next + self.find(:first) + end +end diff --git a/app/models/reservation_subscriber.rb b/app/models/reservation_subscriber.rb new file mode 100644 index 0000000..28921e8 --- /dev/null +++ b/app/models/reservation_subscriber.rb @@ -0,0 +1,12 @@ +class ReservationSubscriber < ActiveRecord::Base + validates_presence_of :name, :description + validates_uniqueness_of :name + + def self.upcoming + self.find(:all) + end + + def self.next + self.find(:first) + end +end diff --git a/app/views/admin/reservation_items/edit.html.haml b/app/views/admin/reservation_items/edit.html.haml new file mode 100644 index 0000000..e2c288e --- /dev/null +++ b/app/views/admin/reservation_items/edit.html.haml @@ -0,0 +1,29 @@ +- content_for 'page_css' do + :sass + p.title + margin: 10px 0 !important + + #content .form-area div.error-with-field + input.textbox + font-family: Georgia,Palatino,"Times New Roman",Times,serif + font-size: 200% + width: 100% + += calendar_date_select_includes + +%h1= @reservation_item.new_record? ? 'New Item' : 'Edit Item' + +- form_for [:admin, @reservation_item] do |f| + .form-area + %p.title + %label Name + = f.text_field :name, :class => 'textbox' + %p.title + %label Description + = f.text_area :description, :class => 'textbox' + + %p.buttons + - button_text = @reservation_item.new_record? ? 'Create' : 'Save Changes' + = submit_tag button_text, :class => 'button' + or + = link_to 'Cancel', admin_reservation_items_url diff --git a/app/views/admin/reservation_items/index.html.haml b/app/views/admin/reservation_items/index.html.haml new file mode 100644 index 0000000..9ab3991 --- /dev/null +++ b/app/views/admin/reservation_items/index.html.haml @@ -0,0 +1,68 @@ +- content_for 'page_css' do + :sass + p.new + a + color: #000 + border: 1px solid #ddf + padding: 6px + text-decoration: none + + &:hover + background: #efefff + + th.remove + width: 100px + + td.remove + width: 100px + font-size: 0.8em + vertical-align: center + + a + text-decoration: none + color: #000 + + img + margin-bottom: 3px + + #content #reservation-items.index .page .info + top: 0 + +%h1 Reservation items + +%table#reservation-items.index{:summary => "Listing of Reservation Items"} + %thead + %tr + %th.name Name + %th.description Description + %th.modify Remove + %tbody + - if @reservation_items.empty? + %tr + %td.note{:colspan => 3} No items + - else + - @reservation_items.each do |reservation_item| + %tr.node.level-1{:id => "event-#{reservation_item.id}"} + %td.page + %span.w1 + = link_to reservation_item.name, edit_admin_reservation_item_url(reservation_item) + + %td.reservation-item= reservation_item.description + %td.remove + = link_to("#{image('minus.png')} Remove", admin_reservation_item_url(reservation_item), :method => :delete, :alt => 'remove item', :confirm => 'Are you sure? This will delete the item!') + +%p.new= link_to('New Item', new_admin_reservation_item_url) + +%br + +%h1 Subscriber + +%table#reservation-subscriber.index{:summary => "Listing of all Subscribers"} + %thead + %tr + %th.name Name + %th.phone Phone number + %th.modify Remove + %tbody + +%p.new= link_to('New Subscriber', new_admin_reservation_subscriber_url) diff --git a/app/views/admin/reservation_subscribers/edit.html.haml b/app/views/admin/reservation_subscribers/edit.html.haml new file mode 100644 index 0000000..b75f0d1 --- /dev/null +++ b/app/views/admin/reservation_subscribers/edit.html.haml @@ -0,0 +1,27 @@ +- content_for 'page_css' do + :sass + p.title + margin: 10px 0 !important + + #content .form-area div.error-with-field + input.textbox + font-family: Georgia,Palatino,"Times New Roman",Times,serif + font-size: 200% + width: 100% + +%h1= @reservation_subscriber.new_record? ? 'New Subscriber' : 'Edit Subscriber' + +- form_for [:admin, @reservation_subscriber] do |f| + .form-area + %p.title + %label Name + = f.text_field :first_name, :class => 'textbox' + %p.title + %label Description + = f.text_area :note, :class => 'textbox' + + %p.buttons + - button_text = @reservation_subscriber.new_record? ? 'Create' : 'Save Changes' + = submit_tag button_text, :class => 'button' + or + = link_to 'Cancel', admin_reservation_subscribers_url diff --git a/db/migrate/001_create_reservation_items.rb b/db/migrate/001_create_reservation_items.rb new file mode 100644 index 0000000..3bc451c --- /dev/null +++ b/db/migrate/001_create_reservation_items.rb @@ -0,0 +1,13 @@ +class CreateReservationItems < ActiveRecord::Migration + def self.up + create_table :reservation_items do |t| + t.string :name + t.text :description + t.timestamps + end + end + + def self.down + drop_table :reservation_items + end +end diff --git a/db/migrate/002_create_reservation_subscibers.rb b/db/migrate/002_create_reservation_subscibers.rb new file mode 100644 index 0000000..871cec0 --- /dev/null +++ b/db/migrate/002_create_reservation_subscibers.rb @@ -0,0 +1,16 @@ +class CreateReservationSubscribers < ActiveRecord::Migration + def self.up + create_table :reservation_subscribers do |t| + t.string :first_name + t.string :last_name + t.string :phone + t.string :email + t.text :notes + t.timestamps + end + end + + def self.down + drop_table :reservation_subscribers + end +end diff --git a/lib/tasks/reservation_extension_tasks.rake b/lib/tasks/reservation_extension_tasks.rake new file mode 100644 index 0000000..5b1b0c9 --- /dev/null +++ b/lib/tasks/reservation_extension_tasks.rake @@ -0,0 +1,28 @@ +namespace :radiant do + namespace :extensions do + namespace :reservation do + + desc "Runs the migration of the Reservation extension" + task :migrate => :environment do + require 'radiant/extension_migrator' + if ENV["VERSION"] + ReservationExtension.migrator.migrate(ENV["VERSION"].to_i) + else + ReservationExtension.migrator.migrate + end + end + + desc "Copies public assets of the Reservation to the instance public/ directory." + task :update => :environment do + is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) } + puts "Copying assets from ReservationExtension" + Dir[ReservationExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file| + path = file.sub(ReservationExtension.root, '') + directory = File.dirname(path) + mkdir_p RAILS_ROOT + directory, :verbose => false + cp file, RAILS_ROOT + path, :verbose => false + end + end + end + end +end diff --git a/reservation_extension.rb b/reservation_extension.rb new file mode 100644 index 0000000..5e5356c --- /dev/null +++ b/reservation_extension.rb @@ -0,0 +1,23 @@ +# Uncomment this if you reference any of your controllers in activate +# require_dependency 'application' + +class ReservationExtension < Radiant::Extension + version "0.1" + description "Small Reservation System" + url "http://github.com/simerom/radiant-reservation-extension" + + define_routes do |map| + map.namespace :admin, :member => { :remove => :get } do |admin| + admin.resources :reservation_items, :reservation_subscribers + end + end + + def activate + admin.tabs.add "Reservation", "/admin/reservation_items", :after => "Layouts", :visibility => [:all] + end + + def deactivate + admin.tabs.remove "Reservation" + end + +end diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..d8c8db5 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,6 @@ +--colour +--format +progress +--loadby +mtime +--reverse diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..0adbf9f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,36 @@ +unless defined? RADIANT_ROOT + ENV["RAILS_ENV"] = "test" + case + when ENV["RADIANT_ENV_FILE"] + require ENV["RADIANT_ENV_FILE"] + when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions} + require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment" + else + require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment" + end +end +require "#{RADIANT_ROOT}/spec/spec_helper" + +Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets") + +if File.directory?(File.dirname(__FILE__) + "/matchers") + Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file } +end + +Spec::Runner.configure do |config| + # config.use_transactional_fixtures = true + # config.use_instantiated_fixtures = false + # config.fixture_path = RAILS_ROOT + '/spec/fixtures' + + # You can declare fixtures for each behaviour like this: + # describe "...." do + # fixtures :table_a, :table_b + # + # Alternatively, if you prefer to declare them only once, you can + # do so here, like so ... + # + # config.global_fixtures = :table_a, :table_b + # + # If you declare global fixtures, be aware that they will be declared + # for all of your examples, even those that don't use them. +end \ No newline at end of file
raskhadafi/radiant-reservation-extension
7453b456dc396695531530905848a70547ccc93e
added .gitignore
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5236e1e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +
ngerakines/fcache
6f9dff157c4055f4dbec5fada8ed001d424c8e4f
Cleaning build process and packages created.
diff --git a/Makefile b/Makefile index 3aaa1b2..5376eb3 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,23 @@ +include support/include.mk +LIBDIR=`erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell` +VERSION=0.0.1 all: - erlc src/fcache.erl + mkdir -p ./ebin + (cd src;$(MAKE)) + +clean: + rm -rf ebin/*.beam *.tgz + +test: all + mkdir -p t/.logs + prove t/*.t + +package: clean + @mkdir fcache-$(VERSION)/ && cp -rf src t support Makefile fcache-$(VERSION) + @COPYFILE_DISABLE=true tar zcf fcache-$(VERSION).tgz fcache-$(VERSION) + @rm -rf fcache-$(VERSION)/ + +install: + mkdir -p $(prefix)/$(LIBDIR)/fcache-$(VERSION)/ebin + for i in ebin/*.beam; do install $$i $(prefix)/$(LIBDIR)/fcache-$(VERSION)/$$i ; done diff --git a/src/Makefile b/src/Makefile index e69de29..9b3edea 100644 --- a/src/Makefile +++ b/src/Makefile @@ -0,0 +1,9 @@ +include ../support/include.mk + +all: $(EBIN_FILES) + +debug: + $(MAKE) DEBUG=-DDEBUG + +clean: + rm -rf $(EBIN_FILES) \ No newline at end of file diff --git a/support/include.mk b/support/include.mk new file mode 100644 index 0000000..2454342 --- /dev/null +++ b/support/include.mk @@ -0,0 +1,44 @@ +## -*- makefile -*- + +ERL := erl +ERLC := $(ERL)c + +INCLUDE_DIRS := ../include ../../ $(wildcard ../deps/*/include) +EBIN_DIRS := $(wildcard ../deps/*/ebin) +ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %) + +ifndef no_debug_info + ERLC_FLAGS += +debug_info +endif + +ifdef debug + ERLC_FLAGS += -Ddebug +endif + +EBIN_DIR := ../ebin +DOC_DIR := ../doc +EMULATOR := beam + +ERL_SOURCES := $(wildcard *.erl) +ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl) +ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.$(EMULATOR)) +# ERL_DOCUMENTS := $(ERL_SOURCES:%.erl=$(DOC_DIR)/%.html) +ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR)) +APP_FILES := $(wildcard *.app) +EBIN_FILES = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app) +# $(ERL_DOCUMENTS) +EBIN_FILES_NO_DOCS = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app) +MODULES = $(ERL_SOURCES:%.erl=%) + +../ebin/%.app: %.app + cp $< $@ + +$(EBIN_DIR)/%.$(EMULATOR): %.erl + $(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $< + +./%.$(EMULATOR): %.erl + $(ERLC) $(ERLC_FLAGS) -o . $< + +$(DOC_DIR)/%.html: %.erl + $(ERL) -noshell -run edoc file $< -run init stop + mv *.html $(DOC_DIR) \ No newline at end of file
ngerakines/fcache
df650bf7e157745c6ecbe75dd383f98c0c735e09
initial code commit
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3aaa1b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ + +all: + erlc src/fcache.erl diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/src/fcache.erl b/src/fcache.erl new file mode 100644 index 0000000..1da5242 --- /dev/null +++ b/src/fcache.erl @@ -0,0 +1,86 @@ +%% crypto:start(), fcache:start(), fcache:locate({erlang, integer_to_list, [1]}). +-module(fcache). +-behaviour(gen_server). + +-export([start/0, cache/1, locate/1, discover/0]). + +-export([init/1, handle_call/3, handle_cast/2, handle_info/2]). +-export([terminate/2, code_change/3]). + +init(_) -> + {Good, _Bad} = gen_server:multi_call(nodes(), fcache, {info}, 10000), + Nodes = [Name || {Name, ok} <- Good], + {ok, {[node() | Nodes], gb_trees:empty()}}. + +start() -> + case node() of + 'nonode@nohost' -> exit(invalid_node); + _ -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []) + end. + +locate({Module, Function, Arguments}) -> + Key = crypto:md5(erlang:term_to_binary({Module, Function, Arguments})), + locate(Key); +locate(Key) -> + gen_server:call(fcache, {locate, Key}, 6000). + +cache({Module, Function, Arguments}) -> + Key = crypto:md5(erlang:term_to_binary({Module, Function, Arguments})), + Node = locate(Key), + case gen_server:call({fcache, Node}, {get, Key}, 6000) of + {ok, Value} -> Value; + _ -> + Value = apply(Module, Function, Arguments), + gen_server:call({fcache, Node}, {set, Key, Value}, 6000), + Value + end. + +discover() -> + gen_server:call(fcache, {discover}, 6000). + +handle_call({discover}, _From, {_, Cache}) -> + {Good, _Bad} = gen_server:multi_call(nodes(), fcache, {info}, 10000), + Nodes = [Name || {Name, ok} <- Good], + {reply, [node() | Nodes], {[node() | Nodes], Cache}}; + +handle_call({locate, _}, _From, State = {Nodes, _}) when length(Nodes) == 1 -> + {reply, node(), State}; + +handle_call({locate, Key}, _From, State = {Nodes, _}) -> + <<X:128/integer>> = Key, + Mod = X rem length(Nodes), + {reply, Mod, State}; + +handle_call({get, Key}, _From, State = {_, Tree}) -> + Resp = case gb_trees:is_defined(Key, Tree) of + true -> + {ok, gb_trees:get(Key, Tree)}; + false -> + {nok, existance} + end, + {reply, Resp, State}; + +handle_call({set, Key, Value}, _From, {Nodes, Tree}) -> + NewTree = case gb_trees:is_defined(Key, Tree) of + true -> + gb_trees:update(Key, Value, Tree); + false -> + gb_trees:insert(Key, Value, Tree) + end, + {reply, ok, {Nodes, NewTree}}; + +handle_call({nodes}, _From, State = {Nodes, _}) -> + {reply, Nodes, State}; + +handle_call({info}, _From, State) -> + {reply, ok, State}; + +handle_call(_, _From, State) -> {reply, {error, invalid_call}, State}. + +handle_cast(_Message, State) -> {noreply, State}. + +handle_info(_Info, State) -> {noreply, State}. + +terminate(_Reason, _State) -> ok. + +code_change(_OldVsn, State, _Extra) -> {ok, State}.
dotnet/android-samples
9a7ddcd034eb846aa2c0dbdf94cbb4cb2ad90443
Remove sample metadata. (#352)
diff --git a/Button/Button/README.md b/Button/Button/README.md index 3389d8a..8a13c70 100644 --- a/Button/Button/README.md +++ b/Button/Button/README.md @@ -1,16 +1,3 @@ ---- -name: .NET for Android - Button Widget -description: "Shows how to use a simple button widget (UI)" -page_type: sample -languages: -- csharp -products: -- dotnet-android -extensions: - tags: - - ui -urlFragment: button ---- # Button Widget Shows how to use a simple button widget - see the [documentation](https://docs.microsoft.com/xamarin/android/user-interface/controls/buttons/). diff --git a/LocalNotifications/README.md b/LocalNotifications/README.md index 7feb942..f3553fc 100644 --- a/LocalNotifications/README.md +++ b/LocalNotifications/README.md @@ -1,20 +1,10 @@ ---- -name: .NET for Android - Android Local Notifications Sample -description: This sample app accompanies the article Using Local Notifications in .NET for Android. -page_type: sample -languages: -- csharp -products: -- dotnet-android -urlFragment: localnotifications ---- # Android Local Notifications Sample This sample app accompanies the article, [Walkthrough - Using Local Notifications in .NET for Android](https://docs.microsoft.com/xamarin/android/app-fundamentals/notifications/local-notifications-walkthrough). ![Android app screenshot](Screenshots/screenshot-1.png) When you tap the button displayed in the MainActivity screen, a notification is created. When you tap the notification, it takes you to a SecondActivity screen. diff --git a/Phoneword/README.md b/Phoneword/README.md index 7fa05ce..94cdad0 100644 --- a/Phoneword/README.md +++ b/Phoneword/README.md @@ -1,21 +1,8 @@ ---- -name: .NET for Android - Phoneword -description: "Sample app for the article, Hello, Android (Quickstart). This version of Phoneword incorporates all of the functionality... (get started)" -page_type: sample -languages: -- csharp -products: -- dotnet-android -extensions: - tags: - - getstarted -urlFragment: phoneword ---- # Phoneword This sample app accompanies the article, [Hello, Android (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android/hello-android-quickstart). This version of **Phoneword** incorporates all of the functionality explained in this article, and it can be used as the starting point for the article, [Hello, Android Multiscreen (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android-multiscreen/hello-android-multiscreen-quickstart). diff --git a/PopupMenuDemo/README.md b/PopupMenuDemo/README.md index 480bd93..057e12e 100644 --- a/PopupMenuDemo/README.md +++ b/PopupMenuDemo/README.md @@ -1,18 +1,8 @@ ---- -name: .NET for Android - Popup Menu -description: "Demonstrates how to add support for displaying popup menus that are attached to a particular view" -page_type: sample -languages: -- csharp -products: -- dotnet-android -urlFragment: popupmenudemo ---- # Popup Menu Demo **PopupMenuDemo** is a sample app that accompanies the article, [PopUp Menu](https://docs.microsoft.com/xamarin/android/user-interface/controls/popup-menu). It demonstrates how to add support for displaying popup menus that are attached to a particular view. ![Popup menu in Android](Screenshots/PopupMenuDemo.png) diff --git a/SwitchDemo/README.md b/SwitchDemo/README.md index 5014375..06827ef 100644 --- a/SwitchDemo/README.md +++ b/SwitchDemo/README.md @@ -1,22 +1,9 @@ ---- -name: .NET for Android - Switch Demo -description: "Shows how to use a switch control" -page_type: sample -languages: -- csharp -products: -- dotnet-android -extensions: - tags: - - ui -urlFragment: switchdemo ---- # Switch Demo This sample app accompanies the article, [Introduction to Switches](https://docs.microsoft.com/xamarin/android/user-interface/controls/switch), showing how to use the Switch control in Xamarin.Android. ![Switch control in an Android app](Screenshots/screenshot.png) ![Switch on in an Android app](Screenshots/Screenshot_switchon) ![Switch off in an Android app](Screenshots/Screenshot_switchoff)
dotnet/android-samples
3e36a4a3627261a5ab4866faf337fcdd30c05222
Replace "Xamarin.Android" references with ".NET for Android"
diff --git a/Button/Button/README.md b/Button/Button/README.md index 9f26eb0..3389d8a 100644 --- a/Button/Button/README.md +++ b/Button/Button/README.md @@ -1,16 +1,16 @@ --- -name: Xamarin.Android - Button Widget +name: .NET for Android - Button Widget description: "Shows how to use a simple button widget (UI)" page_type: sample languages: - csharp products: -- xamarin +- dotnet-android extensions: tags: - ui urlFragment: button --- # Button Widget Shows how to use a simple button widget - see the [documentation](https://docs.microsoft.com/xamarin/android/user-interface/controls/buttons/). diff --git a/LocalNotifications/README.md b/LocalNotifications/README.md index 6c90ea3..7feb942 100644 --- a/LocalNotifications/README.md +++ b/LocalNotifications/README.md @@ -1,20 +1,20 @@ --- -name: Xamarin.Android - Android Local Notifications Sample -description: This sample app accompanies the article Using Local Notifications in Xamarin.Android. +name: .NET for Android - Android Local Notifications Sample +description: This sample app accompanies the article Using Local Notifications in .NET for Android. page_type: sample languages: - csharp products: -- xamarin +- dotnet-android urlFragment: localnotifications --- # Android Local Notifications Sample This sample app accompanies the article, -[Walkthrough - Using Local Notifications in Xamarin.Android](https://docs.microsoft.com/xamarin/android/app-fundamentals/notifications/local-notifications-walkthrough). +[Walkthrough - Using Local Notifications in .NET for Android](https://docs.microsoft.com/xamarin/android/app-fundamentals/notifications/local-notifications-walkthrough). ![Android app screenshot](Screenshots/screenshot-1.png) When you tap the button displayed in the MainActivity screen, a notification is created. When you tap the notification, it takes you to a SecondActivity screen. diff --git a/Phoneword/README.md b/Phoneword/README.md index 9ae5390..7fa05ce 100644 --- a/Phoneword/README.md +++ b/Phoneword/README.md @@ -1,21 +1,21 @@ --- -name: Xamarin.Android - Phoneword +name: .NET for Android - Phoneword description: "Sample app for the article, Hello, Android (Quickstart). This version of Phoneword incorporates all of the functionality... (get started)" page_type: sample languages: - csharp products: -- xamarin +- dotnet-android extensions: tags: - getstarted urlFragment: phoneword --- # Phoneword This sample app accompanies the article, [Hello, Android (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android/hello-android-quickstart). This version of **Phoneword** incorporates all of the functionality explained in this article, and it can be used as the starting point for the article, [Hello, Android Multiscreen (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android-multiscreen/hello-android-multiscreen-quickstart). diff --git a/PopupMenuDemo/README.md b/PopupMenuDemo/README.md index 52eeb04..480bd93 100644 --- a/PopupMenuDemo/README.md +++ b/PopupMenuDemo/README.md @@ -1,18 +1,18 @@ --- -name: Xamarin.Android - Popup Menu +name: .NET for Android - Popup Menu description: "Demonstrates how to add support for displaying popup menus that are attached to a particular view" page_type: sample languages: - csharp products: -- xamarin +- dotnet-android urlFragment: popupmenudemo --- # Popup Menu Demo **PopupMenuDemo** is a sample app that accompanies the article, [PopUp Menu](https://docs.microsoft.com/xamarin/android/user-interface/controls/popup-menu). It demonstrates how to add support for displaying popup menus that are attached to a particular view. ![Popup menu in Android](Screenshots/PopupMenuDemo.png) diff --git a/README.md b/README.md index 59e044d..fbc2e5e 100644 --- a/README.md +++ b/README.md @@ -1,185 +1,159 @@ -# MonoDroid (Xamarin.Android) samples +# .NET for Android samples This branch contains samples ported to .NET 7. See the [.NET MAUI Installation docs](https://docs.microsoft.com/en-us/dotnet/maui/get-started/installation) for setup instructions. This repository contains Mono for Android samples, showing usage of various -Android API wrappers from C#. Visit the [Android Sample Gallery](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) +Android API wrappers from C#. Visit the [Android Sample Gallery](https://docs.microsoft.com/samples/browse/?term=dotnet-android) to download individual samples. ## Tips for .NET 7 Migration The goal here is to fully "modernize" the template for .NET 7 and C# 11. Compare a `dotnet new android` template named the same as the existing project. 1. If the root namespace doesn't match the project name, to get the existing code to compile, you may need: ```xml <RootNamespace>Xamarin.AidlDemo</RootNamespace> ``` 2. Update any dependencies, NuGet packages, etc. 3. Remove `android:versionCode`, `android:versionName`, `package`, `<uses-sdk/>`, and `<application label=""`. These are defined in the `.csproj` file. 4. Remove all unused using statements, since we now have `ImplicitUsings=enable`. 5. Fix all namespace declarations to use C# 10 file-scoped namespaces. 6. Build. Fix any warnings related to nullable reference types (`Nullable=enable`). 7. Run the app and ensure the sample still works. ## License The Apache License 2.0 applies to all samples in this repository. Copyright 2011 Xamarin Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ## Porting to NET6 When porting a legacy sample to NET6+, please make sure to preserve as much history of the original sample as possible. Some samples have their project, source and resource files in the same directory where the readme file, screenshot folder and other files not directly related to the sample code reside. Since NET6+ defaults to importing all the files in the project directory as if they were part of the project, the application code must first be moved to a subdirectory (with the exception of the .sln file). New subdirectory should use the same name as the solution file, without the .sln extension. After creating it **first** move all the relevant files and directories (source code, project file(s), the `Properties` and `Resources` directories etc), using the `git mv` command to the newly created directory, modify the .sln file to update project file path(s) and **commit** these changes. This ensures that further changes will preserve commit history. Now the sample is ready for porting. After creating new project file (using `dotnet new android -n SampleName`) in a separate directory, copy any necessary package and project references from the old project, updating them as needed and after that replace the old project file with the new one. A handful of useful tips (copied from the `dotnet` branch's README in this repository): 1. If the root namespace doesn't match the project name, to get the existing code to compile, you may need: ``` xml <RootNamespace>Xamarin.AidlDemo</RootNamespace> ``` 2. Update any dependencies, NuGet packages, etc. 3. Remove android:versionCode, android:versionName, package, <uses-sdk/>, and <application label="". These are defined in the .csproj file. 4. Remove all unused using statements, since we now have ImplicitUsings=enable. 5. Fix all namespace declarations to use C# 10 file-scoped namespaces. 6. Build. Fix any warnings related to nullable reference types (Nullable=enable). 7. Run the app and ensure the sample still works. Another collection of tips can be found [here](https://github.com/xamarin/xamarin-android/wiki/Migrating-Xamarin.Android-Applications-to-.NET-6) ## Contributing ## Samples Submission Guidelines ## Galleries We love samples! Application samples show off our platform and provide a great way for people to learn our stuff. And we even promote them as a first-class feature of the docs site. You can find the sample galleries here: -- [Xamarin.Forms Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Forms) +- [MAUI Samples](https://learn.microsoft.com/samples/browse/?term=maui) -- [iOS Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.iOS) - -- [Mac Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Mac) - -- [Android Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) - -## Sample GitHub Repositories - -These sample galleries are populated by samples in these GitHub repos: - -- [https://github.com/xamarin/xamarin-forms-samples](https://github.com/xamarin/xamarin-forms-samples) - -- [https://github.com/xamarin/mobile-samples](https://github.com/xamarin/mobile-samples) - -- [https://github.com/xamarin/ios-samples](https://github.com/xamarin/ios-samples) - -- [https://github.com/xamarin/mac-samples](https://github.com/xamarin/mac-samples) - -- [https://github.com/xamarin/monodroid-samples](https://github.com/xamarin/monodroid-samples) - -- [https://github.com/xamarin/mac-ios-samples](https://github.com/xamarin/mac-ios-samples) - -The [mobile-samples](https://github.com/xamarin/mobile-samples) repository is for samples that are cross-platform. -The [mac-ios-samples](https://github.com/xamarin/mac-ios-samples) repository is for samples that are Mac/iOS only. +- [Android Samples](https://docs.microsoft.com/samples/browse/?term=dotnet-android) ## Sample Requirements We welcome sample submissions, please start by creating an issue with your proposal. Because the sample galleries are powered by the github sample repos, each sample needs to have the following things: - **Screenshots** - a folder called Screenshots that has at least one screen shot of the sample on each platform (preferably a screen shot for every page or every major piece of functionality). For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo/Screenshots). - **Readme** - a `README.md` file that explains the sample, and contains metadata to help customers find it. For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/blob/master/android-p/AndroidPMiniDemo/README.md). The README file should begin with a YAML header (delimited by `---`) with the following keys/values: - - **name** - must begin with `Xamarin.Android -` + - **name** - must begin with `.NET for Android -` - **description** - brief description of the sample (&lt; 150 chars) that appears in the sample code browser search - **page_type** - must be the string `sample`. - **languages** - coding language/s used in the sample, such as: `csharp`, `fsharp`, `vb`, `java` - - **products**: should be `xamarin` for every sample in this repo + - **products**: should be `dotnet-android` for every sample in this repo - **urlFragment**: although this can be auto-generated, please supply an all-lowercase value that represents the sample's path in this repo, except directory separators are replaced with dashes (`-`) and no other punctuation. Here is a working example from [_android-p/AndroidPMiniDemo_ README raw view](https://raw.githubusercontent.com/xamarin/monodroid-samples/master/android-p/AndroidPMiniDemo/README.md). ```yaml --- - name: Xamarin.Android - Android P Mini Demo + name: .NET for Android - Android P Mini Demo description: "Demonstrates new display cutout and image notification features (Android Pie)" page_type: sample languages: - csharp products: - - xamarin + - dotnet-android urlFragment: android-p-androidpminidemo --- # Heading 1 rest of README goes here, including screenshot images and requirements/instructions to get it running ``` > NOTE: This must be valid YAML, so some characters in the name or description will require the entire string to be surrounded by " or ' quotes. - **Buildable solution and .csproj file** - the project _must_ build and have the appropriate project scaffolding (solution + .csproj files). -This approach ensures that all samples integrate with the Microsoft [sample code browser](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android). - -A good example of this stuff is here in the [Android Pie sample](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo) +This approach ensures that all samples integrate with the Microsoft [sample code browser](https://learn.microsoft.com/samples/browse/?term=dotnet-android). -For a cross-platform sample, please see: https://github.com/xamarin/mobile-samples/tree/master/Tasky diff --git a/SwitchDemo/README.md b/SwitchDemo/README.md index e7bd984..5014375 100644 --- a/SwitchDemo/README.md +++ b/SwitchDemo/README.md @@ -1,22 +1,22 @@ --- -name: Xamarin.Android - Switch Demo +name: .NET for Android - Switch Demo description: "Shows how to use a switch control" page_type: sample languages: - csharp products: -- xamarin +- dotnet-android extensions: tags: - ui urlFragment: switchdemo --- # Switch Demo This sample app accompanies the article, [Introduction to Switches](https://docs.microsoft.com/xamarin/android/user-interface/controls/switch), showing how to use the Switch control in Xamarin.Android. ![Switch control in an Android app](Screenshots/screenshot.png) ![Switch on in an Android app](Screenshots/Screenshot_switchon) ![Switch off in an Android app](Screenshots/Screenshot_switchoff)
dotnet/android-samples
be4df1129909e69d0488c914b870c5ed512979f4
Port UpdateUsersProfile sample to .NET (#339)
diff --git a/SwitchDemo/Metadata.xml b/SwitchDemo/Metadata.xml deleted file mode 100644 index 8133d27..0000000 --- a/SwitchDemo/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>08f30733-d18b-4728-88ee-2a3002cbd782</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>User Interface</Tags> - <Gallery>true</Gallery> - <Brief>This example shows how to use a switch control.</Brief> -</SampleMetadata> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Activity1.cs b/SwitchDemo/SwitchDemo/Activity1.cs index 46ce01a..a222002 100644 --- a/SwitchDemo/SwitchDemo/Activity1.cs +++ b/SwitchDemo/SwitchDemo/Activity1.cs @@ -1,23 +1,20 @@ namespace SwitchDemo { [Activity(Label = "SwitchDemo", MainLauncher = true)] public class Activity1 : Activity { protected override void OnCreate(Bundle? bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); - var s = FindViewById<Switch>(Resource.Id.monitored_switch); - - ArgumentNullException.ThrowIfNull(s); - s.CheckedChange += (sender, e) => { - - var toast = Toast.MakeText(this, "Your answer is " + (e.IsChecked ? "correct" : "incorrect"), - ToastLength.Short); - toast?.Show(); + var monitored_switch = RequireViewById<Switch>(Resource.Id.monitored_switch); + monitored_switch.CheckedChange += (sender, e) => + { + var answer = e.IsChecked ? "correct" : "incorrect"; + Toast.MakeText(this, $"Your answer is {answer}", ToastLength.Long)!.Show(); }; } } } \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/layout/Main.xml b/SwitchDemo/SwitchDemo/Resources/layout/Main.xml index e5586ef..2e352db 100644 --- a/SwitchDemo/SwitchDemo/Resources/layout/Main.xml +++ b/SwitchDemo/SwitchDemo/Resources/layout/Main.xml @@ -1,15 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Switch android:id="@+id/monitored_switch" - android:text="Is Mono for Android great?" + android:text="Is .NET great?" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:checked="true" android:textOn="@strings/answeryes" android:textOff="@strings/answerno" /> </LinearLayout> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/SwitchDemo.csproj b/SwitchDemo/SwitchDemo/SwitchDemo.csproj index daabc48..494df8f 100644 --- a/SwitchDemo/SwitchDemo/SwitchDemo.csproj +++ b/SwitchDemo/SwitchDemo/SwitchDemo.csproj @@ -1,12 +1,12 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>net6.0-android</TargetFramework> + <TargetFramework>net7.0-android</TargetFramework> <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> <OutputType>Exe</OutputType> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <ApplicationId>com.companyname.SwitchDemo</ApplicationId> <ApplicationVersion>1</ApplicationVersion> <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> </PropertyGroup> </Project> \ No newline at end of file diff --git a/UpdateUsersProfile/AndroidManifest.xml b/UpdateUsersProfile/AndroidManifest.xml new file mode 100644 index 0000000..b531859 --- /dev/null +++ b/UpdateUsersProfile/AndroidManifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.READ_PROFILE" /> + <uses-permission android:name="android.permission.READ_CONTACTS" /> + <uses-permission android:name="android.permission.WRITE_CONTACTS" /> + <uses-permission android:name="android.permission.WRITE_PROFILE" /> +</manifest> \ No newline at end of file diff --git a/UpdateUsersProfile/MainActivity.cs b/UpdateUsersProfile/MainActivity.cs new file mode 100644 index 0000000..51fd54d --- /dev/null +++ b/UpdateUsersProfile/MainActivity.cs @@ -0,0 +1,106 @@ +using Android.Content; +using Android.Content.PM; +using Android.Database; +using Android.Provider; +using AndroidX.Core.App; +using AndroidX.Core.Content; + +namespace UpdateUsersProfile +{ + [Activity(Label = "UpdateUsersProfile", MainLauncher = true, Icon = "@mipmap/ic_launcher")] + public class MainActivity : Activity + { + public static readonly int REQUEST_CONTACTS = 1; + + protected override void OnCreate(Bundle? bundle) + { + base.OnCreate(bundle); + + // Set our view from the "main" layout resource + SetContentView(Resource.Layout.Main); + + // Get the button for updating the user profile: + var button = RequireViewById<Button>(Resource.Id.MyButton); + button.Click += delegate { + + // Give a name to the device owner's profile: + NameOwner(); + + // Read back the name: + if (ReadBackName()) + // launch an activity to view the profile if reading the name works: + ViewProfile(); + }; + } + + // Give the device user a name: "John Doe" + void NameOwner() + { + // Create the display name for the user's profile: + var values = new ContentValues(); + values.Put(ContactsContract.Contacts.InterfaceConsts.DisplayName, "Jonathan Peppers"); + + // Insert the user's name. Note that the user's profile entry cannot be created explicitly + // (attempting to do so will throw an exception): + if (ContextCompat.CheckSelfPermission(this, Android.Manifest.Permission.ReadContacts) == Permission.Granted && + ContextCompat.CheckSelfPermission(this, Android.Manifest.Permission.WriteContacts) == Permission.Granted) + { + // We have permission, go ahead and access contacts + ContentResolver?.Update(ContactsContract.Profile.ContentRawContactsUri!, values, null, null); + } + else + { + // Contacts permission is not granted. Display rationale & request. + ActivityCompat.RequestPermissions(this, new String[] { Android.Manifest.Permission.ReadContacts, Android.Manifest.Permission.WriteContacts }, REQUEST_CONTACTS); + } + } + + public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) + { + if (requestCode == REQUEST_CONTACTS) + { + // Check if the required permission(s) have been granted + if (grantResults.All(r => r == Permission.Granted)) + { + NameOwner(); + } + } + } + + // Read back the user name and print it to the console: + bool ReadBackName() + { + // Get the URI for the user's profile: + Android.Net.Uri? uri = ContactsContract.Profile.ContentUri; + ArgumentNullException.ThrowIfNull(uri); + + // Setup the "projection" (columns we want) for only the display name: + string[] projection = { ContactsContract.Contacts.InterfaceConsts.DisplayName }; + + // Use a CursorLoader to retrieve the user's profile data: + var loader = new AndroidX.Loader.Content.CursorLoader(this, uri, projection, null, null, null); + if (ContextCompat.CheckSelfPermission(this, Android.Manifest.Permission.ReadContacts) == Permission.Granted) + { + var cursor = (ICursor?)loader.LoadInBackground(); + + // Print the user name to the console if reading back succeeds: + if (cursor != null) + { + if (cursor.MoveToFirst()) + { + Console.WriteLine(cursor.GetString(cursor.GetColumnIndex(projection[0]))); + return true; + } + } + } + return false; + } + + // Launch an intent that navigates to the user's profile: + void ViewProfile() + { + var intent = new Intent(Intent.ActionView, ContactsContract.Profile.ContentUri); + StartActivity(intent); + } + } +} \ No newline at end of file diff --git a/UpdateUsersProfile/Resources/AboutResources.txt b/UpdateUsersProfile/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/UpdateUsersProfile/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/UpdateUsersProfile/Resources/layout/Main.xml b/UpdateUsersProfile/Resources/layout/Main.xml new file mode 100644 index 0000000..4ca38ea --- /dev/null +++ b/UpdateUsersProfile/Resources/layout/Main.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > + <Button + android:id="@+id/MyButton" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/buttonText" + /> +</LinearLayout> \ No newline at end of file diff --git a/UpdateUsersProfile/Resources/mipmap-anydpi-v26/ic_launcher.xml b/UpdateUsersProfile/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/UpdateUsersProfile/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/UpdateUsersProfile/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/UpdateUsersProfile/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/UpdateUsersProfile/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher.png b/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher_foreground.png b/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher_round.png b/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher.png b/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher_foreground.png b/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher_round.png b/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher.png b/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher_round.png b/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher.png b/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher_round.png b/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher.png b/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/UpdateUsersProfile/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/UpdateUsersProfile/Resources/values/ic_launcher_background.xml b/UpdateUsersProfile/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/UpdateUsersProfile/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/UpdateUsersProfile/Resources/values/strings.xml b/UpdateUsersProfile/Resources/values/strings.xml new file mode 100644 index 0000000..7a04086 --- /dev/null +++ b/UpdateUsersProfile/Resources/values/strings.xml @@ -0,0 +1,7 @@ +<resources> + <string name="app_name">UpdateUsersProfile</string> + <string name="app_text">Hello, Android!</string> + <string name="buttonText">Update Profile</string> + <string name="ApplicationName">UpdateUserProfile</string> + <string name="permission_contacts_rationale">Permission to access contacts</string> +</resources> diff --git a/UpdateUsersProfile/UpdateUsersProfile.csproj b/UpdateUsersProfile/UpdateUsersProfile.csproj new file mode 100644 index 0000000..f0d8a78 --- /dev/null +++ b/UpdateUsersProfile/UpdateUsersProfile.csproj @@ -0,0 +1,15 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net7.0-android</TargetFramework> + <SupportedOSPlatformVersion>23</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.UpdateUsersProfile</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> + <ItemGroup> + <PackageReference Include="Xamarin.AndroidX.Loader" Version="1.1.0.15" /> + </ItemGroup> +</Project> \ No newline at end of file diff --git a/UpdateUsersProfile/UpdateUsersProfile.sln b/UpdateUsersProfile/UpdateUsersProfile.sln new file mode 100644 index 0000000..9126eec --- /dev/null +++ b/UpdateUsersProfile/UpdateUsersProfile.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32611.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateUsersProfile", "UpdateUsersProfile.csproj", "{E434AC58-B83D-4A9F-87DD-363402C978A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E434AC58-B83D-4A9F-87DD-363402C978A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E434AC58-B83D-4A9F-87DD-363402C978A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E434AC58-B83D-4A9F-87DD-363402C978A1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {E434AC58-B83D-4A9F-87DD-363402C978A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E434AC58-B83D-4A9F-87DD-363402C978A1}.Release|Any CPU.Build.0 = Release|Any CPU + {E434AC58-B83D-4A9F-87DD-363402C978A1}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {750BA47A-692F-44B3-B51A-1EF7F94AAABF} + EndGlobalSection +EndGlobal
dotnet/android-samples
ba346015ae55810d3771224c6c36a7f660ae1491
Port Phoneword and PopupMenu samples (#340)
diff --git a/Phoneword/Phoneword.sln b/Phoneword/Phoneword.sln new file mode 100644 index 0000000..fc50f41 --- /dev/null +++ b/Phoneword/Phoneword.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32519.111 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phoneword", "Phoneword\Phoneword.csproj", "{9C2983B9-50D8-4BD8-93B7-72027DE935E8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9C2983B9-50D8-4BD8-93B7-72027DE935E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C2983B9-50D8-4BD8-93B7-72027DE935E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C2983B9-50D8-4BD8-93B7-72027DE935E8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {9C2983B9-50D8-4BD8-93B7-72027DE935E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C2983B9-50D8-4BD8-93B7-72027DE935E8}.Release|Any CPU.Build.0 = Release|Any CPU + {9C2983B9-50D8-4BD8-93B7-72027DE935E8}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F4BD4825-E0F1-4313-BD5C-D9877C7D0635} + EndGlobalSection +EndGlobal diff --git a/Phoneword/Phoneword/AndroidManifest.xml b/Phoneword/Phoneword/AndroidManifest.xml new file mode 100644 index 0000000..f91298d --- /dev/null +++ b/Phoneword/Phoneword/AndroidManifest.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:label="Phoneword" android:icon="@mipmap/ic_launcher"></application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> diff --git a/Phoneword/Phoneword/MainActivity.cs b/Phoneword/Phoneword/MainActivity.cs new file mode 100644 index 0000000..f90bac1 --- /dev/null +++ b/Phoneword/Phoneword/MainActivity.cs @@ -0,0 +1,37 @@ +using Core; + +namespace Phoneword; + +[Activity(Label = "Phone Word", MainLauncher = true, Icon = "@mipmap/ic_launcher")] +public class MainActivity : Activity +{ + protected override void OnCreate(Bundle? savedInstanceState) + { + base.OnCreate(savedInstanceState); + + // Set our view from the "main" layout resource + SetContentView(Resource.Layout.Main); + + // Get our UI controls from the loaded layout + EditText phoneNumberText = RequireViewById<EditText>(Resource.Id.PhoneNumberText); + Button translateButton = RequireViewById<Button>(Resource.Id.TranslateButton); + TextView translatedPhoneWord = RequireViewById<TextView>(Resource.Id.TranslatedPhoneWord); + + // Add code to translate number + translateButton.Click += (sender, e) => + { + // Translate user's alphanumeric phone number to numeric + var translatedNumber = PhoneTranslator.ToNumber(phoneNumberText.Text); + + if (string.IsNullOrWhiteSpace(translatedNumber)) + { + translatedPhoneWord.Text = string.Empty; + Toast.MakeText(this, "Unable to translate number!", ToastLength.Long)!.Show(); + } + else + { + translatedPhoneWord.Text = translatedNumber; + } + }; + } +} \ No newline at end of file diff --git a/Phoneword/Phoneword/PhoneTranslator.cs b/Phoneword/Phoneword/PhoneTranslator.cs new file mode 100644 index 0000000..c231be9 --- /dev/null +++ b/Phoneword/Phoneword/PhoneTranslator.cs @@ -0,0 +1,50 @@ +using System.Text; + +namespace Core; + +public static class PhoneTranslator +{ + public static string ToNumber(string? raw) + { + if (string.IsNullOrWhiteSpace(raw)) + return ""; + else + raw = raw.ToUpperInvariant(); + + var newNumber = new StringBuilder(); + foreach (var c in raw) + { + if (" -0123456789".Contains(c)) + newNumber.Append(c); + else + { + var result = TranslateToNumber(c); + if (result != null) + newNumber.Append(result); + } + // otherwise we've skipped a non-numeric char + } + return newNumber.ToString(); + } + + static int? TranslateToNumber(char c) + { + if ('A' <= c && c <= 'C') + return 2; + if ('D' <= c && c <= 'F') + return 3; + if ('G' <= c && c <= 'I') + return 4; + if ('J' <= c && c <= 'L') + return 5; + if ('M' <= c && c <= 'O') + return 6; + if ('P' <= c && c <= 'S') + return 7; + if ('T' <= c && c <= 'V') + return 8; + if ('W' <= c && c <= 'Z') + return 9; + return null; + } +} \ No newline at end of file diff --git a/Phoneword/Phoneword/Phoneword.csproj b/Phoneword/Phoneword/Phoneword.csproj new file mode 100644 index 0000000..93c542a --- /dev/null +++ b/Phoneword/Phoneword/Phoneword.csproj @@ -0,0 +1,12 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net7.0-android</TargetFramework> + <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.Phoneword</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> +</Project> diff --git a/Phoneword/Phoneword/Resources/AboutResources.txt b/Phoneword/Phoneword/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/Phoneword/Phoneword/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/Phoneword/Phoneword/Resources/layout/Main.xml b/Phoneword/Phoneword/Resources/layout/Main.xml new file mode 100644 index 0000000..d148c60 --- /dev/null +++ b/Phoneword/Phoneword/Resources/layout/Main.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <TextView + android:text="@string/Phoneword" + android:textAppearance="?android:attr/textAppearanceLarge" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/PhoneWordPrompt" /> + <EditText + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/PhoneNumberText" + android:text="@string/PhoneNumber" /> + <Button + android:text="@string/Translate" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/TranslateButton" /> + <TextView + android:textAppearance="?android:attr/textAppearanceLarge" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/TranslatedPhoneWord" /> +</LinearLayout> \ No newline at end of file diff --git a/Phoneword/Phoneword/Resources/mipmap-anydpi-v26/ic_launcher.xml b/Phoneword/Phoneword/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/Phoneword/Phoneword/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/Phoneword/Phoneword/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/Phoneword/Phoneword/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/Phoneword/Phoneword/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher.png b/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher_foreground.png b/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher_round.png b/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher.png b/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher_foreground.png b/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher_round.png b/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher.png b/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher_round.png b/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher.png b/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher_round.png b/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher.png b/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/Phoneword/Phoneword/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/Phoneword/Phoneword/Resources/values/ic_launcher_background.xml b/Phoneword/Phoneword/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/Phoneword/Phoneword/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/Phoneword/Phoneword/Resources/values/strings.xml b/Phoneword/Phoneword/Resources/values/strings.xml new file mode 100644 index 0000000..7bffcc6 --- /dev/null +++ b/Phoneword/Phoneword/Resources/values/strings.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">Phone Word</string> + <string name="PhoneNumber">1-855-XAMARIN</string> + <string name="Translate">Translate</string> + <string name="Phoneword">Enter a Phoneword:</string> + </resources> \ No newline at end of file diff --git a/Phoneword/README.md b/Phoneword/README.md new file mode 100644 index 0000000..9ae5390 --- /dev/null +++ b/Phoneword/README.md @@ -0,0 +1,21 @@ +--- +name: Xamarin.Android - Phoneword +description: "Sample app for the article, Hello, Android (Quickstart). This version of Phoneword incorporates all of the functionality... (get started)" +page_type: sample +languages: +- csharp +products: +- xamarin +extensions: + tags: + - getstarted +urlFragment: phoneword +--- +# Phoneword + +This sample app accompanies the article, +[Hello, Android (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android/hello-android-quickstart). +This version of **Phoneword** incorporates all of the functionality +explained in this article, and it can be used as the starting point for +the article, +[Hello, Android Multiscreen (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android-multiscreen/hello-android-multiscreen-quickstart). diff --git a/Phoneword/Screenshots/Phoneword Sample Photo 1.png b/Phoneword/Screenshots/Phoneword Sample Photo 1.png new file mode 100644 index 0000000..742e2a0 Binary files /dev/null and b/Phoneword/Screenshots/Phoneword Sample Photo 1.png differ diff --git a/Phoneword/Screenshots/Phoneword Sample Photo 2.png b/Phoneword/Screenshots/Phoneword Sample Photo 2.png new file mode 100644 index 0000000..00dbb7e Binary files /dev/null and b/Phoneword/Screenshots/Phoneword Sample Photo 2.png differ diff --git a/Phoneword/Screenshots/example-screenshot.png b/Phoneword/Screenshots/example-screenshot.png new file mode 100644 index 0000000..af3831c Binary files /dev/null and b/Phoneword/Screenshots/example-screenshot.png differ diff --git a/PopupMenuDemo/AndroidManifest.xml b/PopupMenuDemo/AndroidManifest.xml new file mode 100644 index 0000000..1811bb4 --- /dev/null +++ b/PopupMenuDemo/AndroidManifest.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> \ No newline at end of file diff --git a/PopupMenuDemo/MainActivity.cs b/PopupMenuDemo/MainActivity.cs new file mode 100644 index 0000000..e6a4cfa --- /dev/null +++ b/PopupMenuDemo/MainActivity.cs @@ -0,0 +1,33 @@ +namespace PopupMenuDemo; + +[Activity(Label = "PopupMenuDemo", MainLauncher = true)] +public class Activity1 : Activity +{ + protected override void OnCreate(Bundle? bundle) + { + base.OnCreate(bundle); + + SetContentView(Resource.Layout.Main); + + Button showPopupMenu = RequireViewById<Button>(Resource.Id.popupButton); + showPopupMenu.Click += (s, arg) => { + + PopupMenu menu = new PopupMenu(this, showPopupMenu); + + // Call inflate directly on the menu: + menu.Inflate(Resource.Menu.popup_menu); + + // A menu item was clicked: + menu.MenuItemClick += (s1, arg1) => { + Console.WriteLine("{0} selected", arg1.Item!.TitleFormatted); + }; + + // Menu was dismissed: + menu.DismissEvent += (s2, arg2) => { + Console.WriteLine("menu dismissed"); + }; + + menu.Show(); + }; + } +} diff --git a/PopupMenuDemo/PopupMenuDemo.csproj b/PopupMenuDemo/PopupMenuDemo.csproj new file mode 100644 index 0000000..e0f80f2 --- /dev/null +++ b/PopupMenuDemo/PopupMenuDemo.csproj @@ -0,0 +1,12 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net7.0-android</TargetFramework> + <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.PopupMenuDemo</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/PopupMenuDemo/PopupMenuDemo.sln b/PopupMenuDemo/PopupMenuDemo.sln new file mode 100644 index 0000000..e4a03ad --- /dev/null +++ b/PopupMenuDemo/PopupMenuDemo.sln @@ -0,0 +1,29 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32519.111 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PopupMenuDemo", "PopupMenuDemo.csproj", "{66D4DE6D-4B56-4C20-A435-892687B9C26E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Release|Any CPU.Build.0 = Release|Any CPU + {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6571484D-6BA8-45C9-9F8D-153C0B060A05} + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = PopupMenuDemo.csproj + EndGlobalSection +EndGlobal diff --git a/PopupMenuDemo/README.md b/PopupMenuDemo/README.md new file mode 100644 index 0000000..52eeb04 --- /dev/null +++ b/PopupMenuDemo/README.md @@ -0,0 +1,18 @@ +--- +name: Xamarin.Android - Popup Menu +description: "Demonstrates how to add support for displaying popup menus that are attached to a particular view" +page_type: sample +languages: +- csharp +products: +- xamarin +urlFragment: popupmenudemo +--- +# Popup Menu Demo + +**PopupMenuDemo** is a sample app that accompanies the article, +[PopUp Menu](https://docs.microsoft.com/xamarin/android/user-interface/controls/popup-menu). +It demonstrates how to add support for displaying popup menus that are attached to +a particular view. + +![Popup menu in Android](Screenshots/PopupMenuDemo.png) diff --git a/PopupMenuDemo/Resources/AboutResources.txt b/PopupMenuDemo/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/PopupMenuDemo/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/PopupMenuDemo/Resources/layout/Main.xml b/PopupMenuDemo/Resources/layout/Main.xml new file mode 100644 index 0000000..b17b2e2 --- /dev/null +++ b/PopupMenuDemo/Resources/layout/Main.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > + <Button + android:id="@+id/popupButton" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/showPopup" + /> +</LinearLayout> diff --git a/PopupMenuDemo/Resources/menu/popup_menu.xml b/PopupMenuDemo/Resources/menu/popup_menu.xml new file mode 100644 index 0000000..d96dc9c --- /dev/null +++ b/PopupMenuDemo/Resources/menu/popup_menu.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/item1" + android:title="item 1" /> + <item android:id="@+id/item1" + android:title="item 2" /> + <item android:id="@+id/item1" + android:title="item 3" /> +</menu> \ No newline at end of file diff --git a/PopupMenuDemo/Resources/mipmap-anydpi-v26/ic_launcher.xml b/PopupMenuDemo/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/PopupMenuDemo/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/PopupMenuDemo/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/PopupMenuDemo/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/PopupMenuDemo/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher.png b/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher_foreground.png b/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher_round.png b/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher.png b/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher_foreground.png b/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher_round.png b/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher.png b/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher_round.png b/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher.png b/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher_round.png b/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher.png b/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/PopupMenuDemo/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/PopupMenuDemo/Resources/values/ic_launcher_background.xml b/PopupMenuDemo/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/PopupMenuDemo/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/PopupMenuDemo/Resources/values/strings.xml b/PopupMenuDemo/Resources/values/strings.xml new file mode 100644 index 0000000..6418852 --- /dev/null +++ b/PopupMenuDemo/Resources/values/strings.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="showPopup">Show popup menu</string> + <string name="app_name">PopupMenuDemo</string> + <string name="app_text">Hello, Android!</string> +</resources> \ No newline at end of file diff --git a/Screenshots/PopupMenuDemo.png b/Screenshots/PopupMenuDemo.png new file mode 100644 index 0000000..b121c40 Binary files /dev/null and b/Screenshots/PopupMenuDemo.png differ diff --git a/Screenshots/PopupMenuDemoPhoto1.png b/Screenshots/PopupMenuDemoPhoto1.png new file mode 100644 index 0000000..4f87016 Binary files /dev/null and b/Screenshots/PopupMenuDemoPhoto1.png differ diff --git a/Screenshots/PopupMenuDemoPhoto2.png b/Screenshots/PopupMenuDemoPhoto2.png new file mode 100644 index 0000000..c730bc2 Binary files /dev/null and b/Screenshots/PopupMenuDemoPhoto2.png differ
dotnet/android-samples
75872227ad9c82ade8095982202f7e74ad88dca1
Port Local Notification Sample to .NET 7 (#341)
diff --git a/LocalNotifications/LocalNotifications.sln b/LocalNotifications/LocalNotifications.sln new file mode 100644 index 0000000..ea045b9 --- /dev/null +++ b/LocalNotifications/LocalNotifications.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32519.111 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalNotifications", "LocalNotifications\LocalNotifications.csproj", "{4B2A0076-A973-4AC3-B762-4B889BEFC9C2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4B2A0076-A973-4AC3-B762-4B889BEFC9C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B2A0076-A973-4AC3-B762-4B889BEFC9C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B2A0076-A973-4AC3-B762-4B889BEFC9C2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {4B2A0076-A973-4AC3-B762-4B889BEFC9C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B2A0076-A973-4AC3-B762-4B889BEFC9C2}.Release|Any CPU.Build.0 = Release|Any CPU + {4B2A0076-A973-4AC3-B762-4B889BEFC9C2}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5AFA1196-F555-4E40-8873-088B8649B8A4} + EndGlobalSection +EndGlobal diff --git a/LocalNotifications/LocalNotifications/AndroidManifest.xml b/LocalNotifications/LocalNotifications/AndroidManifest.xml new file mode 100644 index 0000000..f5303b3 --- /dev/null +++ b/LocalNotifications/LocalNotifications/AndroidManifest.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:theme="@style/AppTheme" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> +</manifest> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/LocalNotifications.csproj b/LocalNotifications/LocalNotifications/LocalNotifications.csproj new file mode 100644 index 0000000..9078bab --- /dev/null +++ b/LocalNotifications/LocalNotifications/LocalNotifications.csproj @@ -0,0 +1,15 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net7.0-android</TargetFramework> + <SupportedOSPlatformVersion>23</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.LocalNotifications</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> + <ItemGroup> + <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.5.1.1" /> + </ItemGroup> +</Project> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/MainActivity.cs b/LocalNotifications/LocalNotifications/MainActivity.cs new file mode 100644 index 0000000..64ce061 --- /dev/null +++ b/LocalNotifications/LocalNotifications/MainActivity.cs @@ -0,0 +1,130 @@ +using Android.Content; +using Android.Content.PM; +using Android.Content.Res; +using Android.Runtime; +using AndroidX.AppCompat.App; +using AndroidX.Core.App; +using Java.Lang; +using TaskStackBuilder = AndroidX.Core.App.TaskStackBuilder; + +namespace LocalNotifications; + +[Activity (Label = "Notifications", MainLauncher = true, Icon = "@drawable/Icon")] +public class MainActivity : AppCompatActivity +{ + const string PERMISSION = "android.permission.POST_NOTIFICATIONS"; + const int REQUEST_CODE = 1; + /// <summary> + /// Unique ID for our notification + /// </summary> + const int NOTIFICATION_ID = 1000; + const string CHANNEL_ID = "location_notification"; + public const string COUNT_KEY = "count"; + + // Number of times the button is tapped (starts with first tap): + int count = 1; + + protected override void OnCreate (Bundle? bundle) + { + base.OnCreate (bundle); + SetContentView (Resource.Layout.Main); + + // Display the "Hello World, Click Me!" button and register its event handler: + var button = RequireViewById<Button> (Resource.Id.MyButton); + button.Click += (sender, e) => + { + if (CheckSelfPermission(PERMISSION) == Permission.Denied) + { + ActivityCompat.RequestPermissions(this, new[] { PERMISSION }, REQUEST_CODE); + } + else + { + CreateNotification(); + } + }; + + CreateNotificationChannel(); + } + + public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) + { + if (requestCode == REQUEST_CODE) + { + if (permissions.Length > 0 && permissions[0] == PERMISSION && + grantResults.Length > 0 && grantResults[0] == Permission.Granted) + { + CreateNotification(); + } + else + { + Toast.MakeText(this, "Unable to request permissions!", ToastLength.Long)!.Show(); + } + } + } + + void CreateNotification() + { + // Pass the current button press count value to the next activity: + var valuesForActivity = new Bundle(); + valuesForActivity.PutInt(COUNT_KEY, count); + + // When the user clicks the notification, SecondActivity will start up. + var resultIntent = new Intent(this, typeof(SecondActivity)); + + // Pass some values to SecondActivity: + resultIntent.PutExtras(valuesForActivity); + + // Construct a back stack for cross-task navigation: + var stackBuilder = TaskStackBuilder.Create(this); + ArgumentNullException.ThrowIfNull(stackBuilder); + stackBuilder.AddParentStack(Class.FromType(typeof(SecondActivity))); + stackBuilder.AddNextIntent(resultIntent); + + // Create the PendingIntent with the back stack: + var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.Immutable); + + // Build the notification: + var builder = new NotificationCompat.Builder(this, CHANNEL_ID) + .SetAutoCancel(true) // Dismiss the notification from the notification area when the user clicks on it + .SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent. + .SetContentTitle("Button Clicked") // Set the title + .SetNumber(count) // Display the count in the Content Info + .SetSmallIcon(Resource.Mipmap.ic_stat_button_click) // This is the icon to display + .SetContentText($"The button has been clicked {count} times."); // the message to display. + + // Finally, publish the notification: + var notificationManager = NotificationManagerCompat.From(this); + if (notificationManager.AreNotificationsEnabled()) + { + notificationManager.Notify(NOTIFICATION_ID, builder.Build()); + } + else + { + Toast.MakeText(this, "Notifications are not enabled!", ToastLength.Long)!.Show(); + } + + // Increment the button press count: + count++; + } + + void CreateNotificationChannel () + { + ArgumentNullException.ThrowIfNull (Resources); + + // Creating a NotificationChannel is only needed in API 26+ + if (OperatingSystem.IsAndroidVersionAtLeast (26)) + { + var name = Resources.GetString (Resource.String.channel_name); + var description = GetString (Resource.String.channel_description); + var channel = new NotificationChannel (CHANNEL_ID, name, NotificationImportance.Default) + { + Description = description + }; + + if (GetSystemService(NotificationService) is NotificationManager manager) + { + manager.CreateNotificationChannel(channel); + } + } + } +} diff --git a/LocalNotifications/LocalNotifications/Resources/AboutResources.txt b/LocalNotifications/LocalNotifications/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/Resources/drawable/Icon.png b/LocalNotifications/LocalNotifications/Resources/drawable/Icon.png new file mode 100644 index 0000000..d8c1895 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/drawable/Icon.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/layout/Main.xml b/LocalNotifications/LocalNotifications/Resources/layout/Main.xml new file mode 100644 index 0000000..7e669df --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/layout/Main.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <Button + android:id="@+id/MyButton" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/Hello" /> +</LinearLayout> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/Resources/layout/Second.axml b/LocalNotifications/LocalNotifications/Resources/layout/Second.axml new file mode 100644 index 0000000..8e6e1df --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/layout/Second.axml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:minWidth="25px" + android:minHeight="25px"> + <TextView + android:text="" + android:textAppearance="?android:attr/textAppearanceLarge" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:id="@+id/textView1" /> +</LinearLayout> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-anydpi-v26/ic_launcher.xml b/LocalNotifications/LocalNotifications/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/LocalNotifications/LocalNotifications/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher.png b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher_foreground.png b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher_round.png b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_stat_button_click.png b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_stat_button_click.png new file mode 100644 index 0000000..b96624c Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-hdpi/ic_stat_button_click.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher.png b/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher_foreground.png b/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher_round.png b/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher_round.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher_round.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/LocalNotifications/LocalNotifications/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/LocalNotifications/LocalNotifications/Resources/values/colours.xml b/LocalNotifications/LocalNotifications/Resources/values/colours.xml new file mode 100644 index 0000000..2e7db33 --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/values/colours.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> + +<resources> + <color name="colorPrimary">#3F51B5</color> + <color name="colorPrimaryDark">#303F9F</color> + <color name="colorAccent">#FF4081</color> + <color name="ic_launcher_background">#FFFFFF</color> +</resources> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/Resources/values/strings.xml b/LocalNotifications/LocalNotifications/Resources/values/strings.xml new file mode 100644 index 0000000..c4faeaa --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/values/strings.xml @@ -0,0 +1,7 @@ +<resources> + <string name="app_name">LocalNotifications</string> + <string name="Hello">Hello World, Click Me!</string> + + <string name="channel_name">Local Notifications</string> + <string name="channel_description">The count from MainActivity.</string> +</resources> diff --git a/LocalNotifications/LocalNotifications/Resources/values/styles.xml b/LocalNotifications/LocalNotifications/Resources/values/styles.xml new file mode 100644 index 0000000..b7c7701 --- /dev/null +++ b/LocalNotifications/LocalNotifications/Resources/values/styles.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> + +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + <item name="colorPrimary">@color/colorPrimary</item> + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> + <item name="colorAccent">@color/colorAccent</item> + </style> + +</resources> \ No newline at end of file diff --git a/LocalNotifications/LocalNotifications/SecondActivity.cs b/LocalNotifications/LocalNotifications/SecondActivity.cs new file mode 100644 index 0000000..7bbf632 --- /dev/null +++ b/LocalNotifications/LocalNotifications/SecondActivity.cs @@ -0,0 +1,24 @@ +using AndroidX.AppCompat.App; + +namespace LocalNotifications; + +[Activity (Label = "Second Activity")] +public class SecondActivity : AppCompatActivity +{ + protected override void OnCreate (Bundle? bundle) + { + base.OnCreate (bundle); + + // Get the count value passed to us from MainActivity: + var count = Intent?.Extras?.GetInt (MainActivity.COUNT_KEY, -1); + + // No count was passed? Then just return. + if (count is not null && count <= 0) + return; + + // Display the count sent from the first activity: + SetContentView (Resource.Layout.Second); + var txtView = RequireViewById<TextView> (Resource.Id.textView1); + txtView.Text = $"You clicked the button {count} times in the previous activity."; + } +} diff --git a/LocalNotifications/README.md b/LocalNotifications/README.md new file mode 100644 index 0000000..6c90ea3 --- /dev/null +++ b/LocalNotifications/README.md @@ -0,0 +1,20 @@ +--- +name: Xamarin.Android - Android Local Notifications Sample +description: This sample app accompanies the article Using Local Notifications in Xamarin.Android. +page_type: sample +languages: +- csharp +products: +- xamarin +urlFragment: localnotifications +--- +# Android Local Notifications Sample + +This sample app accompanies the article, +[Walkthrough - Using Local Notifications in Xamarin.Android](https://docs.microsoft.com/xamarin/android/app-fundamentals/notifications/local-notifications-walkthrough). + +![Android app screenshot](Screenshots/screenshot-1.png) + +When you tap the button displayed in the MainActivity screen, a +notification is created. When you tap the notification, it +takes you to a SecondActivity screen. diff --git a/LocalNotifications/Screenshots/screenshot-1.png b/LocalNotifications/Screenshots/screenshot-1.png new file mode 100644 index 0000000..c1c3fff Binary files /dev/null and b/LocalNotifications/Screenshots/screenshot-1.png differ diff --git a/LocalNotifications/Screenshots/screenshot-2.png b/LocalNotifications/Screenshots/screenshot-2.png new file mode 100644 index 0000000..caa262b Binary files /dev/null and b/LocalNotifications/Screenshots/screenshot-2.png differ
dotnet/android-samples
1c45b852b21cdcf2c95604641b134abae1827032
Add URL to XA NET6 porting tips document
diff --git a/README.md b/README.md index c780e6c..545c39e 100644 --- a/README.md +++ b/README.md @@ -1,170 +1,172 @@ # MonoDroid (Xamarin.Android) samples _NOTE: see the [dotnet branch](https://github.com/xamarin/monodroid-samples/tree/dotnet) for a subset of samples that have been ported to .NET 6._ This repository contains Mono for Android samples, showing usage of various Android API wrappers from C#. Visit the [Android Sample Gallery](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) to download individual samples. ## License The Apache License 2.0 applies to all samples in this repository. Copyright 2011 Xamarin Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ## Porting to NET6 When porting a legacy sample to NET6+, please make sure to preserve as much history of the original sample as possible. Some samples have their project, source and resource files in the same directory where the readme file, screenshot folder and other files not directly related to the sample code reside. Since NET6+ defaults to importing all the files in the project directory as if they were part of the project, the application code must first be moved to a subdirectory (with the exception of the .sln file). New subdirectory should use the same name as the solution file, without the .sln extension. After creating it **first** move all the relevant files and directories (source code, project file(s), the `Properties` and `Resources` directories etc), using the `git mv` command to the newly created directory, modify the .sln file to update project file path(s) and **commit** these changes. This ensures that further changes will preserve commit history. Now the sample is ready for porting. After creating new project file (using `dotnet new android -n SampleName`) in a separate directory, copy any necessary package and project references from the old project, updating them as needed and after that replace the old project file with the new one. A handful of useful tips (copied from the `dotnet` branch's README in this repository): 1. If the root namespace doesn't match the project name, to get the existing code to compile, you may need: ``` xml <RootNamespace>Xamarin.AidlDemo</RootNamespace> ``` 2. Update any dependencies, NuGet packages, etc. 3. Remove android:versionCode, android:versionName, package, <uses-sdk/>, and <application label="". These are defined in the .csproj file. 4. Remove all unused using statements, since we now have ImplicitUsings=enable. 5. Fix all namespace declarations to use C# 10 file-scoped namespaces. 6. Build. Fix any warnings related to nullable reference types (Nullable=enable). 7. Run the app and ensure the sample still works. +Another collection of tips can be found [here](https://github.com/xamarin/xamarin-android/wiki/Migrating-Xamarin.Android-Applications-to-.NET-6) + ## Contributing Before adding a sample to the repository, please run either install-hook.bat or install-hook.sh depending on whether you're on Windows or a POSIX system. This will install a Git hook that runs the Xamarin code sample validator before a commit, to ensure that all samples are good to go. ## Samples Submission Guidelines ## Galleries We love samples! Application samples show off our platform and provide a great way for people to learn our stuff. And we even promote them as a first-class feature of the docs site. You can find the sample galleries here: - [Xamarin.Forms Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Forms) - [iOS Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.iOS) - [Mac Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Mac) - [Android Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) ## Sample GitHub Repositories These sample galleries are populated by samples in these GitHub repos: - [https://github.com/xamarin/xamarin-forms-samples](https://github.com/xamarin/xamarin-forms-samples) - [https://github.com/xamarin/mobile-samples](https://github.com/xamarin/mobile-samples) - [https://github.com/xamarin/ios-samples](https://github.com/xamarin/ios-samples) - [https://github.com/xamarin/mac-samples](https://github.com/xamarin/mac-samples) - [https://github.com/xamarin/monodroid-samples](https://github.com/xamarin/monodroid-samples) - [https://github.com/xamarin/mac-ios-samples](https://github.com/xamarin/mac-ios-samples) The [mobile-samples](https://github.com/xamarin/mobile-samples) repository is for samples that are cross-platform. The [mac-ios-samples](https://github.com/xamarin/mac-ios-samples) repository is for samples that are Mac/iOS only. ## Sample Requirements We welcome sample submissions, please start by creating an issue with your proposal. Because the sample galleries are powered by the github sample repos, each sample needs to have the following things: - **Screenshots** - a folder called Screenshots that has at least one screen shot of the sample on each platform (preferably a screen shot for every page or every major piece of functionality). For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo/Screenshots). - **Readme** - a `README.md` file that explains the sample, and contains metadata to help customers find it. For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/blob/master/android-p/AndroidPMiniDemo/README.md). The README file should begin with a YAML header (delimited by `---`) with the following keys/values: - **name** - must begin with `Xamarin.Android -` - **description** - brief description of the sample (&lt; 150 chars) that appears in the sample code browser search - **page_type** - must be the string `sample`. - **languages** - coding language/s used in the sample, such as: `csharp`, `fsharp`, `vb`, `java` - **products**: should be `xamarin` for every sample in this repo - **urlFragment**: although this can be auto-generated, please supply an all-lowercase value that represents the sample's path in this repo, except directory separators are replaced with dashes (`-`) and no other punctuation. Here is a working example from [_android-p/AndroidPMiniDemo_ README raw view](https://raw.githubusercontent.com/xamarin/monodroid-samples/master/android-p/AndroidPMiniDemo/README.md). ```yaml --- name: Xamarin.Android - Android P Mini Demo description: "Demonstrates new display cutout and image notification features (Android Pie)" page_type: sample languages: - csharp products: - xamarin urlFragment: android-p-androidpminidemo --- # Heading 1 rest of README goes here, including screenshot images and requirements/instructions to get it running ``` > NOTE: This must be valid YAML, so some characters in the name or description will require the entire string to be surrounded by " or ' quotes. - **Buildable solution and .csproj file** - the project _must_ build and have the appropriate project scaffolding (solution + .csproj files). This approach ensures that all samples integrate with the Microsoft [sample code browser](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android). A good example of this stuff is here in the [Android Pie sample](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo) For a cross-platform sample, please see: https://github.com/xamarin/mobile-samples/tree/master/Tasky ## GitHub Integration We integrate tightly with Git to make sure we always provide working samples to our customers. This is achieved through a pre-commit hook that runs before your commit goes through, as well as a post-receive hook on GitHub's end that notifies our samples gallery server when changes go through. To you, as a sample committer, this means that before you push to the repos, you should run the "install-hook.bat" or "install-hook.sh" (depending on whether you're on Windows or macOS/Linux, respectively). These will install the Git pre-commit hook. Now, whenever you try to make a Git commit, all samples in the repo will be validated. If any sample fails to validate, the commit is aborted; otherwise, your commit goes through and you can go ahead and push. This strict approach is put in place to ensure that the samples we present to our customers are always in a good state, and to ensure that all samples integrate correctly with the sample gallery (README.md, Metadata.xml, etc). Note that the master branch of each sample repo is what we present to our customers for our stable releases, so they must *always* Just Work. Should you wish to invoke validation of samples manually, simply run "validate.windows" or "validate.posix" (again, Windows vs macOS/Linux, respectively). These must be run from a Bash shell (i.e. a terminal on macOS/Linux or the Git Bash terminal on Windows). If you have any questions, don't hesitate to ask!
dotnet/android-samples
4092b3bdfc74732b537ef297909fcde2dee2fd00
Add some NET6 porting tips
diff --git a/README.md b/README.md index c6ad347..c780e6c 100644 --- a/README.md +++ b/README.md @@ -1,127 +1,170 @@ # MonoDroid (Xamarin.Android) samples _NOTE: see the [dotnet branch](https://github.com/xamarin/monodroid-samples/tree/dotnet) for a subset of samples that have been ported to .NET 6._ This repository contains Mono for Android samples, showing usage of various Android API wrappers from C#. Visit the [Android Sample Gallery](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) to download individual samples. ## License The Apache License 2.0 applies to all samples in this repository. Copyright 2011 Xamarin Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +## Porting to NET6 + +When porting a legacy sample to NET6+, please make sure to preserve as +much history of the original sample as possible. Some samples have +their project, source and resource files in the same directory where +the readme file, screenshot folder and other files not directly +related to the sample code reside. Since NET6+ defaults to importing +all the files in the project directory as if they were part of the +project, the application code must first be moved to a subdirectory +(with the exception of the .sln file). + +New subdirectory should use the same name as the solution file, +without the .sln extension. After creating it **first** move all the +relevant files and directories (source code, project file(s), the +`Properties` and `Resources` directories etc), using the `git mv` +command to the newly created directory, modify the .sln file to update +project file path(s) and **commit** these changes. This ensures that +further changes will preserve commit history. + +Now the sample is ready for porting. After creating new project file +(using `dotnet new android -n SampleName`) in a separate directory, +copy any necessary package and project references from the old +project, updating them as needed and after that replace the old +project file with the new one. + +A handful of useful tips (copied from the `dotnet` branch's README in +this repository): + + 1. If the root namespace doesn't match the project name, to get the existing code to compile, you may need: + +``` xml +<RootNamespace>Xamarin.AidlDemo</RootNamespace> + +``` + 2. Update any dependencies, NuGet packages, etc. + 3. Remove android:versionCode, android:versionName, package, + <uses-sdk/>, and <application label="". These are defined in the + .csproj file. + 4. Remove all unused using statements, since we now have ImplicitUsings=enable. + 5. Fix all namespace declarations to use C# 10 file-scoped namespaces. + 6. Build. Fix any warnings related to nullable reference types (Nullable=enable). + 7. Run the app and ensure the sample still works. + ## Contributing Before adding a sample to the repository, please run either install-hook.bat or install-hook.sh depending on whether you're on Windows or a POSIX system. This will install a Git hook that runs the Xamarin code sample validator before a commit, to ensure that all samples are good to go. ## Samples Submission Guidelines ## Galleries We love samples! Application samples show off our platform and provide a great way for people to learn our stuff. And we even promote them as a first-class feature of the docs site. You can find the sample galleries here: - [Xamarin.Forms Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Forms) - [iOS Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.iOS) - [Mac Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Mac) - [Android Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) ## Sample GitHub Repositories These sample galleries are populated by samples in these GitHub repos: - [https://github.com/xamarin/xamarin-forms-samples](https://github.com/xamarin/xamarin-forms-samples) - [https://github.com/xamarin/mobile-samples](https://github.com/xamarin/mobile-samples) - [https://github.com/xamarin/ios-samples](https://github.com/xamarin/ios-samples) - [https://github.com/xamarin/mac-samples](https://github.com/xamarin/mac-samples) - [https://github.com/xamarin/monodroid-samples](https://github.com/xamarin/monodroid-samples) - [https://github.com/xamarin/mac-ios-samples](https://github.com/xamarin/mac-ios-samples) The [mobile-samples](https://github.com/xamarin/mobile-samples) repository is for samples that are cross-platform. The [mac-ios-samples](https://github.com/xamarin/mac-ios-samples) repository is for samples that are Mac/iOS only. ## Sample Requirements We welcome sample submissions, please start by creating an issue with your proposal. Because the sample galleries are powered by the github sample repos, each sample needs to have the following things: - **Screenshots** - a folder called Screenshots that has at least one screen shot of the sample on each platform (preferably a screen shot for every page or every major piece of functionality). For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo/Screenshots). - **Readme** - a `README.md` file that explains the sample, and contains metadata to help customers find it. For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/blob/master/android-p/AndroidPMiniDemo/README.md). The README file should begin with a YAML header (delimited by `---`) with the following keys/values: - **name** - must begin with `Xamarin.Android -` - **description** - brief description of the sample (&lt; 150 chars) that appears in the sample code browser search - **page_type** - must be the string `sample`. - **languages** - coding language/s used in the sample, such as: `csharp`, `fsharp`, `vb`, `java` - **products**: should be `xamarin` for every sample in this repo - **urlFragment**: although this can be auto-generated, please supply an all-lowercase value that represents the sample's path in this repo, except directory separators are replaced with dashes (`-`) and no other punctuation. Here is a working example from [_android-p/AndroidPMiniDemo_ README raw view](https://raw.githubusercontent.com/xamarin/monodroid-samples/master/android-p/AndroidPMiniDemo/README.md). ```yaml --- name: Xamarin.Android - Android P Mini Demo description: "Demonstrates new display cutout and image notification features (Android Pie)" page_type: sample languages: - csharp products: - xamarin urlFragment: android-p-androidpminidemo --- # Heading 1 rest of README goes here, including screenshot images and requirements/instructions to get it running ``` > NOTE: This must be valid YAML, so some characters in the name or description will require the entire string to be surrounded by " or ' quotes. - **Buildable solution and .csproj file** - the project _must_ build and have the appropriate project scaffolding (solution + .csproj files). This approach ensures that all samples integrate with the Microsoft [sample code browser](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android). A good example of this stuff is here in the [Android Pie sample](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo) For a cross-platform sample, please see: https://github.com/xamarin/mobile-samples/tree/master/Tasky ## GitHub Integration We integrate tightly with Git to make sure we always provide working samples to our customers. This is achieved through a pre-commit hook that runs before your commit goes through, as well as a post-receive hook on GitHub's end that notifies our samples gallery server when changes go through. To you, as a sample committer, this means that before you push to the repos, you should run the "install-hook.bat" or "install-hook.sh" (depending on whether you're on Windows or macOS/Linux, respectively). These will install the Git pre-commit hook. Now, whenever you try to make a Git commit, all samples in the repo will be validated. If any sample fails to validate, the commit is aborted; otherwise, your commit goes through and you can go ahead and push. This strict approach is put in place to ensure that the samples we present to our customers are always in a good state, and to ensure that all samples integrate correctly with the sample gallery (README.md, Metadata.xml, etc). Note that the master branch of each sample repo is what we present to our customers for our stable releases, so they must *always* Just Work. Should you wish to invoke validation of samples manually, simply run "validate.windows" or "validate.posix" (again, Windows vs macOS/Linux, respectively). These must be run from a Bash shell (i.e. a terminal on macOS/Linux or the Git Bash terminal on Windows). If you have any questions, don't hesitate to ask!
dotnet/android-samples
959e3279a604174d02f9df426ed933f9bbb354f9
Port AccelerometerPlay to NET6
diff --git a/AccelerometerPlay/AccelerometerPlay.sln b/AccelerometerPlay/AccelerometerPlay.sln index 91c20ac..aea3d2e 100644 --- a/AccelerometerPlay/AccelerometerPlay.sln +++ b/AccelerometerPlay/AccelerometerPlay.sln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccelerometerPlay", "AccelerometerPlay.csproj", "{B2164643-D5C4-4CF3-BB44-F60073A4DA33}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B2164643-D5C4-4CF3-BB44-F60073A4DA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2164643-D5C4-4CF3-BB44-F60073A4DA33}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2164643-D5C4-4CF3-BB44-F60073A4DA33}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {B2164643-D5C4-4CF3-BB44-F60073A4DA33}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2164643-D5C4-4CF3-BB44-F60073A4DA33}.Release|Any CPU.Build.0 = Release|Any CPU - {B2164643-D5C4-4CF3-BB44-F60073A4DA33}.Release|Any CPU.Deploy.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccelerometerPlay", "AccelerometerPlay\AccelerometerPlay.csproj", "{5945F063-F2E0-4F2A-A84D-AEB23E387888}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5945F063-F2E0-4F2A-A84D-AEB23E387888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5945F063-F2E0-4F2A-A84D-AEB23E387888}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5945F063-F2E0-4F2A-A84D-AEB23E387888}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5945F063-F2E0-4F2A-A84D-AEB23E387888}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/AccelerometerPlay/AccelerometerPlay/AccelerometerActivity.cs b/AccelerometerPlay/AccelerometerPlay/AccelerometerActivity.cs index aab2483..5e588d8 100644 --- a/AccelerometerPlay/AccelerometerPlay/AccelerometerActivity.cs +++ b/AccelerometerPlay/AccelerometerPlay/AccelerometerActivity.cs @@ -1,76 +1,73 @@ -/* +namespace AccelerometerPlay; + +/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -using System; -using Android.App; -using Android.Hardware; -using Android.OS; -using Android.Runtime; -using Android.Views; - // This is an example of using the accelerometer to integrate the device's // acceleration to a position using the Verlet method. This is illustrated with // a very simple particle system comprised of a few iron balls freely moving on // an inclined wooden table. The inclination of the virtual table is controlled // by the device's accelerometer. -namespace AccelerometerPlay + +using Android.Hardware; +using Android.Views; + +using Java.Interop; + +[Activity (Label = "Accelerometer Demo", MainLauncher = true, Icon = "@mipmap/appicon", ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape)] +public class AccelerometerActivity : Activity { - [Activity (Label = "Accelerometer Demo", MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape)] - public class AccelerometerActivity : Activity - { - private SimulationView sim_view; - private SensorManager sensor_manager; - private IWindowManager window_manager; + SimulationView? sim_view; + SensorManager? sensor_manager; + IWindowManager? window_manager; - protected override void OnCreate (Bundle bundle) - { - base.OnCreate (bundle); + protected override void OnCreate (Bundle? bundle) + { + base.OnCreate (bundle); - // Remove the title bar - RequestWindowFeature (WindowFeatures.NoTitle); + // Remove the title bar + RequestWindowFeature (WindowFeatures.NoTitle); - // Keep the screen from turning off while we're running - Window.AddFlags (WindowManagerFlags.KeepScreenOn); + // Keep the screen from turning off while we're running + Window?.AddFlags (WindowManagerFlags.KeepScreenOn); - // Get an instance of the SensorManager - sensor_manager = (SensorManager)GetSystemService (Activity.SensorService); + // Get an instance of the SensorManager + sensor_manager = (SensorManager?)GetSystemService (Activity.SensorService) ?? throw new InvalidOperationException ("Unable to obtain the sensor service instance"); - // Get an instance of the WindowManager - window_manager = GetSystemService (Activity.WindowService).JavaCast<IWindowManager> (); + // Get an instance of the WindowManager + window_manager = GetSystemService (Activity.WindowService).JavaCast<IWindowManager> () ?? throw new InvalidOperationException ("Unable to obtain the window manager service instance"); - // Instantiate our simulation view and set it as the activity's content - sim_view = new SimulationView (this, sensor_manager, window_manager); - SetContentView (sim_view); - } + // Instantiate our simulation view and set it as the activity's content + sim_view = new SimulationView (this, sensor_manager, window_manager); + SetContentView (sim_view); + } - protected override void OnResume () - { - base.OnResume (); + protected override void OnResume () + { + base.OnResume (); - // Start tracking the sensor - sim_view.StartSimulation (); - } + // Start tracking the sensor + sim_view!.StartSimulation (); + } - protected override void OnPause () - { - base.OnPause (); + protected override void OnPause () + { + base.OnPause (); - // Stop tracking the sensor - sim_view.StopSimulation (); - } + // Stop tracking the sensor + sim_view!.StopSimulation (); } } - diff --git a/AccelerometerPlay/AccelerometerPlay/AccelerometerPlay.csproj b/AccelerometerPlay/AccelerometerPlay/AccelerometerPlay.csproj index bb26a43..ede8b79 100644 --- a/AccelerometerPlay/AccelerometerPlay/AccelerometerPlay.csproj +++ b/AccelerometerPlay/AccelerometerPlay/AccelerometerPlay.csproj @@ -1,89 +1,12 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.30703</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{B2164643-D5C4-4CF3-BB44-F60073A4DA33}</ProjectGuid> - <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>AccelerometerPlay</RootNamespace> - <AssemblyName>AccelerometerPlay</AssemblyName> - <FileAlignment>512</FileAlignment> - <AndroidApplication>true</AndroidApplication> - <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> - <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> - <AndroidStoreUncompressedFileExtensions /> - <MandroidI18n /> - <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> - <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> + <TargetFramework>net6.0-android</TargetFramework> + <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.microsoft.accelerometerplay</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>True</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>False</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <AndroidLinkMode>None</AndroidLinkMode> - <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>True</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> - </PropertyGroup> - <ItemGroup> - <Reference Include="Mono.Android" /> - <Reference Include="mscorlib" /> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="AccelerometerActivity.cs" /> - <Compile Include="Particle.cs" /> - <Compile Include="ParticleSystem.cs" /> - <Compile Include="PointF.cs" /> - <Compile Include="Resources\Resource.Designer.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="SimulationView.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="Resources\AboutResources.txt" /> - <None Include="Properties\AndroidManifest.xml" /> - </ItemGroup> - <ItemGroup> - <AndroidResource Include="Resources\drawable-mdpi\Wood.jpg" /> - <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> - <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> - <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> - <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> - <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> - </ItemGroup> - <ItemGroup> - <AndroidResource Include="Resources\drawable-mdpi\Ball.png" /> - </ItemGroup> - <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> - <ItemGroup> - <Folder Include="Resources\drawable-hdpi\" /> - <Folder Include="Resources\drawable-ldpi\" /> - <Folder Include="Resources\drawable-xhdpi\" /> - <Folder Include="Resources\drawable-xxhdpi\" /> - </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/AccelerometerPlay/AccelerometerPlay/AndroidManifest.xml b/AccelerometerPlay/AccelerometerPlay/AndroidManifest.xml new file mode 100644 index 0000000..3fead98 --- /dev/null +++ b/AccelerometerPlay/AccelerometerPlay/AndroidManifest.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Particle.cs b/AccelerometerPlay/AccelerometerPlay/Particle.cs index cd597f3..6c8cf00 100644 --- a/AccelerometerPlay/AccelerometerPlay/Particle.cs +++ b/AccelerometerPlay/AccelerometerPlay/Particle.cs @@ -1,99 +1,96 @@ -/* +namespace AccelerometerPlay; + +/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -using System; - // Each of our particle holds its previous and current position, its // acceleration. For added realism each particle has its own friction // coefficient. -namespace AccelerometerPlay +class Particle { - class Particle - { - private ParticleSystem system; + ParticleSystem system; - private PointF prev_location = new PointF (); - private PointF accel = new PointF (); - private float friction; + PointF prev_location = new PointF (); + PointF accel = new PointF (); + float friction; - public PointF Location { get; private set; } + public PointF Location { get; private set; } - public Particle (ParticleSystem system) - { - this.system = system; - Location = new PointF (); + public Particle (ParticleSystem system) + { + this.system = system; + Location = new PointF (); - // Make each particle a bit different by randomizing its - // coefficient of friction - var random = new Random (); - var r = ((float)random.NextDouble () - 0.5f) * 0.2f; + // Make each particle a bit different by randomizing its + // coefficient of friction + var random = new Random (); + var r = ((float)random.NextDouble () - 0.5f) * 0.2f; - friction = 1.0f - SimulationView.FRICTION + r; - } + friction = 1.0f - SimulationView.FRICTION + r; + } - public void ComputePhysics (float sx, float sy, float dT, float dTC) - { - // Force of gravity applied to our virtual object - float m = 1000.0f; // mass of our virtual object - float gx = -sx * m; - float gy = -sy * m; + public void ComputePhysics (float sx, float sy, float dT, float dTC) + { + // Force of gravity applied to our virtual object + float m = 1000.0f; // mass of our virtual object + float gx = -sx * m; + float gy = -sy * m; - // ·F = mA <=> A = ·F / m We could simplify the code by - // completely eliminating "m" (the mass) from all the equations, - // but it would hide the concepts from this sample code. - float invm = 1.0f / m; - float ax = gx * invm; - float ay = gy * invm; + // ·F = mA <=> A = ·F / m We could simplify the code by + // completely eliminating "m" (the mass) from all the equations, + // but it would hide the concepts from this sample code. + float invm = 1.0f / m; + float ax = gx * invm; + float ay = gy * invm; - // Time-corrected Verlet integration The position Verlet - // integrator is defined as x(t+Æt) = x(t) + x(t) - x(t-Æt) + - // a(t)Ætö2 However, the above equation doesn't handle variable - // Æt very well, a time-corrected version is needed: x(t+Æt) = - // x(t) + (x(t) - x(t-Æt)) * (Æt/Æt_prev) + a(t)Ætö2 We also add - // a simple friction term (f) to the equation: x(t+Æt) = x(t) + - // (1-f) * (x(t) - x(t-Æt)) * (Æt/Æt_prev) + a(t)Ætö2 - float dTdT = dT * dT; - float x = Location.X + friction * dTC * (Location.X - prev_location.X) + accel.X * dTdT; - float y = Location.Y + friction * dTC * (Location.Y - prev_location.Y) + accel.Y * dTdT; + // Time-corrected Verlet integration The position Verlet + // integrator is defined as x(t+Æt) = x(t) + x(t) - x(t-Æt) + + // a(t)Ætö2 However, the above equation doesn't handle variable + // Æt very well, a time-corrected version is needed: x(t+Æt) = + // x(t) + (x(t) - x(t-Æt)) * (Æt/Æt_prev) + a(t)Ætö2 We also add + // a simple friction term (f) to the equation: x(t+Æt) = x(t) + + // (1-f) * (x(t) - x(t-Æt)) * (Æt/Æt_prev) + a(t)Ætö2 + float dTdT = dT * dT; + float x = Location.X + friction * dTC * (Location.X - prev_location.X) + accel.X * dTdT; + float y = Location.Y + friction * dTC * (Location.Y - prev_location.Y) + accel.Y * dTdT; - prev_location.Set (Location); - Location.Set (x, y); - accel.Set (ax, ay); - } + prev_location.Set (Location); + Location.Set (x, y); + accel.Set (ax, ay); + } - // Resolving constraints and collisions with the Verlet integrator - // can be very simple, we simply need to move a colliding or - // constrained particle in such way that the constraint is - // satisfied. - public void ResolveCollisionWithBounds () - { - float xmax = system.sim_view.Bounds.X; - float ymax = system.sim_view.Bounds.Y; - float x = Location.X; - float y = Location.Y; + // Resolving constraints and collisions with the Verlet integrator + // can be very simple, we simply need to move a colliding or + // constrained particle in such way that the constraint is + // satisfied. + public void ResolveCollisionWithBounds () + { + float xmax = system.sim_view.Bounds.X; + float ymax = system.sim_view.Bounds.Y; + float x = Location.X; + float y = Location.Y; - if (x > xmax) - Location.X = xmax; - else if (x < -xmax) - Location.X = -xmax; + if (x > xmax) + Location.X = xmax; + else if (x < -xmax) + Location.X = -xmax; - if (y > ymax) - Location.Y = ymax; - else if (y < -ymax) - Location.Y = -ymax; - } + if (y > ymax) + Location.Y = ymax; + else if (y < -ymax) + Location.Y = -ymax; } } diff --git a/AccelerometerPlay/AccelerometerPlay/ParticleSystem.cs b/AccelerometerPlay/AccelerometerPlay/ParticleSystem.cs index ad4ebf3..8512c2f 100644 --- a/AccelerometerPlay/AccelerometerPlay/ParticleSystem.cs +++ b/AccelerometerPlay/AccelerometerPlay/ParticleSystem.cs @@ -1,126 +1,122 @@ -/* +namespace AccelerometerPlay; + +/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -using System; -using System.Collections.Generic; - // A particle system is just a collection of particles -namespace AccelerometerPlay +class ParticleSystem { - class ParticleSystem - { - public long last_t; - public float last_delta_t; - - static int NUM_PARTICLES = 15; - public SimulationView sim_view; + public long last_t; + public float last_delta_t; - public List<Particle> Balls { get; private set; } + static int NUM_PARTICLES = 15; + public SimulationView sim_view; - public ParticleSystem (SimulationView view) - { - sim_view = view; - Balls = new List<Particle> (); + public List<Particle> Balls { get; private set; } - // Initially our particles have no speed or acceleration - for (int i = 0; i < NUM_PARTICLES; i++) - Balls.Add (new Particle (this)); - } + public ParticleSystem (SimulationView view) + { + sim_view = view; + Balls = new List<Particle> (); - // Update the position of each particle in the system using the - // Verlet integrator. - private void UpdatePositions (float sx, float sy, long timestamp) - { - long t = timestamp; + // Initially our particles have no speed or acceleration + for (int i = 0; i < NUM_PARTICLES; i++) + Balls.Add (new Particle (this)); + } - if (last_t != 0) { - float dT = (float)(t - last_t) * (1.0f / 1000000000.0f); + // Update the position of each particle in the system using the + // Verlet integrator. + void UpdatePositions (float sx, float sy, long timestamp) + { + long t = timestamp; - if (last_delta_t != 0) { - float dTC = dT / last_delta_t; + if (last_t != 0) { + float dT = (float)(t - last_t) * (1.0f / 1000000000.0f); - foreach (var ball in Balls) - ball.ComputePhysics (sx, sy, dT, dTC); - } + if (last_delta_t != 0) { + float dTC = dT / last_delta_t; - last_delta_t = dT; + foreach (var ball in Balls) + ball.ComputePhysics (sx, sy, dT, dTC); } - last_t = t; + last_delta_t = dT; } - // Performs one iteration of the simulation. First updating the - // position of all the particles and resolving the constraints and - // collisions. - public void Update (float sx, float sy, long now) - { - // update the system's positions - UpdatePositions (sx, sy, now); + last_t = t; + } - // We do no more than a limited number of iterations - int NUM_MAX_ITERATIONS = 10; + // Performs one iteration of the simulation. First updating the + // position of all the particles and resolving the constraints and + // collisions. + public void Update (float sx, float sy, long now) + { + // update the system's positions + UpdatePositions (sx, sy, now); + + // We do no more than a limited number of iterations + int NUM_MAX_ITERATIONS = 10; - // Resolve collisions, each particle is tested against every - // other particle for collision. If a collision is detected the - // particle is moved away using a virtual spring of infinite - // stiffness. - var random = new Random (); + // Resolve collisions, each particle is tested against every + // other particle for collision. If a collision is detected the + // particle is moved away using a virtual spring of infinite + // stiffness. + var random = new Random (); - bool more = true; + bool more = true; - for (int k = 0; k < NUM_MAX_ITERATIONS && more; k++) { - more = false; + for (int k = 0; k < NUM_MAX_ITERATIONS && more; k++) { + more = false; - for (int i = 0; i < Balls.Count; i++) { - var curr = Balls[i]; + for (int i = 0; i < Balls.Count; i++) { + var curr = Balls[i]; - for (int j = i + 1; j < Balls.Count; j++) { - var ball = Balls[j]; + for (int j = i + 1; j < Balls.Count; j++) { + var ball = Balls[j]; - var dx = ball.Location.X - curr.Location.X; - var dy = ball.Location.Y - curr.Location.Y; - var dd = dx * dx + dy * dy; + var dx = ball.Location.X - curr.Location.X; + var dy = ball.Location.Y - curr.Location.Y; + var dd = dx * dx + dy * dy; - // Check for collisions - if (dd <= SimulationView.BALL_DIAMETER_2) { + // Check for collisions + if (dd <= SimulationView.BALL_DIAMETER_2) { - // add a little bit of entropy, after nothing is - // perfect in the universe. - dx += ((float)random.Next () - 0.5f) * 0.0001f; - dy += ((float)random.Next () - 0.5f) * 0.0001f; - dd = dx * dx + dy * dy; - - // simulate the spring - var d = (float)Math.Sqrt (dd); - var c = (0.5f * (SimulationView.BALL_DIAMETER - d)) / d; - - curr.Location.X -= dx * c; - curr.Location.Y -= dy * c; - ball.Location.X += dx * c; - ball.Location.Y += dy * c; - - more = true; - } + // add a little bit of entropy, after nothing is + // perfect in the universe. + dx += ((float)random.Next () - 0.5f) * 0.0001f; + dy += ((float)random.Next () - 0.5f) * 0.0001f; + dd = dx * dx + dy * dy; + + // simulate the spring + var d = (float)Math.Sqrt (dd); + var c = (0.5f * (SimulationView.BALL_DIAMETER - d)) / d; + + curr.Location.X -= dx * c; + curr.Location.Y -= dy * c; + ball.Location.X += dx * c; + ball.Location.Y += dy * c; + + more = true; } - - // Finally make sure the particle doesn't intersects - // with the walls. - curr.ResolveCollisionWithBounds (); } + + // Finally make sure the particle doesn't intersects + // with the walls. + curr.ResolveCollisionWithBounds (); } } } } diff --git a/AccelerometerPlay/AccelerometerPlay/PointF.cs b/AccelerometerPlay/AccelerometerPlay/PointF.cs index 40f1973..e6efad0 100644 --- a/AccelerometerPlay/AccelerometerPlay/PointF.cs +++ b/AccelerometerPlay/AccelerometerPlay/PointF.cs @@ -1,39 +1,36 @@ -/* +namespace AccelerometerPlay; + +/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -using System; - // It's cheaper to use a fully .Net point class than Android.Graphics.PointF -namespace AccelerometerPlay +class PointF { - class PointF - { - public float X; - public float Y; + public float X; + public float Y; - public void Set (float x, float y) - { - X = x; - Y = y; - } + public void Set (float x, float y) + { + X = x; + Y = y; + } - public void Set (PointF point) - { - X = point.X; - Y = point.Y; - } + public void Set (PointF point) + { + X = point.X; + Y = point.Y; } } diff --git a/AccelerometerPlay/AccelerometerPlay/Properties/AndroidManifest.xml b/AccelerometerPlay/AccelerometerPlay/Properties/AndroidManifest.xml deleted file mode 100644 index dac99b1..0000000 --- a/AccelerometerPlay/AccelerometerPlay/Properties/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="AccelerometerPlay.AccelerometerPlay"> - <uses-sdk /> - <application android:label="AccelerometerPlay"> - </application> -</manifest> \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Properties/AssemblyInfo.cs b/AccelerometerPlay/AccelerometerPlay/Properties/AssemblyInfo.cs deleted file mode 100644 index 5d668ac..0000000 --- a/AccelerometerPlay/AccelerometerPlay/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using Android.App; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle ("AccelerometerPlay")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("AccelerometerPlay")] -[assembly: AssemblyCopyright ("Copyright © 2012")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible (false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid ("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.0.0.0")] -[assembly: AssemblyFileVersion ("1.0.0.0")] -[assembly: Application (Label = "Accelerometer Demo (MFA)", Icon = "@drawable/icon")] \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/AboutResources.txt b/AccelerometerPlay/AccelerometerPlay/Resources/AboutResources.txt index b0fc999..219f425 100644 --- a/AccelerometerPlay/AccelerometerPlay/Resources/AboutResources.txt +++ b/AccelerometerPlay/AccelerometerPlay/Resources/AboutResources.txt @@ -1,44 +1,44 @@ Images, layout descriptions, binary blobs and string dictionaries can be included in your application as resource files. Various Android APIs are designed to operate on the resource IDs instead of dealing with images, strings or binary blobs directly. -For example, a sample Android app that contains a user interface layout (Main.xml), -an internationalization string table (Strings.xml) and some icons (drawable/Icon.png) +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) would keep its resources in the "Resources" directory of the application: Resources/ - Drawable/ - Icon.png + drawable/ + icon.png - Layout/ - Main.axml + layout/ + main.xml - Values/ - Strings.xml + values/ + strings.xml -In order to get the build system to recognize Android resources, the build action should be set -to "AndroidResource". The native Android APIs do not operate directly with filenames, but +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but instead operate on resource IDs. When you compile an Android application that uses resources, -the build system will package the resources for distribution and generate a class called -"Resource" that contains the tokens for each one of the resources included. For example, -for the above Resources layout, this is what the Resource class would expose: +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: public class Resource { public class Drawable { - public const int Icon = 0x123; + public const int icon = 0x123; } public class Layout { - public const int Main = 0x456; + public const int main = 0x456; } - public class String { - public const int FirstString = 0xabc; - public const int SecondString = 0xbcd; + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; } } -You would then use Resource.Drawable.Icon to reference the Drawable/Icon.png file, or -Resource.Layout.Main to reference the Layout/Main.axml file, or Resource.String.FirstString -to reference the first string in the dictionary file Values/Strings.xml. \ No newline at end of file +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-hdpi/icon.png b/AccelerometerPlay/AccelerometerPlay/Resources/drawable-hdpi/icon.png deleted file mode 100755 index 2e6ef76..0000000 Binary files a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-hdpi/icon.png and /dev/null differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-ldpi/icon.png b/AccelerometerPlay/AccelerometerPlay/Resources/drawable-ldpi/icon.png deleted file mode 100755 index 183f309..0000000 Binary files a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-ldpi/icon.png and /dev/null differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/icon.png b/AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/icon.png deleted file mode 100755 index edefb8b..0000000 Binary files a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/icon.png and /dev/null differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-xhdpi/icon.png b/AccelerometerPlay/AccelerometerPlay/Resources/drawable-xhdpi/icon.png deleted file mode 100755 index de4bbc0..0000000 Binary files a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-xhdpi/icon.png and /dev/null differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-xxhdpi/icon.png b/AccelerometerPlay/AccelerometerPlay/Resources/drawable-xxhdpi/icon.png deleted file mode 100755 index 5e5182b..0000000 Binary files a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-xxhdpi/icon.png and /dev/null differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-anydpi-v26/appicon.xml b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-anydpi-v26/appicon.xml new file mode 100644 index 0000000..7751f69 --- /dev/null +++ b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-anydpi-v26/appicon.xml @@ -0,0 +1,4 @@ +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@mipmap/appicon_background" /> + <foreground android:drawable="@mipmap/appicon_foreground" /> +</adaptive-icon> \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-anydpi-v26/appicon_round.xml b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-anydpi-v26/appicon_round.xml new file mode 100644 index 0000000..7751f69 --- /dev/null +++ b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-anydpi-v26/appicon_round.xml @@ -0,0 +1,4 @@ +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@mipmap/appicon_background" /> + <foreground android:drawable="@mipmap/appicon_foreground" /> +</adaptive-icon> \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon.png new file mode 100644 index 0000000..f97217f Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon_background.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon_background.png new file mode 100644 index 0000000..513e69d Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon_background.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon_foreground.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon_foreground.png new file mode 100644 index 0000000..99d3a29 Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-hdpi/appicon_foreground.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/Ball.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/Ball.png similarity index 100% rename from AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/Ball.png rename to AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/Ball.png diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/Wood.jpg b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/Wood.jpg similarity index 100% rename from AccelerometerPlay/AccelerometerPlay/Resources/drawable-mdpi/Wood.jpg rename to AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/Wood.jpg diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon.png new file mode 100644 index 0000000..76ceb98 Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon_background.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon_background.png new file mode 100644 index 0000000..9e2d1e4 Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon_background.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon_foreground.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon_foreground.png new file mode 100644 index 0000000..a28d342 Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-mdpi/appicon_foreground.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon.png new file mode 100644 index 0000000..83f089c Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon_background.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon_background.png new file mode 100644 index 0000000..658be3f Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon_background.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon_foreground.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon_foreground.png new file mode 100644 index 0000000..70a542a Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xhdpi/appicon_foreground.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon.png new file mode 100644 index 0000000..988160a Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon_background.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon_background.png new file mode 100644 index 0000000..9171c3e Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon_background.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon_foreground.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon_foreground.png new file mode 100644 index 0000000..cb63bfb Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxhdpi/appicon_foreground.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon.png new file mode 100644 index 0000000..b65da5a Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon_background.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon_background.png new file mode 100644 index 0000000..1232d8c Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon_background.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon_foreground.png b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon_foreground.png new file mode 100644 index 0000000..9f9c9e6 Binary files /dev/null and b/AccelerometerPlay/AccelerometerPlay/Resources/mipmap-xxxhdpi/appicon_foreground.png differ diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/values/ic_launcher_background.xml b/AccelerometerPlay/AccelerometerPlay/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/AccelerometerPlay/AccelerometerPlay/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/AccelerometerPlay/AccelerometerPlay/Resources/values/strings.xml b/AccelerometerPlay/AccelerometerPlay/Resources/values/strings.xml new file mode 100644 index 0000000..f4d1efa --- /dev/null +++ b/AccelerometerPlay/AccelerometerPlay/Resources/values/strings.xml @@ -0,0 +1,4 @@ +<resources> + <string name="app_name">AccelerometerPlay</string> + <string name="app_text">Hello, Android!</string> +</resources> diff --git a/AccelerometerPlay/AccelerometerPlay/SimulationView.cs b/AccelerometerPlay/AccelerometerPlay/SimulationView.cs index ffd244e..17e7bbe 100644 --- a/AccelerometerPlay/AccelerometerPlay/SimulationView.cs +++ b/AccelerometerPlay/AccelerometerPlay/SimulationView.cs @@ -1,178 +1,215 @@ +namespace AccelerometerPlay; + /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - -using System; using Android.Content; +using Android.Graphics; using Android.Hardware; using Android.Util; using Android.Views; -using Android.Graphics; -namespace AccelerometerPlay +class SimulationView : View, ISensorEventListener { - class SimulationView : View, ISensorEventListener - { - // diameter of the balls in meters - public static float BALL_DIAMETER = 0.004f; - public static float BALL_DIAMETER_2 = BALL_DIAMETER * BALL_DIAMETER; + const string TAG = "APSV"; + + // diameter of the balls in meters + public static float BALL_DIAMETER = 0.004f; + public static float BALL_DIAMETER_2 = BALL_DIAMETER * BALL_DIAMETER; - // friction of the virtual table and air - public static float FRICTION = 0.1f; + // friction of the virtual table and air + public static float FRICTION = 0.1f; - private SensorManager sensor_manager; - private Sensor accel_sensor; + SensorManager sensor_manager; + Sensor accel_sensor; - private float meters_to_pixels_x; - private float meters_to_pixels_y; + float meters_to_pixels_x; + float meters_to_pixels_y; - private Bitmap ball_bitmap; - private Bitmap wood_bitmap; - private Bitmap wood_bitmap2; + Bitmap ball_bitmap; + Bitmap wood_bitmap; + Bitmap wood_bitmap2; - private PointF origin = new PointF (); - private PointF sensor_values = new PointF (); + PointF origin = new PointF (); + PointF sensor_values = new PointF (); - private long sensor_timestamp; - private long cpu_timestamp; + long sensor_timestamp; + long cpu_timestamp; - private ParticleSystem particles; - private Display display; + ParticleSystem particles; + Display display; - public PointF Bounds { get; private set; } + public PointF Bounds { get; private set; } - public SimulationView (Context context, SensorManager sensorManager, IWindowManager window) - : base (context) - { - Bounds = new PointF (); + public SimulationView (Context context, SensorManager sensorManager, IWindowManager window) + : base (context) + { + Bounds = new PointF (); + + // Get an accelorometer sensor + sensor_manager = sensorManager; + accel_sensor = sensor_manager.GetDefaultSensor (SensorType.Accelerometer) ?? throw new InvalidOperationException ("Unable to obtain default accelerometer sensor instance"); + + // Calculate screen size and dpi + DisplayMetrics metrics = context.Resources?.DisplayMetrics ?? throw new InvalidOperationException ("Unable to obtain display metrics"); + + meters_to_pixels_x = metrics.Xdpi / 0.0254f; + meters_to_pixels_y = metrics.Ydpi / 0.0254f; + + // Rescale the ball so it's about 0.5 cm on screen + var ball = EnsureValidBitmap ( + BitmapFactory.DecodeResource (Resources, Resource.Mipmap.Ball), + "Unable to decode the Ball bitmap resource" + ); + var dest_w = (int)(BALL_DIAMETER * meters_to_pixels_x + 0.5f); + var dest_h = (int)(BALL_DIAMETER * meters_to_pixels_y + 0.5f); + ball_bitmap = EnsureValidBitmap ( + Bitmap.CreateScaledBitmap (ball, dest_w, dest_h, true), + "Unable to create scaled ball bitmap" + ); + + // Load the wood background texture + var opts = new BitmapFactory.Options (); + + // InDither is deprecated (and has no effect) since API24 + if (Android.OS.Build.VERSION.SdkInt <= Android.OS.BuildVersionCodes.M) { +#pragma warning disable 0618 + opts.InDither = true; +#pragma warning restore 0618 + } - // Get an accelorometer sensor - sensor_manager = sensorManager; - accel_sensor = sensor_manager.GetDefaultSensor (SensorType.Accelerometer); + opts.InPreferredConfig = Bitmap.Config.Rgb565; + wood_bitmap = EnsureValidBitmap ( + BitmapFactory.DecodeResource (Resources, Resource.Mipmap.Wood, opts), + "Unable to decode the Wood bitmap resource (#1)" + ); + wood_bitmap2 = EnsureValidBitmap ( + BitmapFactory.DecodeResource (Resources, Resource.Mipmap.Wood, opts), + "Unable to decode the Wood bitmap resource (#1)" + ); + + display = window.DefaultDisplay ?? throw new InvalidOperationException ("Unable to obtain the default display instance"); + particles = new ParticleSystem (this); + } - // Calculate screen size and dpi - var metrics = new DisplayMetrics (); - window.DefaultDisplay.GetMetrics (metrics); + Bitmap EnsureValidBitmap (Bitmap? bitmap, string errorMessage) + { + if (bitmap != null) { + return bitmap; + } - meters_to_pixels_x = metrics.Xdpi / 0.0254f; - meters_to_pixels_y = metrics.Ydpi / 0.0254f; + throw new InvalidOperationException (errorMessage); + } - // Rescale the ball so it's about 0.5 cm on screen - var ball = BitmapFactory.DecodeResource (Resources, Resource.Drawable.Ball); - var dest_w = (int)(BALL_DIAMETER * meters_to_pixels_x + 0.5f); - var dest_h = (int)(BALL_DIAMETER * meters_to_pixels_y + 0.5f); - ball_bitmap = Bitmap.CreateScaledBitmap (ball, dest_w, dest_h, true); + public void StartSimulation () + { + // It is not necessary to get accelerometer events at a very high + // rate, by using a slower rate (SENSOR_DELAY_UI), we get an + // automatic low-pass filter, which "extracts" the gravity component + // of the acceleration. As an added benefit, we use less power and + // CPU resources. + sensor_manager.RegisterListener (this, accel_sensor, SensorDelay.Ui); + } - // Load the wood background texture - var opts = new BitmapFactory.Options (); - opts.InDither = true; - opts.InPreferredConfig = Bitmap.Config.Rgb565; - wood_bitmap = BitmapFactory.DecodeResource (Resources, Resource.Drawable.Wood, opts); - wood_bitmap2 = BitmapFactory.DecodeResource (Resources, Resource.Drawable.Wood, opts); + public void StopSimulation () + { + sensor_manager.UnregisterListener (this); + } - display = window.DefaultDisplay; - particles = new ParticleSystem (this); - } + protected override void OnSizeChanged (int w, int h, int oldw, int oldh) + { + // Compute the origin of the screen relative + // to the origin of the bitmap + origin.Set ((w - ball_bitmap.Width) * 0.5f, (h - ball_bitmap.Height) * 0.5f); - public void StartSimulation () - { - // It is not necessary to get accelerometer events at a very high - // rate, by using a slower rate (SENSOR_DELAY_UI), we get an - // automatic low-pass filter, which "extracts" the gravity component - // of the acceleration. As an added benefit, we use less power and - // CPU resources. - sensor_manager.RegisterListener (this, accel_sensor, SensorDelay.Ui); - } + Bounds.X = (((float)w / (float)meters_to_pixels_x - BALL_DIAMETER) * 0.5f); + Bounds.Y = (((float)h / (float)meters_to_pixels_y - BALL_DIAMETER) * 0.5f); + + Console.WriteLine (Bounds.X); + } - public void StopSimulation () - { - sensor_manager.UnregisterListener (this); + protected override void OnDraw (Canvas? canvas) + { + // Draw the background + if (canvas == null) { + // Not much point in continuing since there's nothing to draw on + Log.Warn (TAG, "Canvas is null in SimulationView.OnDraw, cannot paint"); + return; } - protected override void OnSizeChanged (int w, int h, int oldw, int oldh) - { - // Compute the origin of the screen relative - // to the origin of the bitmap - origin.Set ((w - ball_bitmap.Width) * 0.5f, (h - ball_bitmap.Height) * 0.5f); + canvas.DrawBitmap (wood_bitmap, 0, 0, null); + canvas.DrawBitmap (wood_bitmap2, wood_bitmap.Width, 0, null); - Bounds.X = (((float)w / (float)meters_to_pixels_x - BALL_DIAMETER) * 0.5f); - Bounds.Y = (((float)h / (float)meters_to_pixels_y - BALL_DIAMETER) * 0.5f); + // Compute the new position of our object, based on accelerometer + // data and present time. + var now = sensor_timestamp + (DateTime.Now.Ticks - cpu_timestamp); + particles.Update (sensor_values.X, sensor_values.Y, now); - Console.WriteLine (Bounds.X); - } + foreach (var ball in particles.Balls) { + // We transform the canvas so that the coordinate system matches + // the sensors coordinate system with the origin in the center + // of the screen and the unit is the meter. + var x = origin.X + ball.Location.X * meters_to_pixels_x; + var y = origin.Y - ball.Location.Y * meters_to_pixels_y; - protected override void OnDraw (Canvas canvas) - { - // Draw the background - canvas.DrawBitmap (wood_bitmap, 0, 0, null); - canvas.DrawBitmap (wood_bitmap2, wood_bitmap.Width, 0, null); - - // Compute the new position of our object, based on accelerometer - // data and present time. - var now = sensor_timestamp + (DateTime.Now.Ticks - cpu_timestamp); - particles.Update (sensor_values.X, sensor_values.Y, now); - - foreach (var ball in particles.Balls) { - // We transform the canvas so that the coordinate system matches - // the sensors coordinate system with the origin in the center - // of the screen and the unit is the meter. - var x = origin.X + ball.Location.X * meters_to_pixels_x; - var y = origin.Y - ball.Location.Y * meters_to_pixels_y; - - canvas.DrawBitmap (ball_bitmap, x, y, null); - } - - // Make sure to redraw asap - Invalidate (); + canvas.DrawBitmap (ball_bitmap, x, y, null); } + // Make sure to redraw asap + Invalidate (); + } + + +#region ISensorEventListener Members + public void OnAccuracyChanged (Sensor? sensor, SensorStatus accuracy) + { + } - #region ISensorEventListener Members - public void OnAccuracyChanged (Sensor sensor, SensorStatus accuracy) - { + public void OnSensorChanged (SensorEvent? e) + { + if (e == null || e.Sensor == null || e.Values == null) { + Log.Warn (TAG, "Invalid event data in SimulationView.OnSensorChanged, cannot update"); + return; } - public void OnSensorChanged (SensorEvent e) - { - if (e.Sensor.Type != SensorType.Accelerometer) - return; - - // Record the accelerometer data, the event's timestamp as well as - // the current time. The latter is needed so we can calculate the - // "present" time during rendering. In this application, we need to - // take into account how the screen is rotated with respect to the - // sensors (which always return data in a coordinate space aligned - // to with the screen in its native orientation). - switch (display.Rotation) { - case SurfaceOrientation.Rotation0: - sensor_values.Set (e.Values[0], e.Values[1]); - break; - case SurfaceOrientation.Rotation90: - sensor_values.Set (-e.Values[1], e.Values[0]); - break; - case SurfaceOrientation.Rotation180: - sensor_values.Set (-e.Values[0], -e.Values[1]); - break; - case SurfaceOrientation.Rotation270: - sensor_values.Set (e.Values[1], -e.Values[0]); - break; - } - - sensor_timestamp = e.Timestamp; - cpu_timestamp = DateTime.Now.Ticks; + if (e.Sensor.Type != SensorType.Accelerometer) + return; + + // Record the accelerometer data, the event's timestamp as well as + // the current time. The latter is needed so we can calculate the + // "present" time during rendering. In this application, we need to + // take into account how the screen is rotated with respect to the + // sensors (which always return data in a coordinate space aligned + // to with the screen in its native orientation). + switch (display.Rotation) { + case SurfaceOrientation.Rotation0: + sensor_values.Set (e.Values[0], e.Values[1]); + break; + case SurfaceOrientation.Rotation90: + sensor_values.Set (-e.Values[1], e.Values[0]); + break; + case SurfaceOrientation.Rotation180: + sensor_values.Set (-e.Values[0], -e.Values[1]); + break; + case SurfaceOrientation.Rotation270: + sensor_values.Set (e.Values[1], -e.Values[0]); + break; } - #endregion + + sensor_timestamp = e.Timestamp; + cpu_timestamp = DateTime.Now.Ticks; } +#endregion }
dotnet/android-samples
7ea1e34d17447a6491db50ffed36f6e9bbd5665b
Port Android Sample SwitchDemo (#337)
diff --git a/SwitchDemo/Metadata.xml b/SwitchDemo/Metadata.xml new file mode 100644 index 0000000..8133d27 --- /dev/null +++ b/SwitchDemo/Metadata.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" ?> +<SampleMetadata> + <ID>08f30733-d18b-4728-88ee-2a3002cbd782</ID> + <IsFullApplication>false</IsFullApplication> + <Level>Beginning</Level> + <Tags>User Interface</Tags> + <Gallery>true</Gallery> + <Brief>This example shows how to use a switch control.</Brief> +</SampleMetadata> \ No newline at end of file diff --git a/SwitchDemo/README.md b/SwitchDemo/README.md new file mode 100644 index 0000000..e7bd984 --- /dev/null +++ b/SwitchDemo/README.md @@ -0,0 +1,22 @@ +--- +name: Xamarin.Android - Switch Demo +description: "Shows how to use a switch control" +page_type: sample +languages: +- csharp +products: +- xamarin +extensions: + tags: + - ui +urlFragment: switchdemo +--- +# Switch Demo + +This sample app accompanies the article, +[Introduction to Switches](https://docs.microsoft.com/xamarin/android/user-interface/controls/switch), showing how to use the Switch control in Xamarin.Android. + + +![Switch control in an Android app](Screenshots/screenshot.png) +![Switch on in an Android app](Screenshots/Screenshot_switchon) +![Switch off in an Android app](Screenshots/Screenshot_switchoff) diff --git a/SwitchDemo/Screenshots/Screenshot_switchoff.png b/SwitchDemo/Screenshots/Screenshot_switchoff.png new file mode 100644 index 0000000..29f56cf Binary files /dev/null and b/SwitchDemo/Screenshots/Screenshot_switchoff.png differ diff --git a/SwitchDemo/Screenshots/Screenshot_switchon.png b/SwitchDemo/Screenshots/Screenshot_switchon.png new file mode 100644 index 0000000..536557f Binary files /dev/null and b/SwitchDemo/Screenshots/Screenshot_switchon.png differ diff --git a/SwitchDemo/Screenshots/screenshot.png b/SwitchDemo/Screenshots/screenshot.png new file mode 100644 index 0000000..f03392e Binary files /dev/null and b/SwitchDemo/Screenshots/screenshot.png differ diff --git a/SwitchDemo/SwitchDemo.sln b/SwitchDemo/SwitchDemo.sln new file mode 100644 index 0000000..bab444c --- /dev/null +++ b/SwitchDemo/SwitchDemo.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32611.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwitchDemo", "SwitchDemo\SwitchDemo.csproj", "{F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}.Release|Any CPU.Build.0 = Release|Any CPU + {F2BBE1A9-C2FE-4916-A58E-CC0C9DA8BFC6}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A200BC8E-80B1-4AEE-8192-640BA82DA8A4} + EndGlobalSection +EndGlobal diff --git a/SwitchDemo/SwitchDemo/Activity1.cs b/SwitchDemo/SwitchDemo/Activity1.cs new file mode 100644 index 0000000..46ce01a --- /dev/null +++ b/SwitchDemo/SwitchDemo/Activity1.cs @@ -0,0 +1,23 @@ +namespace SwitchDemo +{ + [Activity(Label = "SwitchDemo", MainLauncher = true)] + public class Activity1 : Activity + { + protected override void OnCreate(Bundle? bundle) + { + base.OnCreate(bundle); + + SetContentView(Resource.Layout.Main); + + var s = FindViewById<Switch>(Resource.Id.monitored_switch); + + ArgumentNullException.ThrowIfNull(s); + s.CheckedChange += (sender, e) => { + + var toast = Toast.MakeText(this, "Your answer is " + (e.IsChecked ? "correct" : "incorrect"), + ToastLength.Short); + toast?.Show(); + }; + } + } +} \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/AndroidManifest.xml b/SwitchDemo/SwitchDemo/AndroidManifest.xml new file mode 100644 index 0000000..1811bb4 --- /dev/null +++ b/SwitchDemo/SwitchDemo/AndroidManifest.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/AboutResources.txt b/SwitchDemo/SwitchDemo/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/SwitchDemo/SwitchDemo/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/layout/Main.xml b/SwitchDemo/SwitchDemo/Resources/layout/Main.xml new file mode 100644 index 0000000..e5586ef --- /dev/null +++ b/SwitchDemo/SwitchDemo/Resources/layout/Main.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <Switch + android:id="@+id/monitored_switch" + android:text="Is Mono for Android great?" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:checked="true" + android:textOn="@strings/answeryes" + android:textOff="@strings/answerno" /> + +</LinearLayout> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-anydpi-v26/ic_launcher.xml b/SwitchDemo/SwitchDemo/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/SwitchDemo/SwitchDemo/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/SwitchDemo/SwitchDemo/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/SwitchDemo/SwitchDemo/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher.png b/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher_foreground.png b/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher_round.png b/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher.png b/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher_foreground.png b/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher_round.png b/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher_round.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher_round.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/SwitchDemo/SwitchDemo/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/SwitchDemo/SwitchDemo/Resources/values/ic_launcher_background.xml b/SwitchDemo/SwitchDemo/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/SwitchDemo/SwitchDemo/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/SwitchDemo/SwitchDemo/Resources/values/strings.xml b/SwitchDemo/SwitchDemo/Resources/values/strings.xml new file mode 100644 index 0000000..4841597 --- /dev/null +++ b/SwitchDemo/SwitchDemo/Resources/values/strings.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">SwitchDemo</string> + <string name="answeryes">YES</string> + <string name="answerno">NO</string> +</resources> diff --git a/SwitchDemo/SwitchDemo/SwitchDemo.csproj b/SwitchDemo/SwitchDemo/SwitchDemo.csproj new file mode 100644 index 0000000..daabc48 --- /dev/null +++ b/SwitchDemo/SwitchDemo/SwitchDemo.csproj @@ -0,0 +1,12 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net6.0-android</TargetFramework> + <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.SwitchDemo</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> +</Project> \ No newline at end of file
dotnet/android-samples
a42b3065c75d761bb11ed169466efbc5308bfdd3
Port Button sample (#336)
diff --git a/Button/Button.sln b/Button/Button.sln new file mode 100644 index 0000000..10bd81b --- /dev/null +++ b/Button/Button.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32519.111 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Button", "Button\Button.csproj", "{6718B810-3374-4B91-A10D-BE95A40BABA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6718B810-3374-4B91-A10D-BE95A40BABA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6718B810-3374-4B91-A10D-BE95A40BABA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6718B810-3374-4B91-A10D-BE95A40BABA2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {6718B810-3374-4B91-A10D-BE95A40BABA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6718B810-3374-4B91-A10D-BE95A40BABA2}.Release|Any CPU.Build.0 = Release|Any CPU + {6718B810-3374-4B91-A10D-BE95A40BABA2}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {87F7BF16-6B87-4D3B-9EF4-C69B7A1112D0} + EndGlobalSection +EndGlobal diff --git a/Button/Button/AndroidManifest.xml b/Button/Button/AndroidManifest.xml new file mode 100644 index 0000000..afe3022 --- /dev/null +++ b/Button/Button/AndroidManifest.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> \ No newline at end of file diff --git a/Button/Button/Button.csproj b/Button/Button/Button.csproj new file mode 100644 index 0000000..6a446ee --- /dev/null +++ b/Button/Button/Button.csproj @@ -0,0 +1,12 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net6.0-android</TargetFramework> + <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.Button</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/Button/Button/MainActivity.cs b/Button/Button/MainActivity.cs new file mode 100644 index 0000000..dfa16b2 --- /dev/null +++ b/Button/Button/MainActivity.cs @@ -0,0 +1,22 @@ +namespace Mono.Samples.Button; + +[Activity (Label = "Button Demo", MainLauncher = true)] +public class ButtonActivity : Activity +{ + int count = 0; + + protected override void OnCreate (Bundle? bundle) + { + base.OnCreate (bundle); + + // Create your application here + Android.Widget.Button button = new (this); + + button.Text = $"{count} clicks!!"; + button.Click += delegate { + button.Text = $"{++count} clicks!!"; + }; + + SetContentView (button); + } +} diff --git a/Button/Button/Metadata.xml b/Button/Button/Metadata.xml new file mode 100644 index 0000000..3f63349 --- /dev/null +++ b/Button/Button/Metadata.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" ?> +<SampleMetadata> + <ID>58efbec2-7223-47b1-b889-fa1270f8c97f</ID> + <IsFullApplication>false</IsFullApplication> + <Level>Beginning</Level> + <Tags>User Interface</Tags> + <Gallery>true</Gallery> + <Brief>Shows how to use a simple button widget.</Brief> +</SampleMetadata> diff --git a/Button/Button/README.md b/Button/Button/README.md new file mode 100644 index 0000000..9f26eb0 --- /dev/null +++ b/Button/Button/README.md @@ -0,0 +1,16 @@ +--- +name: Xamarin.Android - Button Widget +description: "Shows how to use a simple button widget (UI)" +page_type: sample +languages: +- csharp +products: +- xamarin +extensions: + tags: + - ui +urlFragment: button +--- +# Button Widget + +Shows how to use a simple button widget - see the [documentation](https://docs.microsoft.com/xamarin/android/user-interface/controls/buttons/). diff --git a/Button/Button/Resources/AboutResources.txt b/Button/Button/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/Button/Button/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/Button/Button/Resources/mipmap-hdpi/ic_launcher.png b/Button/Button/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/Button/Button/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/Button/Button/Resources/mipmap-hdpi/ic_launcher_foreground.png b/Button/Button/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/Button/Button/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/Button/Button/Resources/mipmap-hdpi/ic_launcher_round.png b/Button/Button/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/Button/Button/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/Button/Button/Resources/mipmap-mdpi/ic_launcher.png b/Button/Button/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/Button/Button/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/Button/Button/Resources/mipmap-mdpi/ic_launcher_foreground.png b/Button/Button/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/Button/Button/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/Button/Button/Resources/mipmap-mdpi/ic_launcher_round.png b/Button/Button/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/Button/Button/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/Button/Button/Resources/mipmap-xhdpi/ic_launcher.png b/Button/Button/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/Button/Button/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/Button/Button/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/Button/Button/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/Button/Button/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/Button/Button/Resources/mipmap-xhdpi/ic_launcher_round.png b/Button/Button/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/Button/Button/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/Button/Button/Resources/mipmap-xxhdpi/ic_launcher.png b/Button/Button/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/Button/Button/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/Button/Button/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/Button/Button/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/Button/Button/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/Button/Button/Resources/mipmap-xxhdpi/ic_launcher_round.png b/Button/Button/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/Button/Button/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher.png b/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/Button/Button/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/Button/Button/Screenshots/Button.png b/Button/Button/Screenshots/Button.png new file mode 100644 index 0000000..fdbe54f Binary files /dev/null and b/Button/Button/Screenshots/Button.png differ
dotnet/android-samples
c5e505e2cc1d723f9c77df9445679ac022a3dbd4
Port TextSwitcher sample
diff --git a/TextSwitcher/TextSwitcher.sln b/TextSwitcher/TextSwitcher.sln new file mode 100644 index 0000000..1f3c560 --- /dev/null +++ b/TextSwitcher/TextSwitcher.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32611.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextSwitcher", "TextSwitcher\TextSwitcher.csproj", "{ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC6B3D3-DA78-42C3-A596-554E5BB5CA89}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C25255BD-731B-46A9-9714-B0B7E261D192} + EndGlobalSection +EndGlobal diff --git a/TextSwitcher/TextSwitcher/AndroidManifest.xml b/TextSwitcher/TextSwitcher/AndroidManifest.xml new file mode 100644 index 0000000..1811bb4 --- /dev/null +++ b/TextSwitcher/TextSwitcher/AndroidManifest.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> \ No newline at end of file diff --git a/TextSwitcher/TextSwitcher/MainActivity.cs b/TextSwitcher/TextSwitcher/MainActivity.cs new file mode 100644 index 0000000..8cc656e --- /dev/null +++ b/TextSwitcher/TextSwitcher/MainActivity.cs @@ -0,0 +1,65 @@ +using Android.Views; +using Android.Views.Animations; + +namespace TextSwitcher +{ + [Activity(Label = "TextSwitcher", MainLauncher = true)] + public class MainActivity : Activity, ViewSwitcher.IViewFactory + { + int mCounter = 0; + + protected override void OnCreate(Bundle? savedInstanceState) + { + base.OnCreate(savedInstanceState); + SetContentView(Resource.Layout.Main); + + // Get the TextSwitcher view from the layout + var mSwitcher = FindViewById<Android.Widget.TextSwitcher>(Resource.Id.switcher); + ArgumentNullException.ThrowIfNull(mSwitcher); + + // BEGIN_INCLUDE(setup) + // Set the factory used to create TextViews to switch between. + mSwitcher.SetFactory(this); + + /* + * Set the in and out animations. Using the fade_in/out animations + * provided by the framework. + */ + var animIn = AnimationUtils.LoadAnimation(this, Android.Resource.Animation.FadeIn); + var animOut = AnimationUtils.LoadAnimation(this, Android.Resource.Animation.FadeOut); + mSwitcher.InAnimation = animIn; + mSwitcher.OutAnimation = animOut; + // END_INCLUDE(setup) + + /* + * Setup the 'next' button. The counter is incremented when clicked and + * the new value is displayed in the TextSwitcher. The change of text is + * automatically animated using the in/out animations set above. + */ + var nextButton = FindViewById<Button>(Resource.Id.button); + ArgumentNullException.ThrowIfNull(nextButton); + + nextButton.Click += (sender, e) => + { + mCounter++; + // BEGIN_INCLUDE(settext) + mSwitcher.SetText(Java.Lang.String.ValueOf(mCounter)); + // END_INCLUDE(settext) + }; + + // Set the initial text without an animation + mSwitcher.SetCurrentText(Java.Lang.String.ValueOf(mCounter)); + } + + public View MakeView() + { + // Create a new TextView + var t = new TextView(this); + t.Gravity = GravityFlags.Top | GravityFlags.CenterHorizontal; + t.SetTextAppearance(Android.Resource.Style.TextAppearanceLarge); + + return t; + } + } +} + diff --git a/TextSwitcher/TextSwitcher/Resources/AboutResources.txt b/TextSwitcher/TextSwitcher/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/TextSwitcher/TextSwitcher/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/TextSwitcher/TextSwitcher/Resources/layout/Main.xml b/TextSwitcher/TextSwitcher/Resources/layout/Main.xml new file mode 100644 index 0000000..e2d3339 --- /dev/null +++ b/TextSwitcher/TextSwitcher/Resources/layout/Main.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/LinearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="top|center_horizontal" + android:gravity="center_horizontal" + android:orientation="vertical" + android:paddingBottom="16dp" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingTop="16dp"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/intro" /> + <Button + android:id="@+id/button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/next" /> + <TextSwitcher + android:id="@+id/switcher" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> +</LinearLayout> \ No newline at end of file diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-anydpi-v26/ic_launcher.xml b/TextSwitcher/TextSwitcher/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/TextSwitcher/TextSwitcher/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/TextSwitcher/TextSwitcher/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/TextSwitcher/TextSwitcher/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher.png b/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher_foreground.png b/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher_round.png b/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher.png b/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher_foreground.png b/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher_round.png b/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher_round.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher_round.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/TextSwitcher/TextSwitcher/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/TextSwitcher/TextSwitcher/Resources/values/ic_launcher_background.xml b/TextSwitcher/TextSwitcher/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/TextSwitcher/TextSwitcher/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/TextSwitcher/TextSwitcher/Resources/values/strings.xml b/TextSwitcher/TextSwitcher/Resources/values/strings.xml new file mode 100644 index 0000000..eb51493 --- /dev/null +++ b/TextSwitcher/TextSwitcher/Resources/values/strings.xml @@ -0,0 +1,10 @@ +<resources> + <string name="app_name">TextSwitcher</string> + <string name="app_text">Hello, Android!</string> + <string name="intro"> + This sample illustrates the use of a <b>TextSwitcher</b> to display text. + \n\n<b>Click the button</b> below to set new text in the TextSwitcher and observe the in and out + fade animations. + </string> + <string name="next">Next</string> +</resources> diff --git a/TextSwitcher/TextSwitcher/TextSwitcher.csproj b/TextSwitcher/TextSwitcher/TextSwitcher.csproj new file mode 100644 index 0000000..c2ed5e0 --- /dev/null +++ b/TextSwitcher/TextSwitcher/TextSwitcher.csproj @@ -0,0 +1,12 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net6.0-android</TargetFramework> + <SupportedOSPlatformVersion>23</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.TextSwitcher</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> +</Project> \ No newline at end of file
dotnet/android-samples
32a22046ab6ad79854af20ea4597197b0c6a07ef
Port ActivityLifecycle sample (#332)
diff --git a/ActivityLifecycle/ActivityLifecycle.csproj b/ActivityLifecycle/ActivityLifecycle.csproj new file mode 100644 index 0000000..5f07752 --- /dev/null +++ b/ActivityLifecycle/ActivityLifecycle.csproj @@ -0,0 +1,12 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net6.0-android</TargetFramework> + <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> + <OutputType>Exe</OutputType> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + <ApplicationId>com.companyname.ActivityLifecycle</ApplicationId> + <ApplicationVersion>1</ApplicationVersion> + <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/ActivityLifecycle/ActivityLifecycle.sln b/ActivityLifecycle/ActivityLifecycle.sln new file mode 100644 index 0000000..6cb6add --- /dev/null +++ b/ActivityLifecycle/ActivityLifecycle.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32512.399 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ActivityLifecycle", "ActivityLifecycle.csproj", "{D0B18553-F12F-4F73-9375-9840A27073A0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D0B18553-F12F-4F73-9375-9840A27073A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0B18553-F12F-4F73-9375-9840A27073A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0B18553-F12F-4F73-9375-9840A27073A0}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {D0B18553-F12F-4F73-9375-9840A27073A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0B18553-F12F-4F73-9375-9840A27073A0}.Release|Any CPU.Build.0 = Release|Any CPU + {D0B18553-F12F-4F73-9375-9840A27073A0}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0DA60B70-B72A-4DAD-900B-5DC8B42D9508} + EndGlobalSection +EndGlobal diff --git a/ActivityLifecycle/AndroidManifest.xml b/ActivityLifecycle/AndroidManifest.xml new file mode 100644 index 0000000..1811bb4 --- /dev/null +++ b/ActivityLifecycle/AndroidManifest.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> + </application> + <uses-permission android:name="android.permission.INTERNET" /> +</manifest> \ No newline at end of file diff --git a/ActivityLifecycle/MainActivity.cs b/ActivityLifecycle/MainActivity.cs new file mode 100644 index 0000000..6307c7a --- /dev/null +++ b/ActivityLifecycle/MainActivity.cs @@ -0,0 +1,92 @@ +namespace ActivityLifecycle; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Util; +using Android.Widget; + +[Activity(Label = "Activity A", MainLauncher = true)] +public class MainActivity : Activity +{ + int _counter = 0; + + protected override void OnCreate(Bundle? bundle) + { + Log.Debug(GetType().FullName, "Activity A - OnCreate"); + base.OnCreate(bundle); + SetContentView(Resource.Layout.activity_main); + + var button = FindViewById<Button>(Resource.Id.myButton); + if (button != null) + { + button.Click += (sender, args) => + { + var intent = new Intent(this, typeof(SecondActivity)); + StartActivity(intent); + }; + } + + if (bundle != null) + { + _counter = bundle.GetInt("click_count", 0); + Log.Debug(GetType().FullName, "Activity A - Recovered instance state"); + } + + var clickbutton = FindViewById<Button>(Resource.Id.clickButton); + if (clickbutton != null) + { + clickbutton.Text = Resources?.GetString(Resource.String.counterbutton_text, _counter); + clickbutton.Click += (sender, args) => + { + _counter++; + clickbutton.Text = Resources?.GetString(Resource.String.counterbutton_text, _counter); + }; + } + } + + protected override void OnSaveInstanceState(Bundle outState) + { + outState.PutInt("click_count", _counter); + Log.Debug(GetType().FullName, "Activity A - Saving instance state"); + + // always call the base implementation! + base.OnSaveInstanceState(outState); + } + + protected override void OnDestroy() + { + Log.Debug(GetType().FullName, "Activity A - On Destroy"); + base.OnDestroy(); + } + + protected override void OnPause() + { + Log.Debug(GetType().FullName, "Activity A - OnPause"); + base.OnPause(); + } + + protected override void OnRestart() + { + Log.Debug(GetType().FullName, "Activity A - OnRestart"); + base.OnRestart(); + } + + protected override void OnResume() + { + Log.Debug(GetType().FullName, "Activity A - OnResume"); + base.OnResume(); + } + + protected override void OnStart() + { + Log.Debug(GetType().FullName, "Activity A - OnStart"); + base.OnStart(); + } + + protected override void OnStop() + { + Log.Debug(GetType().FullName, "Activity A - OnStop"); + base.OnStop(); + } +} \ No newline at end of file diff --git a/ActivityLifecycle/Resources/AboutResources.txt b/ActivityLifecycle/Resources/AboutResources.txt new file mode 100644 index 0000000..219f425 --- /dev/null +++ b/ActivityLifecycle/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/ActivityLifecycle/Resources/layout/activity_main.xml b/ActivityLifecycle/Resources/layout/activity_main.xml new file mode 100644 index 0000000..53c8e1a --- /dev/null +++ b/ActivityLifecycle/Resources/layout/activity_main.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <Button + android:id="@+id/myButton" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/mybutton_text" /> + <Button + android:id="@+id/clickButton" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/counterbutton_text" /> +</LinearLayout> \ No newline at end of file diff --git a/ActivityLifecycle/Resources/mipmap-anydpi-v26/ic_launcher.xml b/ActivityLifecycle/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/ActivityLifecycle/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/ActivityLifecycle/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/ActivityLifecycle/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/ActivityLifecycle/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher.png b/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..2531cb3 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher_foreground.png b/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7a859c2 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher_round.png b/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b8d35b3 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher.png b/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..795ea7c Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher_foreground.png b/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a12b157 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher_round.png b/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..8f56909 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher.png b/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..761cc91 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e7d70a5 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher_round.png b/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9737d79 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher.png b/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9133e31 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..73ccaa6 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher_round.png b/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c3ae5f5 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher.png b/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fd714 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f6584af Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ef89bd5 Binary files /dev/null and b/ActivityLifecycle/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/ActivityLifecycle/Resources/values/ic_launcher_background.xml b/ActivityLifecycle/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000..6ec24e6 --- /dev/null +++ b/ActivityLifecycle/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="ic_launcher_background">#2C3E50</color> +</resources> \ No newline at end of file diff --git a/ActivityLifecycle/Resources/values/strings.xml b/ActivityLifecycle/Resources/values/strings.xml new file mode 100644 index 0000000..407de5a --- /dev/null +++ b/ActivityLifecycle/Resources/values/strings.xml @@ -0,0 +1,5 @@ +<resources> + <string name="mybutton_text">Start Activity B</string> + <string name="counterbutton_text">I\'ve been touched %1$d times.</string> + <string name="app_name">ActivityLifecycle</string> +</resources> diff --git a/ActivityLifecycle/SecondActivity.cs b/ActivityLifecycle/SecondActivity.cs new file mode 100644 index 0000000..ae0af6a --- /dev/null +++ b/ActivityLifecycle/SecondActivity.cs @@ -0,0 +1,51 @@ +namespace ActivityLifecycle; + +using Android.App; +using Android.OS; +using Android.Util; + +[Activity(Label = "Activity B")] +public class SecondActivity : Activity +{ + protected override void OnCreate(Bundle? bundle) + { + Log.Debug(GetType().FullName, "Activity B - OnCreate"); + base.OnCreate(bundle); + } + + protected override void OnRestart() + { + Log.Debug(GetType().FullName, "Activity B - OnRestart"); + base.OnRestart(); + } + + protected override void OnStart() + { + Log.Debug(GetType().FullName, "Activity B - OnStart"); + base.OnStart(); + } + + protected override void OnResume() + { + Log.Debug(GetType().FullName, "Activity B - OnResume"); + base.OnResume(); + } + + protected override void OnPause() + { + Log.Debug(GetType().FullName, "Activity B - OnPause"); + base.OnPause(); + } + + protected override void OnStop() + { + Log.Debug(GetType().FullName, "Activity B - OnStop"); + base.OnStop(); + } + + protected override void OnDestroy() + { + Log.Debug(GetType().FullName, "Activity B - OnDestroy"); + base.OnDestroy(); + } +} \ No newline at end of file
dotnet/android-samples
f945d48fdd183c647ccf6e0b6e9316771f558c9d
Upgrade target .NET Framework to 4.8.
diff --git a/android5.0/Cheesesquare/Cheesesquare.UITests/Cheesesquare.UITests.csproj b/android5.0/Cheesesquare/Cheesesquare.UITests/Cheesesquare.UITests.csproj index bae2e60..35ac6ce 100644 --- a/android5.0/Cheesesquare/Cheesesquare.UITests/Cheesesquare.UITests.csproj +++ b/android5.0/Cheesesquare/Cheesesquare.UITests/Cheesesquare.UITests.csproj @@ -1,54 +1,55 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{9690A5F4-6D51-47C4-BB78-ACDF05B859C5}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>Cheesesquare.UITests</RootNamespace> <AssemblyName>Cheesesquare.UITests</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> + <TargetFrameworkProfile /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="Xamarin.UITest"> <HintPath>..\packages\Xamarin.UITest.1.3.14\lib\Xamarin.UITest.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Cheesesquare.csproj"> <Project>{580F5B91-D14A-449B-BFDE-C21A0F9A7D2F}</Project> <Name>Cheesesquare</Name> <ReferenceOutputAssembly>False</ReferenceOutputAssembly> <Private>False</Private> </ProjectReference> </ItemGroup> <ItemGroup> <Compile Include="Tests.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> <None Include="packages.config" /> </ItemGroup> </Project> \ No newline at end of file
dotnet/android-samples
1f3796a90280b530e4be6f4e3f32fcf7d621557f
[Notepad] Bump TargetFrameworkVersion to v10.0
diff --git a/NotePad-Mono.Data.Sqlite/Notepad.csproj b/NotePad-Mono.Data.Sqlite/Notepad.csproj index dd3db37..e0b9fdc 100644 --- a/NotePad-Mono.Data.Sqlite/Notepad.csproj +++ b/NotePad-Mono.Data.Sqlite/Notepad.csproj @@ -1,98 +1,98 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{CB6BAF1A-9CA2-4112-B5A1-6E2B88416781}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.Notepad</RootNamespace> <AssemblyName>Notepad</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> - <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> + <TargetFrameworkVersion>v10.0</TargetFrameworkVersion> <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>SdkOnly</AndroidLinkMode> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="Mono.Data.Sqlite" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Data" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="LinedEditText.cs" /> <Compile Include="Note.cs" /> <Compile Include="NoteAdapter.cs" /> <Compile Include="NoteEditorActivity.cs" /> <Compile Include="NoteRepository.cs" /> <Compile Include="NotesListActivity.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Layout\NoteEditor.axml" /> <AndroidResource Include="Resources\Layout\NoteListRow.axml" /> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Values\strings.xml" /> </ItemGroup> <ItemGroup> <None Include="Readme.md" /> </ItemGroup> <ItemGroup> <Content Include="Metadata.xml" /> <Content Include="Screenshots\notepad1.png" /> <Content Include="Screenshots\notepad2.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> </Project> \ No newline at end of file
dotnet/android-samples
a4d2b339b4dac6a2769bed3daad487ab9d3406e9
Fix obsolete API usage (#315)
diff --git a/HoneycombGallery/CameraFragment.cs b/HoneycombGallery/CameraFragment.cs index ff83804..7c6d91c 100644 --- a/HoneycombGallery/CameraFragment.cs +++ b/HoneycombGallery/CameraFragment.cs @@ -1,321 +1,320 @@ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; -using Android.Graphics; using Java.IO; using Android.App; using Android.Content; using Android.OS; using Android.Util; using Android.Views; -using Camera = Android.Hardware.Camera; +using Android.Hardware; namespace com.example.monodroid.hcgallery { public class CameraFragment : Fragment { private Preview mPreview; Camera mCamera; int mNumberOfCameras; int mCameraCurrentlyLocked; // The first rear facing camera int mDefaultCameraId; public override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Create a RelativeLayout container that will hold a SurfaceView, // and set it as the content of our activity. mPreview = new Preview (this.Activity); // Find the total number of cameras available mNumberOfCameras = Camera.NumberOfCameras; // Find the ID of the default camera Camera.CameraInfo cameraInfo = new Camera.CameraInfo (); for (int i = 0; i < mNumberOfCameras; i++) { Camera.GetCameraInfo (i, cameraInfo); - if (cameraInfo.Facing == Camera.CameraInfo.CameraFacingBack) { + if (cameraInfo.Facing == CameraFacing.Back) { mDefaultCameraId = i; } } SetHasOptionsMenu (mNumberOfCameras > 1); } public override void OnActivityCreated (Bundle savedInstanceState) { base.OnActivityCreated (savedInstanceState); // Add an up arrow to the "home" button, indicating that the button will go "up" // one activity in the app's Activity heirarchy. // Calls to getActionBar() aren't guaranteed to return the ActionBar when called // from within the Fragment's onCreate method, because the Window's decor hasn't been // initialized yet. Either call for the ActionBar reference in Activity.onCreate() // (after the setContentView(...) call), or in the Fragment's onActivityCreated method. Activity activity = this.Activity; ActionBar actionBar = activity.ActionBar; actionBar.SetDisplayHomeAsUpEnabled (true); } public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return mPreview; } public override void OnResume() { base.OnResume (); // Open the default i.e. the first rear facing camera. mCamera = Camera.Open (mDefaultCameraId); mCameraCurrentlyLocked = mDefaultCameraId; mPreview.SetCamera (mCamera); } public override void OnPause () { base.OnPause (); // Because the Camera object is a shared resource, it's very // important to release it when the activity is paused. if (mCamera != null) { mPreview.SetCamera (null); mCamera.Release (); mCamera = null; } } public override void OnCreateOptionsMenu (IMenu menu, MenuInflater inflater) { if (mNumberOfCameras > 1) { // Inflate our menu which can gather user input for switching camera inflater.Inflate (Resource.Menu.camera_menu, menu); } else { base.OnCreateOptionsMenu (menu, inflater); } } public override bool OnOptionsItemSelected (IMenuItem item) { // Handle item selection switch (item.ItemId) { case Resource.Id.switch_cam: // Release this camera -> mCameraCurrentlyLocked if (mCamera != null) { mCamera.StopPreview (); mPreview.SetCamera (null); mCamera.Release (); mCamera = null; } // Acquire the next camera and request Preview to reconfigure // parameters. mCamera = Camera.Open ((mCameraCurrentlyLocked + 1) % mNumberOfCameras); mCameraCurrentlyLocked = (mCameraCurrentlyLocked + 1) % mNumberOfCameras; mPreview.SwitchCamera (mCamera); // Start the preview mCamera.StartPreview(); return true; case Android.Resource.Id.Home: Intent intent = new Intent (this.Activity, typeof (MainActivity)); intent.AddFlags (ActivityFlags.ClearTop | ActivityFlags.SingleTop); StartActivity (intent); goto default; default: return base.OnOptionsItemSelected (item); } } } // ---------------------------------------------------------------------- /** * A simple wrapper around a Camera and a SurfaceView that renders a centered * preview of the Camera to the surface. We need to center the SurfaceView * because not all devices have cameras that support preview sizes at the same * aspect ratio as the device's display. */ class Preview : ViewGroup, ISurfaceHolderCallback { private const string TAG = "Preview"; SurfaceView mSurfaceView; ISurfaceHolder mHolder; Camera.Size mPreviewSize; IList<Camera.Size> mSupportedPreviewSizes; Camera mCamera; internal Preview (Context context) : base (context) { mSurfaceView = new SurfaceView (context); AddView (mSurfaceView); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = mSurfaceView.Holder; mHolder.AddCallback (this); mHolder.SetType (SurfaceType.PushBuffers); } public void SetCamera (Camera camera) { mCamera = camera; if (mCamera != null) { mSupportedPreviewSizes = mCamera.GetParameters () .SupportedPreviewSizes; RequestLayout (); } } public void SwitchCamera (Camera camera) { SetCamera (camera); try { camera.SetPreviewDisplay (mHolder); } catch (IOException exception) { Log.Error (TAG, "IOException caused by setPreviewDisplay()", exception); } Camera.Parameters parameters = camera.GetParameters (); parameters.SetPreviewSize (mPreviewSize.Width, mPreviewSize.Height); RequestLayout(); camera.SetParameters (parameters); } protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec) { // We purposely disregard child measurements because act as a // wrapper to a SurfaceView that centers the camera preview instead // of stretching it. int width = ResolveSize (SuggestedMinimumWidth, widthMeasureSpec); int height = ResolveSize (SuggestedMinimumHeight, heightMeasureSpec); SetMeasuredDimension (width, height); if (mSupportedPreviewSizes != null) { mPreviewSize = GetOptimalPreviewSize (mSupportedPreviewSizes, width, height); } } protected override void OnLayout (bool changed, int l, int t, int r, int b) { if (changed && ChildCount > 0) { View child = GetChildAt (0); int width = r - l; int height = b - t; int previewWidth = width; int previewHeight = height; if (mPreviewSize != null) { previewWidth = mPreviewSize.Width; previewHeight = mPreviewSize.Height; } // Center the child SurfaceView within the parent. if (width * previewHeight > height * previewWidth) { int scaledChildWidth = previewWidth * height / previewHeight; child.Layout ((width - scaledChildWidth) / 2, 0, (width + scaledChildWidth) / 2, height); } else { int scaledChildHeight = previewHeight * width / previewWidth; child.Layout (0, (height - scaledChildHeight) / 2, width, (height + scaledChildHeight) / 2); } } } public void SurfaceCreated(ISurfaceHolder holder) { // The Surface has been created, acquire the camera and tell it where // to draw. try { if (mCamera != null) { mCamera.SetPreviewDisplay(holder); } } catch (IOException exception) { Log.Error(TAG, "IOException caused by setPreviewDisplay()", exception); } } public void SurfaceDestroyed (ISurfaceHolder holder) { // Surface will be destroyed when we return, so stop the preview. if (mCamera != null) { mCamera.StopPreview (); } } private Camera.Size GetOptimalPreviewSize (IList<Camera.Size> sizes, int w, int h) { double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; if (sizes == null) return null; Camera.Size optimalSize = null; double minDiff = double.MaxValue; int targetHeight = h; // Try to find an size match aspect ratio and size foreach (Camera.Size size in sizes) { double ratio = (double) size.Width / size.Height; if (Math.Abs (ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.Abs (size.Height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.Abs (size.Height - targetHeight); } } // Cannot find the one match the aspect ratio, ignore the requirement if (optimalSize == null) { minDiff = double.MaxValue; foreach (Camera.Size size in sizes) { if (Math.Abs (size.Height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.Abs (size.Height - targetHeight); } } } return optimalSize; } public void SurfaceChanged (ISurfaceHolder holder, Android.Graphics.Format format, int w, int h) { // Now that the size is known, set up the camera parameters and begin // the preview. Camera.Parameters parameters = mCamera.GetParameters (); parameters.SetPreviewSize (mPreviewSize.Width, mPreviewSize.Height); RequestLayout(); mCamera.SetParameters (parameters); mCamera.StartPreview (); } } } diff --git a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/Activity1.cs b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/Activity1.cs index 5849031..78e370d 100644 --- a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/Activity1.cs +++ b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/Activity1.cs @@ -1,49 +1,49 @@ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; namespace SystemUIVisibilityDemo { [Activity (Label = "SystemUIVisibilityDemo", MainLauncher = true)] public class Activity1 : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); var tv = FindViewById<TextView> (Resource.Id.systemUiFlagTextView); var lowProfileButton = FindViewById<Button> (Resource.Id.lowProfileButton); var hideNavButton = FindViewById<Button> (Resource.Id.hideNavigation); var visibleButton = FindViewById<Button> (Resource.Id.visibleButton); lowProfileButton.Click += delegate { - tv.SystemUiVisibility = (StatusBarVisibility)View.SystemUiFlagLowProfile; + tv.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.LowProfile; }; hideNavButton.Click += delegate { - tv.SystemUiVisibility = (StatusBarVisibility)View.SystemUiFlagHideNavigation; + tv.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.HideNavigation; }; visibleButton.Click += delegate { - tv.SystemUiVisibility = (StatusBarVisibility)View.SystemUiFlagVisible; + tv.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.Visible; }; tv.SystemUiVisibilityChange += delegate(object sender, View.SystemUiVisibilityChangeEventArgs e) { tv.Text = String.Format ("Visibility = {0}", e.Visibility); }; } } } diff --git a/UrbanAirship/samples/PushSample/CustomPreferencesActivity.cs b/UrbanAirship/samples/PushSample/CustomPreferencesActivity.cs index b4bdb79..e42240b 100644 --- a/UrbanAirship/samples/PushSample/CustomPreferencesActivity.cs +++ b/UrbanAirship/samples/PushSample/CustomPreferencesActivity.cs @@ -1,243 +1,243 @@ /* Copyright 2009-2011 Urban Airship Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Xamarin.UrbanAirship; using Xamarin.UrbanAirship.AnalyticsAPI; using Xamarin.UrbanAirship.Locations; using Xamarin.UrbanAirship.Push; using Android.Content.Res; using Android.Text.Format; using Java.Util; namespace PushSample { [Activity (Label = "CustomPreferencesActivity")] // This class represents the UI and implementation of the activity enabling users // to set Quiet Time preferences. public class CustomPreferencesActivity : InstrumentedActivity { CheckBox pushEnabled; CheckBox soundEnabled; CheckBox vibrateEnabled; CheckBox quietTimeEnabled; CheckBox locationEnabled; CheckBox backgroundLocationEnabled; CheckBox foregroundLocationEnabled; TextView locationEnabledLabel; TextView backgroundLocationEnabledLabel; TextView foregroundLocationEnabledLabel; TimePicker startTime; TimePicker endTime; PushPreferences pushPrefs = PushManager.Shared().Preferences; LocationPreferences locPrefs = UALocationManager.Shared().Preferences; private void PushSettingsActive(bool active) { soundEnabled.Enabled = active; vibrateEnabled.Enabled = active; } private void QuietTimeSettingsActive(bool active) { startTime.Enabled = active; endTime.Enabled = active; } private void BackgroundLocationActive(bool active) { backgroundLocationEnabled.Enabled = active; } private void ForegroundLocationActive (bool active) { foregroundLocationEnabled.Enabled = active; } protected override void OnCreate(Bundle icicle) { base.OnCreate(icicle); Window w = Window; w.RequestFeature (WindowFeatures.LeftIcon); SetContentView(Resource.Layout.push_preferences_dialog); pushEnabled = (CheckBox) FindViewById(Resource.Id.push_enabled); soundEnabled = (CheckBox) FindViewById(Resource.Id.sound_enabled); vibrateEnabled = (CheckBox) FindViewById(Resource.Id.vibrate_enabled); quietTimeEnabled = (CheckBox) FindViewById(Resource.Id.quiet_time_enabled); locationEnabled = (CheckBox) FindViewById(Resource.Id.location_enabled); backgroundLocationEnabled = (CheckBox) FindViewById(Resource.Id.background_location_enabled); foregroundLocationEnabled = (CheckBox) FindViewById(Resource.Id.foreground_location_enabled); locationEnabledLabel = (TextView) FindViewById(Resource.Id.location_enabled_label); backgroundLocationEnabledLabel = (TextView) FindViewById(Resource.Id.background_location_enabled_label); foregroundLocationEnabledLabel = (TextView) FindViewById(Resource.Id.foreground_location_enabled_label); startTime = (TimePicker) FindViewById(Resource.Id.start_time); endTime = (TimePicker) FindViewById(Resource.Id.end_time); startTime.SetIs24HourView (new Java.Lang.Boolean (DateFormat.Is24HourFormat(this))); endTime.SetIs24HourView (new Java.Lang.Boolean (DateFormat.Is24HourFormat(this))); pushEnabled.Click += (v, e) => { PushSettingsActive(((CheckBox) v).Checked); }; quietTimeEnabled.Click += (v, e) => { QuietTimeSettingsActive(((CheckBox)v).Checked); }; locationEnabled.Click += (v, e) => { BackgroundLocationActive(((CheckBox)v).Checked); ForegroundLocationActive(((CheckBox)v).Checked); }; } // When the activity starts, we need to fetch and display the user's current // Push preferences in the view, if applicable. public override void OnStart() { base.OnStart(); bool isPushEnabled = pushPrefs.IsPushEnabled; pushEnabled.Checked = isPushEnabled; soundEnabled.Checked = pushPrefs.SoundEnabled; vibrateEnabled.Checked = pushPrefs.VibrateEnabled; PushSettingsActive(isPushEnabled); bool isQuietTimeEnabled = pushPrefs.QuietTimeEnabled; quietTimeEnabled.Checked = isQuietTimeEnabled; QuietTimeSettingsActive(isQuietTimeEnabled); if (!UAirship.Shared().AirshipConfigOptions.LocationOptions.LocationServiceEnabled) { locationEnabled.Visibility = ViewStates.Gone; backgroundLocationEnabled.Visibility = ViewStates.Gone; foregroundLocationEnabled.Visibility = ViewStates.Gone; locationEnabledLabel.Visibility = ViewStates.Gone; backgroundLocationEnabledLabel.Visibility = ViewStates.Gone; foregroundLocationEnabledLabel.Visibility = ViewStates.Gone; } else { locationEnabled.Checked = locPrefs.IsLocationEnabled; backgroundLocationEnabled.Checked = locPrefs.IsBackgroundLocationEnabled; foregroundLocationEnabled.Checked = locPrefs.IsForegroundLocationEnabled; } //this will be null if a quiet time interval hasn't been set Date[] interval = pushPrefs.GetQuietTimeInterval (); if(interval != null) { startTime.CurrentHour = new Java.Lang.Integer (interval[0].Hours); startTime.CurrentMinute = new Java.Lang.Integer (interval[0].Minutes); endTime.CurrentHour = new Java.Lang.Integer (interval[1].Hours); endTime.CurrentMinute = new Java.Lang.Integer (interval[1].Minutes); } } // When the activity is closed, save the user's Push preferences public override void OnStop() { base.OnStop(); bool IsPushEnabledInActivity = pushEnabled.Checked; bool IsQuietTimeEnabledInActivity = quietTimeEnabled.Checked; if(IsPushEnabledInActivity) { PushManager.EnablePush(); } else { PushManager.DisablePush(); } pushPrefs.SoundEnabled = soundEnabled.Checked; pushPrefs.VibrateEnabled = vibrateEnabled.Checked; pushPrefs.QuietTimeEnabled = IsQuietTimeEnabledInActivity; if(IsQuietTimeEnabledInActivity) { // Grab the start date. Calendar cal = Calendar.Instance; - cal.Set(Calendar.HourOfDay, (int) startTime.CurrentHour); - cal.Set(Calendar.Minute, (int) startTime.CurrentMinute); + cal.Set(CalendarField.HourOfDay, (int) startTime.CurrentHour); + cal.Set(CalendarField.Minute, (int) startTime.CurrentMinute); Date startDate = cal.Time; // Prepare the end date. cal = Calendar.Instance; - cal.Set(Calendar.HourOfDay, (int) endTime.CurrentHour); - cal.Set(Calendar.Minute, (int) endTime.CurrentMinute); + cal.Set(CalendarField.HourOfDay, (int) endTime.CurrentHour); + cal.Set(CalendarField.Minute, (int) endTime.CurrentMinute); Date endDate = cal.Time; pushPrefs.SetQuietTimeInterval (startDate, endDate); } this.HandleLocation(); } private void HandleLocation() { if (!UAirship.Shared().AirshipConfigOptions.LocationOptions.LocationServiceEnabled) { return; } bool isLocationEnabledInActivity = locationEnabled.Checked; bool isBackgroundLocationEnabledInActivity = backgroundLocationEnabled.Checked; bool isForegroundLocationEnabledInActivity = foregroundLocationEnabled.Checked; // Set the location enable preference first because it will be used // in the logic to enable/disable background and foreground locations. if (isLocationEnabledInActivity) { UALocationManager.EnableLocation(); } else { UALocationManager.DisableLocation(); } HandleBackgroundLocationPreference(isBackgroundLocationEnabledInActivity); HandleForegroundLocationPreference(isForegroundLocationEnabledInActivity); } private void HandleBackgroundLocationPreference(bool backgroundLocationEnabled) { if (backgroundLocationEnabled) { UALocationManager.EnableBackgroundLocation(); } else { UALocationManager.DisableBackgroundLocation(); } } private void HandleForegroundLocationPreference(bool foregroundLocationEnabled) { if (foregroundLocationEnabled) { UALocationManager.EnableForegroundLocation(); } else { UALocationManager.DisableForegroundLocation(); } } protected void OnConfigurationChanged(Configuration newConfig) { base.OnConfigurationChanged(newConfig); // DO NOT REMOVE, just having it here seems to fix a weird issue with // Time picker where the fields would go blank on rotation. } } } diff --git a/android-o/AndroidCipher/AndroidCipher/AndroidCipher.cs b/android-o/AndroidCipher/AndroidCipher/AndroidCipher.cs index 99dd7ad..497d7ac 100644 --- a/android-o/AndroidCipher/AndroidCipher/AndroidCipher.cs +++ b/android-o/AndroidCipher/AndroidCipher/AndroidCipher.cs @@ -1,83 +1,80 @@ using System; using Android.Widget; using Java.Security; using Javax.Crypto; using Javax.Crypto.Spec; using System.Text; using Android.Util; using Java.Security.Spec; -using static System.Text.Encoding; -using static Android.Util.Base64; -using static Javax.Crypto.Cipher; namespace AndroidCipher { public class AndroidCipher { private readonly MainActivity _activity; private Cipher _encipher; private SecureRandom _random; private ISecretKey _secretKey; public AndroidCipher(MainActivity activity) { this._activity = activity; } public void Decryption(object sender, EventArgs eventArgs) { - var decipher = GetInstance(Constants.Transformation); + var decipher = Cipher.GetInstance(Constants.Transformation); var algorithmParameterSpec = (IAlgorithmParameterSpec)_encipher.Parameters.GetParameterSpec(Java.Lang.Class.FromType(typeof(GCMParameterSpec))); - decipher.Init(DecryptMode, _secretKey, algorithmParameterSpec); + decipher.Init(CipherMode.DecryptMode, _secretKey, algorithmParameterSpec); - byte[] decodedValue = Decode(UTF8.GetBytes(_activity.textOutput.Text), Base64.Default); + byte[] decodedValue = Base64.Decode(Encoding.UTF8.GetBytes(_activity.textOutput.Text), Base64Flags.Default); byte[] decryptedVal = decipher.DoFinal(decodedValue); _activity.textOriginal.Text = Encoding.Default.GetString(decryptedVal); } public static T Cast<T>(Java.Lang.Object obj) where T : class { var propertyInfo = obj.GetType().GetProperty("Instance"); return propertyInfo == null ? null : propertyInfo.GetValue(obj, null) as T; } public void Encryption(object sender, EventArgs eventArgs) { _secretKey = GenerateKey(); if (ValidateInput(_activity.textInput.Text)) return; - _encipher = GetInstance(Constants.Transformation); - _encipher.Init(EncryptMode, _secretKey, GenerateGcmParameterSpec()); + _encipher = Cipher.GetInstance(Constants.Transformation); + _encipher.Init(CipherMode.EncryptMode, _secretKey, GenerateGcmParameterSpec()); byte[] - results = _encipher.DoFinal(UTF8.GetBytes(_activity.textInput.Text)); - _activity.textOutput.Text = EncodeToString(results, Base64.Default); + results = _encipher.DoFinal(Encoding.UTF8.GetBytes(_activity.textInput.Text)); + _activity.textOutput.Text = Base64.EncodeToString(results, Base64Flags.Default); } private bool ValidateInput(string input) { if (input.Trim().Equals(string.Empty)) { Toast.MakeText(_activity.ApplicationContext, Constants.ValidationMessage, ToastLength.Short).Show(); return true; } return false; } private GCMParameterSpec GenerateGcmParameterSpec() { var source = new byte[Constants.GcmNonceLength]; _random.NextBytes(source); return new GCMParameterSpec(Constants.GcmTagLength * 8, source); } private ISecretKey GenerateKey() { _random = SecureRandom.InstanceStrong; var keyGen = KeyGenerator.GetInstance(Constants.Algorithm); keyGen.Init(Constants.AesKeySize, _random); return keyGen.GenerateKey(); } } } \ No newline at end of file diff --git a/android-o/AndroidCipher/AndroidCipher/AndroidCipher.csproj b/android-o/AndroidCipher/AndroidCipher/AndroidCipher.csproj index b9243e0..bee3a85 100644 --- a/android-o/AndroidCipher/AndroidCipher/AndroidCipher.csproj +++ b/android-o/AndroidCipher/AndroidCipher/AndroidCipher.csproj @@ -1,174 +1,173 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{F0602434-8BAF-4D2E-A423-CC7CD4EA6AD6}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>AndroidCipher</RootNamespace> <AssemblyName>AndroidCipher</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> - <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <NuGetPackageImportStamp> </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>Full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> <AndroidLinkMode>None</AndroidLinkMode> <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidLinkMode>SdkOnly</AndroidLinkMode> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="AndroidCipher.cs" /> <Compile Include="Constants.cs" /> <Compile Include="MainActivity.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="GettingStarted.Xamarin" /> <None Include="packages.config"> <SubType>Designer</SubType> </None> <None Include="Resources\AboutResources.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="Assets\AboutAssets.txt" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml"> <SubType>Designer</SubType> </AndroidResource> <AndroidResource Include="Resources\values\strings.xml" /> </ItemGroup> <ItemGroup> <Folder Include="Resources\drawable\" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\styles.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-hdpi\icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-mdpi\icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-xhdpi\icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-xxhdpi\icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> \ No newline at end of file diff --git a/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocUpdFgService.csproj b/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocUpdFgService.csproj index 004fbdb..393ec5e 100644 --- a/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocUpdFgService.csproj +++ b/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocUpdFgService.csproj @@ -1,214 +1,213 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{8F28BD24-4751-4B87-A416-75C3BFC5D268}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>LocUpdFgService</RootNamespace> <AssemblyName>LocUpdFgService</AssemblyName> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> - <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> <NuGetPackageImportStamp> </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Design.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Transition, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Transition.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v4.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Vector.Drawable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Base, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Base.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Basement.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Location, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Location.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.dll</HintPath> <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Utils.cs" /> <Compile Include="LocationUpdatesService.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> <None Include="Resources\AboutResources.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="Assets\AboutAssets.txt" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-hdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-mdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\layout\activity_main.xml" /> <AndroidResource Include="Resources\values\colors.xml" /> <AndroidResource Include="Resources\values\dimens.xml" /> <AndroidResource Include="Resources\values\strings.xml" /> <AndroidResource Include="Resources\values\styles.xml" /> <AndroidResource Include="Resources\drawable-hdpi\ic_cancel.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_launch.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_cancel.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_launch.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_cancel.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_launch.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_cancel.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_launch.png" /> <AndroidResource Include="Resources\drawable-xxxhdpi\ic_cancel.png" /> <AndroidResource Include="Resources\drawable-xxxhdpi\ic_launch.png" /> <AndroidResource Include="Resources\values-w820dp\dimens.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props'))" /> <Error Condition="!Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" /> </Project> diff --git a/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocationUpdatesService.cs b/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocationUpdatesService.cs index 2c6f65b..a419fcc 100644 --- a/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocationUpdatesService.cs +++ b/android-o/AndroidPlayLocation/LocUpdFgService/LocUpdFgService/LocationUpdatesService.cs @@ -1,378 +1,378 @@ using System.Threading.Tasks; using Android.App; using Android.Content; using Android.Gms.Location; using Android.Gms.Tasks; using Android.Locations; using Android.OS; using Android.Runtime; using Android.Support.V4.App; using Android.Support.V4.Content; using Android.Util; using Java.Lang; using Task = Android.Gms.Tasks.Task; namespace LocUpdFgService { /** * A bound and started service that is promoted to a foreground service when location updates have * been requested and all clients unbind. * * For apps running in the background on "O" devices, location is computed only once every 10 * minutes and delivered batched every 30 minutes. This restriction applies even to apps * targeting "N" or lower which are run on "O" devices. * * This sample show how to use a long-running service for location updates. When an activity is * bound to this service, frequent location updates are permitted. When the activity is removed * from the foreground, the service promotes itself to a foreground service, and location updates * continue. When the activity comes back to the foreground, the foreground service stops, and the * notification assocaited with that service is removed. */ [Service(Label = "LocationUpdatesService", Enabled = true, Exported = true)] [IntentFilter(new string[] { "com.xamarin.LocUpdFgService.LocationUpdatesService" })] public class LocationUpdatesService : Service { const string LocationPackageName = "com.xamarin.LocUpdFgService"; public string Tag = "LocationUpdatesService"; string ChannelId = "channel_01"; public const string ActionBroadcast = LocationPackageName + ".broadcast"; public const string ExtraLocation = LocationPackageName + ".location"; const string ExtraStartedFromNotification = LocationPackageName + ".started_from_notification"; IBinder Binder; /** * The desired interval for location updates. Inexact. Updates may be more or less frequent. */ const long UpdateIntervalInMilliseconds = 10000; /** * The fastest rate for active location updates. Updates will never be more frequent * than this value. */ const long FastestUpdateIntervalInMilliseconds = UpdateIntervalInMilliseconds / 2; /** * The identifier for the notification displayed for the foreground service. */ const int NotificationId = 12345678; /** * Used to check whether the bound activity has really gone away and not unbound as part of an * orientation change. We create a foreground service notification only if the former takes * place. */ bool ChangingConfiguration = false; NotificationManager NotificationManager; /** * Contains parameters used by {@link com.google.android.gms.location.FusedLocationProviderApi}. */ LocationRequest LocationRequest; /** * Provides access to the Fused Location Provider API. */ FusedLocationProviderClient FusedLocationClient; /** * Callback for changes in location. */ LocationCallback LocationCallback; Handler ServiceHandler; /** * The current location. */ public Location Location; public LocationUpdatesService() { Binder = new LocationUpdatesServiceBinder(this); } class LocationCallbackImpl : LocationCallback { public LocationUpdatesService Service { get; set; } public override void OnLocationResult(LocationResult result) { base.OnLocationResult(result); Service.OnNewLocation(result.LastLocation); } } public override void OnCreate() { FusedLocationClient = LocationServices.GetFusedLocationProviderClient(this); LocationCallback = new LocationCallbackImpl { Service = this }; CreateLocationRequest(); GetLastLocation(); HandlerThread handlerThread = new HandlerThread(Tag); handlerThread.Start(); ServiceHandler = new Handler(handlerThread.Looper); NotificationManager = (NotificationManager) GetSystemService(NotificationService); - if (Build.VERSION.SdkInt >= Build.VERSION_CODES.O) + if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { string name = GetString(Resource.String.app_name); - NotificationChannel mChannel = new NotificationChannel(ChannelId, name, NotificationManager.ImportanceDefault); + NotificationChannel mChannel = new NotificationChannel(ChannelId, name, NotificationImportance.Default); NotificationManager.CreateNotificationChannel(mChannel); } } public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { Log.Info(Tag, "Service started"); var startedFromNotification = intent.GetBooleanExtra(ExtraStartedFromNotification, false); // We got here because the user decided to remove location updates from the notification. if (startedFromNotification) { RemoveLocationUpdates(); StopSelf(); } // Tells the system to not try to recreate the service after it has been killed. return StartCommandResult.NotSticky; } public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig) { base.OnConfigurationChanged(newConfig); ChangingConfiguration = true; } public override IBinder OnBind(Intent intent) { // Called when a client (MainActivity in case of this sample) comes to the foreground // and binds with this service. The service should cease to be a foreground service // when that happens. Log.Info(Tag, "in onBind()"); StopForeground(true); ChangingConfiguration = false; return Binder; } public override void OnRebind(Intent intent) { // Called when a client (MainActivity in case of this sample) returns to the foreground // and binds once again with this service. The service should cease to be a foreground // service when that happens. Log.Info(Tag, "in onRebind()"); StopForeground(true); ChangingConfiguration = false; base.OnRebind(intent); } public override bool OnUnbind(Intent intent) { Log.Info(Tag, "Last client unbound from service"); // Called when the last client (MainActivity in case of this sample) unbinds from this // service. If this method is called due to a configuration change in MainActivity, we // do nothing. Otherwise, we make this service a foreground service. if (!ChangingConfiguration && Utils.RequestingLocationUpdates(this)) { Log.Info(Tag, "Starting foreground service"); /* // TODO(developer). If targeting O, use the following code. if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O) { mNotificationManager.startServiceInForeground(new Intent(this, LocationUpdatesService.class), NOTIFICATION_ID, getNotification()); } else { startForeground(NOTIFICATION_ID, getNotification()); } */ StartForeground(NotificationId, GetNotification()); } return true; // Ensures onRebind() is called when a client re-binds. } public override void OnDestroy() { ServiceHandler.RemoveCallbacksAndMessages(null); } /** * Makes a request for location updates. Note that in this sample we merely log the * {@link SecurityException}. */ public void RequestLocationUpdates() { Log.Info(Tag, "Requesting location updates"); Utils.SetRequestingLocationUpdates(this, true); StartService(new Intent(ApplicationContext, typeof(LocationUpdatesService))); try { FusedLocationClient.RequestLocationUpdates(LocationRequest, LocationCallback, Looper.MyLooper()); } catch (SecurityException unlikely) { Utils.SetRequestingLocationUpdates(this, false); Log.Error(Tag, "Lost location permission. Could not request updates. " + unlikely); } } /** * Removes location updates. Note that in this sample we merely log the * {@link SecurityException}. */ public void RemoveLocationUpdates() { Log.Info(Tag, "Removing location updates"); try { FusedLocationClient.RemoveLocationUpdates(LocationCallback); Utils.SetRequestingLocationUpdates(this, false); StopSelf(); } catch (SecurityException unlikely) { Utils.SetRequestingLocationUpdates(this, true); Log.Error(Tag, "Lost location permission. Could not remove updates. " + unlikely); } } /** * Returns the {@link NotificationCompat} used as part of the foreground service. */ Notification GetNotification() { Intent intent = new Intent(this, typeof(LocationUpdatesService)); var text = Utils.GetLocationText(Location); // Extra to help us figure out if we arrived in onStartCommand via the notification or not. intent.PutExtra(ExtraStartedFromNotification, true); // The PendingIntent that leads to a call to onStartCommand() in this service. var servicePendingIntent = PendingIntent.GetService(this, 0, intent, PendingIntentFlags.UpdateCurrent); // The PendingIntent to launch activity. var activityPendingIntent = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(MainActivity)), 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .AddAction(Resource.Drawable.ic_launch, GetString(Resource.String.launch_activity), activityPendingIntent) .AddAction(Resource.Drawable.ic_cancel, GetString(Resource.String.remove_location_updates), servicePendingIntent) .SetContentText(text) .SetContentTitle(Utils.GetLocationTitle(this)) .SetOngoing(true) .SetPriority((int) NotificationPriority.High) .SetSmallIcon(Resource.Mipmap.ic_launcher) .SetTicker(text) .SetWhen(JavaSystem.CurrentTimeMillis()); - if (Build.VERSION.SdkInt>= Build.VERSION_CODES.O) + if (Build.VERSION.SdkInt>= BuildVersionCodes.O) { builder.SetChannelId(ChannelId); } return builder.Build(); } private void GetLastLocation() { try { FusedLocationClient.LastLocation.AddOnCompleteListener(new GetLastLocationOnCompleteListener { Service = this }); } catch (SecurityException unlikely) { Log.Error(Tag, "Lost location permission." + unlikely); } } public void OnNewLocation(Location location) { Log.Info(Tag, "New location: " + location); Location = location; // Notify anyone listening for broadcasts about the new location. Intent intent = new Intent(ActionBroadcast); intent.PutExtra(ExtraLocation, location); LocalBroadcastManager.GetInstance(ApplicationContext).SendBroadcast(intent); // Update notification content if running as a foreground service. if (ServiceIsRunningInForeground(this)) { NotificationManager.Notify(NotificationId, GetNotification()); } } /** * Sets the location request parameters. */ void CreateLocationRequest() { LocationRequest = new LocationRequest(); LocationRequest.SetInterval(UpdateIntervalInMilliseconds); LocationRequest.SetFastestInterval(FastestUpdateIntervalInMilliseconds); LocationRequest.SetPriority(LocationRequest.PriorityHighAccuracy); } /** * Returns true if this is a foreground service. * * @param context The {@link Context}. */ public bool ServiceIsRunningInForeground(Context context) { var manager = (ActivityManager) context.GetSystemService(ActivityService); foreach (var service in manager.GetRunningServices(Integer.MaxValue)) { if (Class.Name.Equals(service.Service.ClassName)) { if (service.Foreground) { return true; } } } return false; } } /** * Class used for the client Binder. Since this service runs in the same process as its * clients, we don't need to deal with IPC. */ public class LocationUpdatesServiceBinder : Binder { readonly LocationUpdatesService service; public LocationUpdatesServiceBinder(LocationUpdatesService service) { this.service = service; } public LocationUpdatesService GetLocationUpdatesService() { return service; } } public class GetLastLocationOnCompleteListener : Object, IOnCompleteListener { public LocationUpdatesService Service { get; set; } public void OnComplete(Task task) { if (task.IsSuccessful && task.Result != null) { Service.Location = (Location)task.Result; } else { Log.Warn(Service.Tag, "Failed to get location."); } } } } diff --git a/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/LocUpdPendIntent.csproj b/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/LocUpdPendIntent.csproj index fa563f3..efe48cf 100644 --- a/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/LocUpdPendIntent.csproj +++ b/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/LocUpdPendIntent.csproj @@ -1,205 +1,204 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{E6058364-DCA8-4893-9C25-6BAC8BFBEE4D}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>LocUpdPendIntent</RootNamespace> <AssemblyName>LocUpdPendIntent</AssemblyName> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> - <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> <NuGetPackageImportStamp> </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Design.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Transition, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Transition.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v4.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Vector.Drawable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Base, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Base.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Basement.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Location, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Location.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.GooglePlayServices.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\lib\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.dll</HintPath> <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="LocationUpdatesBroadcastReceiver.cs" /> <Compile Include="LocationUpdatesIntentService.cs" /> <Compile Include="Utils.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> <None Include="Resources\AboutResources.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="Assets\AboutAssets.txt" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\mipmap-hdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-mdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\layout\activity_main.xml" /> <AndroidResource Include="Resources\values\colors.xml" /> <AndroidResource Include="Resources\values\dimens.xml" /> <AndroidResource Include="Resources\values\strings.xml" /> <AndroidResource Include="Resources\values\styles.xml" /> <AndroidResource Include="Resources\values-w820dp\dimens.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.props'))" /> <Error Condition="!Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Basement.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Basement.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Base.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Base.targets')" /> <Import Project="..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Location.60.1142.0\build\MonoAndroid80\Xamarin.GooglePlayServices.Location.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" /> </Project> diff --git a/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/Utils.cs b/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/Utils.cs index 0cdee9f..d6f6899 100644 --- a/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/Utils.cs +++ b/android-o/AndroidPlayLocation/LocUpdPendIntent/LocUpdPendIntent/Utils.cs @@ -1,150 +1,150 @@ using System; using System.Collections.Generic; using Android.App; using Android.Content; using Android.Graphics; using Android.Locations; using Android.OS; using Android.Preferences; using Android.Runtime; using Android.Support.V4.App; using Java.Lang; namespace LocUpdPendIntent { /** * Utility methods used in this sample. */ public class Utils { public const string KeyLocationUpdatesRequested = "location-updates-requested"; public const string KeyLocationUpdatesResult = "location-update-result"; public const string ChannelId = "channel_01"; public static void SetRequestingLocationUpdates(Context context, bool value) { PreferenceManager.GetDefaultSharedPreferences(context) .Edit() .PutBoolean(KeyLocationUpdatesRequested, value) .Apply(); } public static bool GetRequestingLocationUpdates(Context context) { return PreferenceManager.GetDefaultSharedPreferences(context) .GetBoolean(KeyLocationUpdatesRequested, false); } /** * Posts a notification in the notification bar when a transition is detected. * If the user clicks the notification, control goes to the MainActivity. */ public static void SendNotification(Context context, string notificationDetails) { // Create an explicit content Intent that starts the main Activity. var notificationIntent = new Intent(context, typeof(MainActivity)); notificationIntent.PutExtra("from_notification", true); // Construct a task stack. var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(context); // Add the main Activity to the task stack as the parent. stackBuilder.AddParentStack(Class.FromType(typeof(MainActivity))); // Push the content Intent onto the stack. stackBuilder.AddNextIntent(notificationIntent); // Get a PendingIntent containing the entire back stack. var notificationPendingIntent = stackBuilder.GetPendingIntent(0, (int) PendingIntentFlags.UpdateCurrent); // Get a notification builder that's compatible with platform versions >= 4 NotificationCompat.Builder builder = new NotificationCompat.Builder(context); // Define the notification settings. builder.SetSmallIcon(Resource.Mipmap.ic_launcher) // In a real app, you may want to use a library like Volley // to decode the Bitmap. .SetLargeIcon(BitmapFactory.DecodeResource(context.Resources, Resource.Mipmap.ic_launcher)) .SetColor(Color.Red) .SetContentTitle("Location update") .SetContentText(notificationDetails) .SetContentIntent(notificationPendingIntent); // Dismiss notification once the user touches it. builder.SetAutoCancel(true); // Get an instance of the Notification manager var mNotificationManager = context.GetSystemService(Context.NotificationService) as NotificationManager; // Android O requires a Notification Channel. - if (Build.VERSION.SdkInt>= Build.VERSION_CODES.O) + if (Build.VERSION.SdkInt>= BuildVersionCodes.O) { string name = context.GetString(Resource.String.app_name); // Create the channel for the notification // Create the channel for the notification - NotificationChannel mChannel = new NotificationChannel(ChannelId, name, NotificationManager.ImportanceDefault); + NotificationChannel mChannel = new NotificationChannel(ChannelId, name, NotificationImportance.Default); // Set the Notification Channel for the Notification Manager. mNotificationManager.CreateNotificationChannel(mChannel); // Channel ID builder.SetChannelId(ChannelId); } // Issue the notification mNotificationManager.Notify(0, builder.Build()); } /** * Returns the title for reporting about a list of {@link Location} objects. * * @param context The {@link Context}. */ public static string GetLocationResultTitle(Context context, IList<Location> locations) { var numLocationsReported = context.Resources.GetQuantityString( Resource.Plurals.num_locations_reported, locations.Count, locations.Count); return numLocationsReported + ": " + DateTime.Now.ToString(); } /** * Returns te text for reporting about a list of {@link Location} objects. * * @param locations List of {@link Location}s. */ public static string GetLocationResultText(Context context, IList<Location> locations) { if (locations.Count == 0) { return context.GetString(Resource.String.unknown_location); } var sb = new StringBuilder(); foreach (var location in locations) { sb.Append("("); sb.Append(location.Latitude); sb.Append(", "); sb.Append(location.Longitude); sb.Append(")"); sb.Append("\n"); } return sb.ToString(); } public static void SetLocationUpdatesResult(Context context, IList<Location> locations) { PreferenceManager.GetDefaultSharedPreferences(context) .Edit() .PutString(KeyLocationUpdatesResult, GetLocationResultTitle(context, locations) + "\n" + GetLocationResultText(context, locations)) .Apply(); } public static string GetLocationUpdatesResult(Context context) { return PreferenceManager.GetDefaultSharedPreferences(context) .GetString(KeyLocationUpdatesResult, ""); } } } diff --git a/android-o/AutofillFramework/AutofillFramework/AutofillFramework.csproj b/android-o/AutofillFramework/AutofillFramework/AutofillFramework.csproj index f24b11e..e6a7c32 100644 --- a/android-o/AutofillFramework/AutofillFramework/AutofillFramework.csproj +++ b/android-o/AutofillFramework/AutofillFramework/AutofillFramework.csproj @@ -1,277 +1,276 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{AC90B879-1EBD-4E98-8171-778680205CAD}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>AutofillFramework</RootNamespace> <AssemblyName>AutofillFramework</AssemblyName> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> - <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> <NuGetPackageImportStamp> </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Configuration"> <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Configuration.dll</HintPath> </Reference> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.IO.Compression" /> <Reference Include="System.Net.Http" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Constraint.Layout.Solver"> <HintPath>..\packages\Xamarin.Android.Support.Constraint.Layout.Solver.1.0.2.2\lib\MonoAndroid70\Xamarin.Android.Support.Constraint.Layout.Solver.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Constraint.Layout"> <HintPath>..\packages\Xamarin.Android.Support.Constraint.Layout.1.0.2.2\lib\MonoAndroid70\Xamarin.Android.Support.Constraint.Layout.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Design.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Transition, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Transition.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v4.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v7.CardView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.CardView.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="CommonUtil.cs" /> <Compile Include="CreditCardActivity.cs" /> <Compile Include="CreditCardAntiPatternActivity.cs" /> <Compile Include="CreditCardCompoundViewActivity.cs" /> <Compile Include="CreditCardDatePickerActivity.cs" /> <Compile Include="CreditCardExpirationDateCompoundView.cs" /> <Compile Include="CreditCardExpirationDatePickerView.cs" /> <Compile Include="CreditCardSpinnersActivity.cs" /> <Compile Include="CustomVirtualView.cs" /> <Compile Include="EmailComposeActivity.cs" /> <Compile Include="InfoButton.cs" /> <Compile Include="MainActivity.cs" /> <Compile Include="MultiplePartitionsActivity.cs" /> <Compile Include="NavigationItem.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="ScrollableCustomVirtualView.cs" /> <Compile Include="StandardAutoCompleteSignInActivity.cs" /> <Compile Include="StandardSignInActivity.cs" /> <Compile Include="VirtualSignInActivity.cs" /> <Compile Include="WebViewSignInActivity.cs" /> <Compile Include="WelcomeActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\attrs.xml" /> <AndroidResource Include="Resources\values\dimens.xml" /> <AndroidResource Include="Resources\values\strings.xml" /> <AndroidResource Include="Resources\values\styles.xml" /> <AndroidResource Include="Resources\xml\multidataset_service.xml" /> <AndroidResource Include="Resources\mipmap-hdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-mdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png" /> <AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_autocomplete_logo_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_custom_virtual_logo_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_disabled_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_edittexts_logo_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_email_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_info_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_person_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_send_white_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_spinners_logo_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_view_module_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_web_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\activity_main.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\cc_exp_date.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\credit_card_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\credit_card_anti_pattern_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\credit_card_compound_view_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\credit_card_date_picker_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\credit_card_spinners_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\email_compose_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\login_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\login_webview_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\login_with_autocomplete_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\multiple_partitions_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\navigation_button.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\navigation_item.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\virtual_login_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\welcome_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Resources\raw\sample_form.html"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </AndroidAsset> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" /> </Project> \ No newline at end of file diff --git a/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDateCompoundView.cs b/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDateCompoundView.cs index 4e9f2eb..d7c4a81 100644 --- a/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDateCompoundView.cs +++ b/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDateCompoundView.cs @@ -1,126 +1,126 @@ using System; using Android.Content; using Android.Runtime; using Android.Util; using Android.Views; using Android.Views.Autofill; using Android.Widget; using Java.Lang; using Java.Util; namespace AutofillFramework { public class CreditCardExpirationDateCompoundView : FrameLayout { private static int CC_EXP_YEARS_COUNT = 5; private string[] mYears = new string[CC_EXP_YEARS_COUNT]; private Spinner mCcExpMonthSpinner; private Spinner mCcExpYearSpinner; protected CreditCardExpirationDateCompoundView(IntPtr javaReference, JniHandleOwnership transfer) : base( javaReference, transfer) { } public CreditCardExpirationDateCompoundView(Context context) : this(context, null) { } public CreditCardExpirationDateCompoundView(Context context, IAttributeSet attrs) : this(context, attrs, 0) { } public CreditCardExpirationDateCompoundView(Context context, IAttributeSet attrs, int defStyleAttr) : this( context, attrs, defStyleAttr, 0) { } public CreditCardExpirationDateCompoundView(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes) : base(context, attrs, defStyleAttr, defStyleRes) { var rootView = LayoutInflater.From(context).Inflate(Resource.Layout.cc_exp_date, this); mCcExpMonthSpinner = rootView.FindViewById<Spinner>(Resource.Id.ccExpMonth); mCcExpYearSpinner = rootView.FindViewById<Spinner>(Resource.Id.ccExpYear); - ImportantForAutofill = ImportantForAutofillYesExcludeDescendants; + ImportantForAutofill = ImportantForAutofill.YesExcludeDescendants; var monthAdapter = ArrayAdapter.CreateFromResource(context, Resource.Array.month_array, Android.Resource.Layout.SimpleSpinnerItem); monthAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); mCcExpMonthSpinner.Adapter = monthAdapter; - int year = Calendar.Instance.Get(Calendar.Year); + int year = Calendar.Instance.Get(CalendarField.Year); for (int i = 0; i < mYears.Length; i++) { mYears[i] = (year + i).ToString(); } mCcExpYearSpinner.Adapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SimpleSpinnerItem, mYears); var onItemSelectedListener = new ItemSelectedListener { that = this, context = context }; mCcExpMonthSpinner.OnItemSelectedListener = onItemSelectedListener; mCcExpYearSpinner.OnItemSelectedListener = onItemSelectedListener; } public class ItemSelectedListener : Java.Lang.Object, AdapterView.IOnItemSelectedListener { public Context context; public CreditCardExpirationDateCompoundView that; public void OnItemSelected(AdapterView parent, View view, int position, long id) { ((AutofillManager) context.GetSystemService(Class.FromType(typeof(AutofillManager)))) .NotifyValueChanged(that); } public void OnNothingSelected(AdapterView parent) { } } public override AutofillValue AutofillValue { get { var calendar = Calendar.Instance; // Set hours, minutes, seconds, and millis to 0 to ensure getAutofillValue() == the value // set by autofill(). Without this line, the view will not turn yellow when updated. calendar.Clear(); var year = Integer.ParseInt(mCcExpYearSpinner.SelectedItem.ToString()); var month = mCcExpMonthSpinner.SelectedItemPosition; - calendar.Set(Calendar.Year, year); - calendar.Set(Calendar.Month, month); + calendar.Set(CalendarField.Year, year); + calendar.Set(CalendarField.Month, month); var unixTime = calendar.TimeInMillis; return AutofillValue.ForDate(unixTime); } } public override void Autofill(AutofillValue value) { if (!value.IsDate) { Log.Warn(CommonUtil.TAG, "Ignoring autofill() because service sent a non-date value:" + value); return; } var calendar = Calendar.Instance; calendar.TimeInMillis = value.DateValue; - var month = calendar.Get(Calendar.Month); - var year = calendar.Get(Calendar.Year); + var month = calendar.Get(CalendarField.Month); + var year = calendar.Get(CalendarField.Year); mCcExpMonthSpinner.SetSelection(month); mCcExpYearSpinner.SetSelection(year - Integer.ParseInt(mYears[0])); } public override AutofillType AutofillType => AutofillType.Date; public void Reset() { mCcExpMonthSpinner.SetSelection(0); mCcExpYearSpinner.SetSelection(0); } } } \ No newline at end of file diff --git a/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDatePickerView.cs b/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDatePickerView.cs index 19ea875..ae21a34 100644 --- a/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDatePickerView.cs +++ b/android-o/AutofillFramework/AutofillFramework/CreditCardExpirationDatePickerView.cs @@ -1,144 +1,144 @@ using System; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Support.V7.Widget; using Android.Text.Format; using Android.Util; using Android.Views; using Android.Views.Autofill; using Android.Widget; using Java.Util; using FragmentManager = Android.Support.V4.App.FragmentManager; using DialogFragment = Android.Support.V4.App.DialogFragment; namespace AutofillFramework { public class CreditCardExpirationDatePickerView : AppCompatEditText { private static int CC_EXP_YEARS_COUNT = 5; /** * Calendar instance used for month / year calculations. Should be reset before each use. */ private Calendar mTempCalendar; public int mMonth; public int mYear; protected CreditCardExpirationDatePickerView(IntPtr javaReference, JniHandleOwnership transfer) : base( javaReference, transfer) { } public CreditCardExpirationDatePickerView(Context context) : this(context, null) { } public CreditCardExpirationDatePickerView(Context context, IAttributeSet attrs) : this(context, attrs, 0) { } public CreditCardExpirationDatePickerView(Context context, IAttributeSet attrs, int defStyleAttr) : base( context, attrs, defStyleAttr) { // Use the current date as the initial date in the picker. mTempCalendar = Calendar.Instance; - mYear = mTempCalendar.Get(Calendar.Year); - mMonth = mTempCalendar.Get(Calendar.Month); + mYear = mTempCalendar.Get(CalendarField.Year); + mMonth = mTempCalendar.Get(CalendarField.Month); } /** * Gets a temporary calendar set with the View's year and month. */ private Calendar GetCalendar() { mTempCalendar.Clear(); - mTempCalendar.Set(Calendar.Year, mYear); - mTempCalendar.Set(Calendar.Month, mMonth); - mTempCalendar.Set(Calendar.Date, 1); + mTempCalendar.Set(CalendarField.Year, mYear); + mTempCalendar.Set(CalendarField.Month, mMonth); + mTempCalendar.Set(CalendarField.Date, 1); return mTempCalendar; } public override AutofillValue AutofillValue { get { var c = GetCalendar(); var value = AutofillValue.ForDate(c.TimeInMillis); if (CommonUtil.DEBUG) Log.Debug(CommonUtil.TAG, "getAutofillValue(): " + value); return value; } } public override void Autofill(AutofillValue value) { if (value == null || !value.IsDate) { Log.Warn(CommonUtil.TAG, "autofill(): invalid value " + value); return; } var time = value.DateValue; mTempCalendar.TimeInMillis = time; - var year = mTempCalendar.Get(Calendar.Year); - var month = mTempCalendar.Get(Calendar.Month); + var year = mTempCalendar.Get(CalendarField.Year); + var month = mTempCalendar.Get(CalendarField.Month); if (CommonUtil.DEBUG) Log.Debug(CommonUtil.TAG, "autofill(" + value + "): " + month + "/" + year); SetDate(year, month); } private void SetDate(int year, int month) { mYear = year; mMonth = month; var selectedDate = new Date(GetCalendar().TimeInMillis); var dateString = DateFormat.GetDateFormat(Context).Format(selectedDate); Text = dateString; } public override AutofillType AutofillType => AutofillType.Text; public void Reset() { mTempCalendar.TimeInMillis = DateTime.Now.Millisecond; - SetDate(mTempCalendar.Get(Calendar.Year), mTempCalendar.Get(Calendar.Month)); + SetDate(mTempCalendar.Get(CalendarField.Year), mTempCalendar.Get(CalendarField.Month)); } public void ShowDatePickerDialog(FragmentManager fragmentManager) { var newFragment = new DatePickerFragment(); newFragment.mParent = this; newFragment.Show(fragmentManager, "datePicker"); } public class DatePickerFragment : DialogFragment, DatePickerDialog.IOnDateSetListener { public CreditCardExpirationDatePickerView that; public CreditCardExpirationDatePickerView mParent; public override Dialog OnCreateDialog(Bundle savedInstanceState) { var dialog = new DatePickerDialog(Activity, Resource.Style.CustomDatePickerDialogTheme, this, mParent.mYear, mParent.mMonth, 1); DatePicker datePicker = dialog.DatePicker; // Limit range. Calendar c = mParent.GetCalendar(); datePicker.MinDate = c.TimeInMillis; - c.Set(Calendar.Year, mParent.mYear + CC_EXP_YEARS_COUNT - 1); + c.Set(CalendarField.Year, mParent.mYear + CC_EXP_YEARS_COUNT - 1); datePicker.MaxDate = c.TimeInMillis; // Remove day. datePicker.FindViewById(Resources.GetIdentifier("day", "id", "android")) .Visibility = ViewStates.Gone; return dialog; } public void OnDateSet(DatePicker view, int year, int month, int dayOfMonth) { mParent.SetDate(year, month); } } } } \ No newline at end of file diff --git a/android-o/AutofillFramework/AutofillFramework/CreditCardSpinnersActivity.cs b/android-o/AutofillFramework/AutofillFramework/CreditCardSpinnersActivity.cs index 88bb64f..1475a2d 100644 --- a/android-o/AutofillFramework/AutofillFramework/CreditCardSpinnersActivity.cs +++ b/android-o/AutofillFramework/AutofillFramework/CreditCardSpinnersActivity.cs @@ -1,148 +1,148 @@ using System; using System.Collections; using System.Linq; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Support.V7.App; using Android.Views.Autofill; using Android.Widget; using Java.Lang; using Object = Java.Lang.Object; namespace AutofillFramework { [Activity(Label = "CreditCardSpinnersActivity")] [Register("com.xamarin.AutofillFramework.CreditCardSpinnersActivity")] public class CreditCardSpinnersActivity : AppCompatActivity { private static int CC_EXP_YEARS_COUNT = 5; private string[] years = new string[CC_EXP_YEARS_COUNT]; private Spinner mCcExpirationDaySpinner; private Spinner mCcExpirationMonthSpinner; private Spinner mCcExpirationYearSpinner; private EditText mCcCardNumber; private EditText mCcSecurityCode; public static Intent GetStartActivityIntent(Context context) { var intent = new Intent(context, typeof(CreditCardSpinnersActivity)); return intent; } protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.credit_card_spinners_activity); mCcExpirationDaySpinner = FindViewById<Spinner>(Resource.Id.expirationDay); mCcExpirationMonthSpinner = FindViewById<Spinner>(Resource.Id.expirationMonth); mCcExpirationYearSpinner = FindViewById<Spinner>(Resource.Id.expirationYear); mCcCardNumber = FindViewById<EditText>(Resource.Id.creditCardNumberField); mCcSecurityCode = FindViewById<EditText>(Resource.Id.creditCardSecurityCode); // Create an ArrayAdapter using the string array and a default spinner layout var dayAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.day_array, Android.Resource.Layout.SimpleSpinnerItem); // Specify the layout to use when the list of choices appears dayAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); // Apply the adapter to the spinner mCcExpirationDaySpinner.Adapter = dayAdapter; /* R.array.month_array could be an array of Strings like "Jan", "Feb", "March", etc., and the AutofillService would know how to autofill it. However, for the sake of keeping the AutofillService simple, we will stick to a list of numbers (1, 2, ... 12) to represent months; it makes it much easier to generate fake autofill data in the service that can still autofill this spinner. */ var monthAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.month_array, Android.Resource.Layout.SimpleSpinnerItem); // Adapter created from resource has getAutofillOptions() implemented by default. monthAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); mCcExpirationMonthSpinner.Adapter = monthAdapter; - int year = Java.Util.Calendar.Instance.Get(Java.Util.Calendar.Year); + int year = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Year); for (int i = 0; i < years.Length; i++) { years[i] = (year + i).ToString(); } // Since the years Spinner uses a custom adapter, it needs to implement getAutofillOptions. mCcExpirationYearSpinner.Adapter = new YearSpinnerArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, years) {that = this}; FindViewById(Resource.Id.submit).Click += delegate { Submit(); }; FindViewById(Resource.Id.clear).Click += delegate { ((AutofillManager) GetSystemService(Class.FromType(typeof(AutofillManager)))).Cancel(); ResetFields(); }; } public class YearSpinnerArrayAdapter : ArrayAdapter { public CreditCardSpinnersActivity that; protected YearSpinnerArrayAdapter(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { } public YearSpinnerArrayAdapter(Context context, int resource) : base(context, resource) { } public YearSpinnerArrayAdapter(Context context, int resource, int textViewResourceId) : base(context, resource, textViewResourceId) { } public YearSpinnerArrayAdapter(Context context, int resource, int textViewResourceId, IList objects) : base( context, resource, textViewResourceId, objects) { } public YearSpinnerArrayAdapter(Context context, int resource, int textViewResourceId, Object[] objects) : base(context, resource, textViewResourceId, objects) { } public YearSpinnerArrayAdapter(Context context, int resource, IList objects) : base(context, resource, objects) { } public YearSpinnerArrayAdapter(Context context, int resource, Object[] objects) : base(context, resource, objects) { } public override ICharSequence[] GetAutofillOptionsFormatted() { return that.years.Select(x => new Java.Lang.String(x)).ToArray(); } } private void ResetFields() { mCcExpirationDaySpinner.SetSelection(0); mCcExpirationMonthSpinner.SetSelection(0); mCcExpirationYearSpinner.SetSelection(0); mCcCardNumber.Text = string.Empty; mCcSecurityCode.Text = string.Empty; } /** * Launches new Activity and finishes, triggering an autofill save request if the user entered * any new data. */ private void Submit() { Intent intent = WelcomeActivity.GetStartActivityIntent(this); StartActivity(intent); Finish(); } } } \ No newline at end of file diff --git a/android-o/AutofillFramework/AutofillService/AutofillHints.cs b/android-o/AutofillFramework/AutofillService/AutofillHints.cs index facfad6..614ece7 100644 --- a/android-o/AutofillFramework/AutofillService/AutofillHints.cs +++ b/android-o/AutofillFramework/AutofillService/AutofillHints.cs @@ -1,921 +1,921 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; using Android.Service.Autofill; using Android.Util; using Android.Views; using AutofillService.Model; -using static Android.Icu.Util.Calendar; +using static Android.Icu.Util.CalendarField; namespace AutofillService { public class AutofillHints { public static int PARTITION_OTHER = 0; public static int PARTITION_ADDRESS = 1; public static int PARTITION_EMAIL = 2; public static int PARTITION_CREDIT_CARD = 3; public static int[] PARTITIONS = {PARTITION_OTHER, PARTITION_ADDRESS, PARTITION_EMAIL, PARTITION_CREDIT_CARD}; //TODO: finish building fake data for all hints. private static ImmutableDictionary<string, AutofillHintProperties> sValidHints = new Dictionary<string, AutofillHintProperties>() { { View.AutofillHintEmailAddress, new AutofillHintProperties(View.AutofillHintEmailAddress, SaveDataType.EmailAddress, PARTITION_EMAIL, new FakeFieldGeneratorForText(View.AutofillHintEmailAddress, "email{0}"), AutofillType.Text, AutofillType.List) }, { View.AutofillHintName, new AutofillHintProperties(View.AutofillHintName, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(View.AutofillHintName, "name{0}"), AutofillType.Text, AutofillType.List) }, { View.AutofillHintUsername, new AutofillHintProperties(View.AutofillHintUsername, SaveDataType.Username, PARTITION_OTHER, new FakeFieldGeneratorForText(View.AutofillHintUsername, "login{0}"), AutofillType.Text, AutofillType.List) }, { View.AutofillHintPassword, new AutofillHintProperties(View.AutofillHintPassword, SaveDataType.Password, PARTITION_OTHER, new FakeFieldGeneratorForText(View.AutofillHintPassword, "login{0}"), AutofillType.Text) }, { View.AutofillHintPhone, new AutofillHintProperties(View.AutofillHintPhone, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(View.AutofillHintPhone, "{0}2345678910"), AutofillType.Text, AutofillType.List) }, { View.AutofillHintPostalAddress, new AutofillHintProperties(View.AutofillHintPostalAddress, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(View.AutofillHintPostalAddress, "{0} Fake Ln, Fake, FA, FAA 10001"), AutofillType.Text, AutofillType.List) }, { View.AutofillHintPostalCode, new AutofillHintProperties(View.AutofillHintPostalCode, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(View.AutofillHintPostalCode, "1000{0}"), AutofillType.Text, AutofillType.List) }, { View.AutofillHintCreditCardNumber, new AutofillHintProperties(View.AutofillHintCreditCardNumber, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(View.AutofillHintCreditCardNumber, "{0}234567"), AutofillType.Text) }, { View.AutofillHintCreditCardSecurityCode, new AutofillHintProperties(View.AutofillHintCreditCardSecurityCode, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(View.AutofillHintCreditCardSecurityCode, "{0}{0}{0}"), AutofillType.Text) }, { View.AutofillHintCreditCardExpirationDate, new AutofillHintProperties( View.AutofillHintCreditCardExpirationDate, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForDate(View.AutofillHintCreditCardExpirationDate), AutofillType.Date) }, { View.AutofillHintCreditCardExpirationMonth, new AutofillHintProperties( View.AutofillHintCreditCardExpirationMonth, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorExpirationMonth(View.AutofillHintCreditCardExpirationMonth), AutofillType.Date) }, { View.AutofillHintCreditCardExpirationYear, new AutofillHintProperties( View.AutofillHintCreditCardExpirationYear, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorExpirationYear(View.AutofillHintCreditCardExpirationYear), AutofillType.Text, AutofillType.List, AutofillType.Date) }, { View.AutofillHintCreditCardExpirationDay, new AutofillHintProperties( View.AutofillHintCreditCardExpirationDay, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorExpirationDay(View.AutofillHintCreditCardExpirationDay), AutofillType.Text, AutofillType.List, AutofillType.Date) }, { W3cHints.HONORIFIC_PREFIX, new AutofillHintProperties( W3cHints.HONORIFIC_PREFIX, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForListValue(W3cHints.HONORIFIC_PREFIX, new[] {"Miss", "Ms.", "Mr.", "Mx.", "Sr.", "Dr.", "Lady", "Lord"}), AutofillType.Text, AutofillType.List) }, { W3cHints.GIVEN_NAME, new AutofillHintProperties( W3cHints.GIVEN_NAME, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.GIVEN_NAME, "name{0}"), AutofillType.Text) }, { W3cHints.ADDITIONAL_NAME, new AutofillHintProperties( W3cHints.ADDITIONAL_NAME, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.ADDITIONAL_NAME, "addtlname{0}"), AutofillType.Text) }, { W3cHints.FAMILY_NAME, new AutofillHintProperties( W3cHints.FAMILY_NAME, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.FAMILY_NAME, "famname{0}"), AutofillType.Text) }, { W3cHints.HONORIFIC_SUFFIX, new AutofillHintProperties( W3cHints.HONORIFIC_SUFFIX, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForListValue(W3cHints.HONORIFIC_SUFFIX, new[] {"san", "kun", "chan", "sama"}), AutofillType.Text, AutofillType.List) }, { W3cHints.NEW_PASSWORD, new AutofillHintProperties( W3cHints.NEW_PASSWORD, SaveDataType.Password, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.NEW_PASSWORD, "login{0}"), AutofillType.Text) }, { W3cHints.CURRENT_PASSWORD, new AutofillHintProperties( View.AutofillHintPassword, SaveDataType.Password, PARTITION_OTHER, new FakeFieldGeneratorForText(View.AutofillHintPassword, "login{0}"), AutofillType.Text) }, { W3cHints.ORGANIZATION_TITLE, new AutofillHintProperties( W3cHints.ORGANIZATION_TITLE, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.ORGANIZATION_TITLE, "org{0}"), AutofillType.Text, AutofillType.List) }, { W3cHints.ORGANIZATION, new AutofillHintProperties( W3cHints.ORGANIZATION, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.ORGANIZATION, "org{0}"), AutofillType.Text, AutofillType.List) }, { W3cHints.STREET_ADDRESS, new AutofillHintProperties( W3cHints.STREET_ADDRESS, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(W3cHints.STREET_ADDRESS, "{0} Fake Ln, Fake, FA, FAA 10001"), AutofillType.Text) }, { W3cHints.ADDRESS_LINE1, new AutofillHintProperties( W3cHints.ADDRESS_LINE1, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(W3cHints.ADDRESS_LINE1, "{0} Fake Ln"), AutofillType.Text) }, { W3cHints.ADDRESS_LINE2, new AutofillHintProperties( W3cHints.ADDRESS_LINE2, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(W3cHints.ADDRESS_LINE2, "Apt. {0}"), AutofillType.Text) }, { W3cHints.ADDRESS_LINE3, new AutofillHintProperties( W3cHints.ADDRESS_LINE3, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(W3cHints.ADDRESS_LINE3, "FA{0}, FA, FAA"), AutofillType.Text) }, { W3cHints.ADDRESS_LEVEL4, new AutofillHintProperties( W3cHints.ADDRESS_LEVEL4, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGenerator(W3cHints.ADDRESS_LEVEL4), AutofillType.Text) }, { W3cHints.ADDRESS_LEVEL3, new AutofillHintProperties( W3cHints.ADDRESS_LEVEL3, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGenerator(W3cHints.ADDRESS_LEVEL3), AutofillType.Text) }, { W3cHints.ADDRESS_LEVEL2, new AutofillHintProperties( W3cHints.ADDRESS_LEVEL2, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGenerator(W3cHints.ADDRESS_LEVEL2), AutofillType.Text) }, { W3cHints.ADDRESS_LEVEL1, new AutofillHintProperties( W3cHints.ADDRESS_LEVEL1, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGenerator(W3cHints.ADDRESS_LEVEL1), AutofillType.Text) }, { W3cHints.COUNTRY, new AutofillHintProperties( W3cHints.COUNTRY, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGenerator(W3cHints.COUNTRY), AutofillType.Text, AutofillType.List) }, { W3cHints.COUNTRY_NAME, new AutofillHintProperties( W3cHints.COUNTRY_NAME, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForListValue(W3cHints.COUNTRY_NAME, new[] {"USA", "Mexico", "Canada"}), AutofillType.Text, AutofillType.List) }, { W3cHints.POSTAL_CODE, new AutofillHintProperties( W3cHints.POSTAL_CODE, SaveDataType.Address, PARTITION_ADDRESS, new FakeFieldGeneratorForText(W3cHints.POSTAL_CODE, "{0}{0}{0}{0}{0}"), AutofillType.Text) }, { W3cHints.CC_NAME, new AutofillHintProperties( W3cHints.CC_NAME, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(W3cHints.CC_NAME, "firstname{0}lastname{0}"), AutofillType.Text) }, { W3cHints.CC_GIVEN_NAME, new AutofillHintProperties( W3cHints.CC_GIVEN_NAME, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(W3cHints.CC_GIVEN_NAME, "givenname{0}"), AutofillType.Text) }, { W3cHints.CC_ADDITIONAL_NAME, new AutofillHintProperties( W3cHints.CC_ADDITIONAL_NAME, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(W3cHints.CC_ADDITIONAL_NAME, "addtlname{0}"), AutofillType.Text) }, { W3cHints.CC_FAMILY_NAME, new AutofillHintProperties( W3cHints.CC_FAMILY_NAME, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(W3cHints.CC_FAMILY_NAME, "familyname{0}"), AutofillType.Text) }, { W3cHints.CC_NUMBER, new AutofillHintProperties( View.AutofillHintCreditCardNumber, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(View.AutofillHintCreditCardNumber, "{0}234567"), AutofillType.Text) }, { W3cHints.CC_EXPIRATION, new AutofillHintProperties( View.AutofillHintCreditCardExpirationDate, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForDate(View.AutofillHintCreditCardExpirationDate), AutofillType.Date) }, { W3cHints.CC_EXPIRATION_MONTH, new AutofillHintProperties( View.AutofillHintCreditCardExpirationMonth, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorExpirationMonth(View.AutofillHintCreditCardExpirationMonth), AutofillType.Text, AutofillType.List) }, { W3cHints.CC_EXPIRATION_YEAR, new AutofillHintProperties( View.AutofillHintCreditCardExpirationYear, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorExpirationYear(View.AutofillHintCreditCardExpirationYear), AutofillType.Text, AutofillType.List) }, { W3cHints.CC_CSC, new AutofillHintProperties( View.AutofillHintCreditCardSecurityCode, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(View.AutofillHintCreditCardSecurityCode, "{0}{0}{0}"), AutofillType.Text) }, { W3cHints.CC_TYPE, new AutofillHintProperties( W3cHints.CC_TYPE, SaveDataType.CreditCard, PARTITION_CREDIT_CARD, new FakeFieldGeneratorForText(W3cHints.CC_TYPE, "type{0}"), AutofillType.Text, AutofillType.List) }, { W3cHints.TRANSACTION_CURRENCY, new AutofillHintProperties( W3cHints.TRANSACTION_CURRENCY, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForListValue(W3cHints.TRANSACTION_CURRENCY, new[] {"USD", "CAD", "KYD", "CRC"}), AutofillType.Text, AutofillType.List) }, { W3cHints.TRANSACTION_AMOUNT, new AutofillHintProperties( W3cHints.TRANSACTION_AMOUNT, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForNumberMultiply(W3cHints.TRANSACTION_AMOUNT, 100), AutofillType.Text, AutofillType.List) }, { W3cHints.LANGUAGE, new AutofillHintProperties( W3cHints.LANGUAGE, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForListValue(W3cHints.LANGUAGE, new[] {"Bulgarian", "Croatian", "Czech", "Danish", "Dutch", "English", "Estonian"}), AutofillType.Text, AutofillType.List) }, { W3cHints.BDAY, new AutofillHintProperties( W3cHints.BDAY, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForBirthDay(W3cHints.BDAY), AutofillType.Date) }, { W3cHints.BDAY_DAY, new AutofillHintProperties( W3cHints.BDAY_DAY, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForNumberDivide(W3cHints.BDAY_DAY, 27), AutofillType.Text, AutofillType.List) }, { W3cHints.BDAY_MONTH, new AutofillHintProperties( W3cHints.BDAY_MONTH, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForNumberDivide(W3cHints.BDAY_MONTH, 12), AutofillType.Text, AutofillType.List) }, { W3cHints.BDAY_YEAR, new AutofillHintProperties( W3cHints.BDAY_YEAR, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorBdayYear(W3cHints.BDAY_YEAR), AutofillType.Text, AutofillType.List) }, { W3cHints.SEX, new AutofillHintProperties( W3cHints.SEX, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.SEX, "Other"), AutofillType.Text, AutofillType.List) }, { W3cHints.URL, new AutofillHintProperties( W3cHints.URL, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.URL, "http://google.com"), AutofillType.Text) }, { W3cHints.PHOTO, new AutofillHintProperties( W3cHints.PHOTO, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGeneratorForText(W3cHints.PHOTO, "photo{0}.jpg"), AutofillType.Text, AutofillType.List) }, { W3cHints.PREFIX_SECTION, new AutofillHintProperties( W3cHints.PREFIX_SECTION, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.PREFIX_SECTION), AutofillType.Text, AutofillType.List) }, { W3cHints.SHIPPING, new AutofillHintProperties( W3cHints.SHIPPING, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.SHIPPING), AutofillType.Text, AutofillType.List) }, { W3cHints.BILLING, new AutofillHintProperties( W3cHints.BILLING, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.BILLING), AutofillType.Text, AutofillType.List) }, { W3cHints.PREFIX_HOME, new AutofillHintProperties( W3cHints.PREFIX_HOME, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.PREFIX_HOME), AutofillType.Text, AutofillType.List) }, { W3cHints.PREFIX_WORK, new AutofillHintProperties( W3cHints.PREFIX_WORK, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.PREFIX_WORK), AutofillType.Text, AutofillType.List) }, { W3cHints.PREFIX_FAX, new AutofillHintProperties( W3cHints.PREFIX_FAX, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.PREFIX_FAX), AutofillType.Text, AutofillType.List) }, { W3cHints.PREFIX_PAGER, new AutofillHintProperties( W3cHints.PREFIX_PAGER, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.PREFIX_PAGER), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL, new AutofillHintProperties( W3cHints.TEL, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_COUNTRY_CODE, new AutofillHintProperties( W3cHints.TEL_COUNTRY_CODE, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_COUNTRY_CODE), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_NATIONAL, new AutofillHintProperties( W3cHints.TEL_NATIONAL, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_NATIONAL), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_AREA_CODE, new AutofillHintProperties( W3cHints.TEL_AREA_CODE, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_AREA_CODE), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_LOCAL, new AutofillHintProperties( W3cHints.TEL_LOCAL, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_LOCAL), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_LOCAL_PREFIX, new AutofillHintProperties( W3cHints.TEL_LOCAL_PREFIX, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_LOCAL_PREFIX), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_LOCAL_SUFFIX, new AutofillHintProperties( W3cHints.TEL_LOCAL_SUFFIX, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_LOCAL_SUFFIX), AutofillType.Text, AutofillType.List) }, { W3cHints.TEL_EXTENSION, new AutofillHintProperties( W3cHints.TEL_EXTENSION, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.TEL_EXTENSION), AutofillType.Text, AutofillType.List) }, { W3cHints.EMAIL, new AutofillHintProperties( View.AutofillHintEmailAddress, SaveDataType.Generic, PARTITION_EMAIL, new FakeFieldGeneratorForText(W3cHints.EMAIL, "email{0}"), AutofillType.Text) }, { W3cHints.IMPP, new AutofillHintProperties( W3cHints.IMPP, SaveDataType.Generic, PARTITION_OTHER, new FakeFieldGenerator(W3cHints.IMPP), AutofillType.Text, AutofillType.List) } }.ToImmutableDictionary(); private AutofillHints() { } public static bool IsValidTypeForHints(string[] hints, AutofillType type) { if (hints != null) { foreach (var hint in hints) { if (hint != null && sValidHints.ContainsKey(hint)) { var valid = sValidHints[hint].IsValidType(type); if (valid) { return true; } } } } return false; } public static bool IsValidHint(string hint) { return sValidHints.ContainsKey(hint); } public static SaveDataType GetSaveTypeForHints(string[] hints) { SaveDataType saveType = 0; if (hints != null) { foreach (string hint in hints) { if (hint != null && sValidHints.ContainsKey(hint)) { saveType |= sValidHints[hint].GetSaveType(); } } } return saveType; } public static FilledAutofillField GetFakeField(string hint, int seed) { return sValidHints[hint].GenerateFakeField(seed); } public static FilledAutofillFieldCollection GetFakeFieldCollection(int partition, int seed) { var filledAutofillFieldCollection = new FilledAutofillFieldCollection(); foreach (var hint in sValidHints.Keys) { if (hint != null && sValidHints[hint].GetPartition() == partition) { var fakeField = GetFakeField(hint, seed); filledAutofillFieldCollection.Add(fakeField); } } return filledAutofillFieldCollection; } private static string GetStoredHintName(string hint) { return sValidHints[hint].GetAutofillHint(); } public static void ConvertToStoredHintNames(string[] hints) { for (int i = 0; i < hints.Length; i++) { hints[i] = GetStoredHintName(hints[i]); } } private static string[] DayRange() { var days = new string[27]; for (int i = 0; i < days.Length; i++) { days[i] = i.ToString(); } return days; } private static string[] MonthRange() { string[] months = new string[12]; for (int i = 0; i < months.Length; i++) { months[i] = i.ToString(); } return months; } public static string[] FilterForSupportedHints(string[] hints) { var filteredHints = new string[hints.Length]; var i = 0; foreach (var hint in hints) { if (IsValidHint(hint)) { filteredHints[i++] = hint; } else { Log.Warn(CommonUtil.TAG, "Invalid autofill hint: " + hint); } } if (i == 0) { return null; } var finalFilteredHints = new string[i]; Array.Copy(filteredHints, 0, finalFilteredHints, 0, i); return finalFilteredHints; } public class FakeFieldGeneratorForText : Java.Lang.Object, IFakeFieldGenerator { public string Type; public string Text; public FakeFieldGeneratorForText(string type, string text) { Type = type; Text = text; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); filledAutofillField.SetTextValue(string.Format(Text, seed)); return filledAutofillField; } } public class FakeFieldGeneratorForNumberMultiply : Java.Lang.Object, IFakeFieldGenerator { public string Type; public int Number; public FakeFieldGeneratorForNumberMultiply(string type, int number) { Type = type; Number = number; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); filledAutofillField.SetTextValue((seed * Number).ToString()); return filledAutofillField; } } public class FakeFieldGeneratorForNumberDivide : Java.Lang.Object, IFakeFieldGenerator { public string Type; public int Number; public FakeFieldGeneratorForNumberDivide(string type, int number) { Type = type; Number = number; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); filledAutofillField.SetTextValue((seed % Number).ToString()); return filledAutofillField; } } public class FakeFieldGenerator : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGenerator(string type) { Type = type; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); return filledAutofillField; } } public class FakeFieldGeneratorForListValue : Java.Lang.Object, IFakeFieldGenerator { public string Type; public string[] Array; public FakeFieldGeneratorForListValue(string type, string[] array) { Type = type; Array = array; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); filledAutofillField.SetListValue(Array, seed % Array.Length); return filledAutofillField; } } public class FakeFieldGeneratorForDate : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGeneratorForDate(string type) { Type = type; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); - var calendar = Instance; + var calendar = Android.Icu.Util.Calendar.Instance; calendar.Set(Year, calendar.Get(Year) + seed); filledAutofillField.SetDateValue(calendar.TimeInMillis); return filledAutofillField; } } public class FakeFieldGeneratorExpirationMonth : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGeneratorExpirationMonth(string type) { Type = type; } public FilledAutofillField Generate(int seed) { var months = MonthRange(); int month = seed % months.Length; - var calendar = Instance; + var calendar = Android.Icu.Util.Calendar.Instance; calendar.Set(Month, month); var filledAutofillField = new FilledAutofillField(Type); filledAutofillField.SetListValue(months, month); filledAutofillField.SetTextValue(month.ToString()); filledAutofillField.SetDateValue(calendar.TimeInMillis); return filledAutofillField; } } public class FakeFieldGeneratorExpirationYear : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGeneratorExpirationYear(string type) { Type = type; } public FilledAutofillField Generate(int seed) { FilledAutofillField filledAutofillField = new FilledAutofillField(Type); - var calendar = Instance; + var calendar = Android.Icu.Util.Calendar.Instance; int expYear = calendar.Get(Year) + seed; calendar.Set(Year, expYear); filledAutofillField.SetDateValue(calendar.TimeInMillis); filledAutofillField.SetTextValue(expYear.ToString()); return filledAutofillField; } } public class FakeFieldGeneratorExpirationDay : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGeneratorExpirationDay(string type) { Type = type; } public FilledAutofillField Generate(int seed) { var days = DayRange(); int day = seed % days.Length; var filledAutofillField = new FilledAutofillField(Type); - var calendar = Instance; + var calendar = Android.Icu.Util.Calendar.Instance; calendar.Set(Date, day); filledAutofillField.SetListValue(days, day); filledAutofillField.SetTextValue(day.ToString()); filledAutofillField.SetDateValue(calendar.TimeInMillis); return filledAutofillField; } } public class FakeFieldGeneratorBdayYear : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGeneratorBdayYear(string type) { Type = type; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); - int year = Instance.Get(Year) - seed * 10; + int year = Android.Icu.Util.Calendar.Instance.Get(Year) - seed * 10; filledAutofillField.SetTextValue("" + year); return filledAutofillField; } } public class FakeFieldGeneratorForBirthDay : Java.Lang.Object, IFakeFieldGenerator { public string Type; public FakeFieldGeneratorForBirthDay(string type) { Type = type; } public FilledAutofillField Generate(int seed) { var filledAutofillField = new FilledAutofillField(Type); - var calendar = Instance; + var calendar = Android.Icu.Util.Calendar.Instance; calendar.Set(Year, calendar.Get(Year) - seed * 10); calendar.Set(Month, seed % 12); calendar.Set(Date, seed % 27); filledAutofillField.SetDateValue(calendar.TimeInMillis); return filledAutofillField; } } } } \ No newline at end of file diff --git a/android-o/AutofillFramework/AutofillService/AutofillService.csproj b/android-o/AutofillFramework/AutofillService/AutofillService.csproj index 7691042..663764c 100644 --- a/android-o/AutofillFramework/AutofillService/AutofillService.csproj +++ b/android-o/AutofillFramework/AutofillService/AutofillService.csproj @@ -1,251 +1,250 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{AD3AF392-F71A-4391-99B3-2ED26F60ACE0}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>AutofillService</RootNamespace> <AssemblyName>AutofillService</AssemblyName> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> - <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> <NuGetPackageImportStamp> </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <AndroidSupportedAbis>arm64-v8a;armeabi-v7a;x86</AndroidSupportedAbis> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Google.Apis.Core, Version=1.32.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL"> <HintPath>..\packages\Google.Apis.Core.1.32.1\lib\netstandard1.3\Google.Apis.Core.dll</HintPath> </Reference> <Reference Include="GoogleGson, Version=2.6.1.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\GoogleGson.2.6.1.0\lib\MonoAndroid\GoogleGson.dll</HintPath> </Reference> <Reference Include="Square.OkHttp3, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Square.OkHttp3.3.8.0\lib\MonoAndroid\Square.OkHttp3.dll</HintPath> </Reference> <Reference Include="Square.OkIO, Version=1.13.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Square.OkIO.1.13.0\lib\MonoAndroid\Square.OkIO.dll</HintPath> </Reference> <Reference Include="Square.Retrofit2, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Square.Retrofit2.2.3.0\lib\MonoAndroid\Square.Retrofit2.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Collections.Immutable, Version=1.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath> </Reference> <Reference Include="System.IO.Compression" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.11.0.1-beta1\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="System.Net.Http" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Core.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Runtime.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Runtime.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Extensions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Extensions.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Extensions.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Constraint.Layout, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Constraint.Layout.1.0.2.2\lib\MonoAndroid70\Xamarin.Android.Support.Constraint.Layout.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Constraint.Layout.Solver, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Constraint.Layout.Solver.1.0.2.2\lib\MonoAndroid70\Xamarin.Android.Support.Constraint.Layout.Solver.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Design.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Transition, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Transition.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath> </Reference> <Reference Include="Xamarin.Android.Support.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="AutofillFieldMetadata.cs" /> <Compile Include="AutofillFieldMetadataCollection.cs" /> <Compile Include="AutofillHelper.cs" /> <Compile Include="AutofillHintProperties.cs" /> <Compile Include="AutofillHints.cs" /> <Compile Include="CommonUtil.cs" /> <Compile Include="Datasource\SharedPrefsAutofillRepository.cs" /> <Compile Include="Datasource\SharedPrefsDigitalAssetLinksRepository.cs" /> <Compile Include="Datasource\SharedPrefsPackageVerificationRepository.cs" /> <Compile Include="Datasource\IAutofillDataSource.cs" /> <Compile Include="IFakeFieldGenerator.cs" /> <Compile Include="Model\FilledAutofillFieldCollection.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Model\FilledAutofillField.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Settings\MyPreferences.cs" /> <Compile Include="Settings\SettingsActivity.cs" /> <Compile Include="Datasource\IDigitalAssetLinksDataSource.cs" /> <Compile Include="Datasource\IPackageVerificationDataSource.cs" /> <Compile Include="SecurityHelper.cs" /> <Compile Include="StructureParser.cs" /> <Compile Include="W3cHints.cs" /> <Compile Include="AuthActivity.cs" /> <Compile Include="MyAutofillService.cs" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="packages.config" /> <AndroidResource Include="Resources\raw\default_field_types" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\mipmap-hdpi\Icon.png" /> <AndroidResource Include="Resources\mipmap-mdpi\Icon.png" /> <AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" /> <AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" /> <AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\Colors.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_add_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_delete_forever_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_lock_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\ic_person_black_24dp.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\Dimens.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\Styles.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\list_divider.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\xml\multidataset_service.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\multidataset_service_auth_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\multidataset_service_list_item.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\multidataset_service_settings_activity.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\multidataset_service_settings_add_data_dialog.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\multidataset_service_settings_authentication_dialog.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Runtime.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Runtime.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Extensions.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Extensions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Extensions.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Extensions.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Core.Runtime.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Runtime.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Extensions.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Extensions.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Extensions.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Extensions.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Transition.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Transition.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Design.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Design.targets')" /> </Project> \ No newline at end of file
dotnet/android-samples
eb0e85d2d675322ec7173eb676f6dbf5af93ab02
Expose private nested types that are exposed in public API. (#316)
diff --git a/OsmDroidBindingExample/OsmDroidBinding/Transforms/Metadata.xml b/OsmDroidBindingExample/OsmDroidBinding/Transforms/Metadata.xml index 9572f6b..a36df90 100755 --- a/OsmDroidBindingExample/OsmDroidBinding/Transforms/Metadata.xml +++ b/OsmDroidBindingExample/OsmDroidBinding/Transforms/Metadata.xml @@ -1,62 +1,64 @@ <metadata> <!-- fixup the namespaces, notice that we have to do one for each namespace. --> <attr path="/api/package[@name='org.osmdroid']" name="managedName">OsmDroid</attr> <attr path="/api/package[@name='org.osmdroid.api']" name="managedName">OsmDroid.Api</attr> <attr path="/api/package[@name='org.osmdroid.contributor']" name="managedName">OsmDroid.Contributor</attr> <attr path="/api/package[@name='org.osmdroid.contributor.util']" name="managedName">OsmDroid.Contributor.Util</attr> <attr path="/api/package[@name='org.osmdroid.contributor.util.constants']" name="managedName">OsmDroid.Util.Constants</attr> <attr path="/api/package[@name='org.osmdroid.events']" name="managedName">OsmDroid.Events</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider']" name="managedName">OsmDroid.TileProvider</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider.constants']" name="managedName">OsmDroid.TileProvider.Constants</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider.modules']" name="managedName">OsmDroid.TileProvider.Modules</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider.tilesource']" name="managedName">OsmDroid.TileProvider.TileSource</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider.util']" name="managedName">OsmDroid.TileProvider.Util</attr> <attr path="/api/package[@name='org.osmdroid.util']" name="managedName">OsmDroid.Util</attr> <attr path="/api/package[@name='org.osmdroid.views']" name="managedName">OsmDroid.Views</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay']" name="managedName">OsmDroid.Views.Overlay</attr> <attr path="/api/package[@name='org.osmdroid.views.util.constants']" name="managedName">OsmDroid.Views.Util.Constants</attr> <attr path="/api/package[@name='org.osmdroid.bonuspack.overlays']" name="managedName">OsmDroid.Bonuspack.Overlays</attr> <attr path="/api/package[@name='org.osmdroid.bonuspack.routing']" name="managedName">OsmDroid.Bonuspack.Routing</attr> <!-- different scoping rules in .NET, so we make these public --> <attr path="/api/package[@name='org.osmdroid.tileprovider.modules']/class[@name='MapTileModuleProviderBase.TileLoader']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider.modules']/class[@name='MapTileModuleProviderBase.TileLoader']/method[@name='loadTile']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider']/class[@name='MapTileProviderBase.ScaleTileLooper']/method[@name='handleTile']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider']/class[@name='MapTileProviderBase.ZoomInTileLooper']/method[@name='handleTile']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.tileprovider']/class[@name='MapTileProviderBase.ZoomOutTileLooper']/method[@name='handleTile']" name="visibility">public</attr> + <attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapControllerOld.CosinusalBasedAnimationRunner']" name="visibility">public</attr> + <attr path="/api/package[@name='org.osmdroid.events']/class[@name='DelayedMapListener.CallbackTask']" name="visibility">public</attr> <!-- Draw() seems to be public for android so we need to be consistent about it. C# doesn't like to mix visibility during inheritance. --> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='Overlay']/method[@name='draw']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='TilesOverlay']/method[@name='draw']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='PathOverlay']/method[@name='draw']" name="visibility">public</attr> <!-- added for 4.2 jar --> <attr path="/api/package[@name='org.osmdroid.views.overlay.compass']/class[@name='CompassOverlay']/method[@name='draw']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay.mylocation']/class[@name='MyLocationNewOverlay']/method[@name='draw']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='ItemizedOverlay']/method[@name='draw']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='NonAcceleratedOverlay']/method[@name='draw']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='ScaleBarOverlay']/method[@name='draw']" name="visibility">public</attr> <remove-node path="/api/package[@name='org.osmdroid.tileprovider.tilesource']/class[@name='CloudmadeTileSource']" /> <!-- Return Object in OverlayManager.Get(int) so that we match ArrayList. --> <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='OverlayManager']/method[@name='get' and count(parameter)=1 and parameter[1][@type='int']]" name="managedReturn"> Java.Lang.Object </attr> <!-- Return IMapController in MapView.Controller so that we match IMapView. --> <attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapView']/method[@name='getController']" name="managedReturn"> OsmDroid.Api.IMapController </attr> <!-- We need to rename class MapView.Projection because it conflicts with a property of the same name --> <attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapView.Projection']" name="managedName"> MapView.ProjectionImpl </attr> <!-- Change return type to match IMapView.Projection property return type --> <attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapView']/method[@name='getProjection']" name="managedReturn"> OsmDroid.Api.IProjection </attr> <!-- fix up some parameter names --> <attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapView']/method[@name='setTileSource']/parameter[@name='p0']" name="name">tileSource</attr> <attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapView']/method[@name='setBuiltInZoomControls']/parameter[@name='p0']" name="name">show</attr> <attr path="/api/package[@name='org.osmdroid.api']/interface[@name='IMapController']/method[@name='setZoom']/parameter[@name='p0']" name="name">zoomLevel</attr> <attr path="/api/package[@name='org.osmdroid.api']/interface[@name='IMapController']/method[@name='setCenter']/parameter[@name='p0']" name="name">centreOfMap</attr> <attr path="/api/package[@name='org.osmdroid.bonuspack.routing']/class[@name='RoadLink']" name="visibility">public</attr> <attr path="/api/package[@name='org.osmdroid.bonuspack.overlays']/class[@name='MapEventsOverlay']/method[@name='draw']" name="visibility">public</attr> </metadata> \ No newline at end of file diff --git a/android5.0/GoogleIO2014Master/AndroidSvg/Transforms/Metadata.xml b/android5.0/GoogleIO2014Master/AndroidSvg/Transforms/Metadata.xml index 0fd6ba3..044c959 100644 --- a/android5.0/GoogleIO2014Master/AndroidSvg/Transforms/Metadata.xml +++ b/android5.0/GoogleIO2014Master/AndroidSvg/Transforms/Metadata.xml @@ -1,31 +1,32 @@ <metadata> <!-- This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask: <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" /> This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground: <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" /> --> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='CSSParser.Selector']" name="managedName">SelectorClass</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.Colour']" name="managedName">ColourClass</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.SolidColor']" name="managedName">SolidColourClass</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVGParser.TextScanner']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.SvgElementBase']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.SvgObject']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.Length']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.Unit']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.Style']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/interface[@name='SVG.SvgContainer']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.CSSClipRect']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.Colour']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.SvgPaint']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.Box']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.PathDefinition']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/interface[@name='SVG.PathInterface']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.TextContainer']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.SvgConditionalContainer']" name="visibility">public</attr> <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='SVG.SvgElement']" name="visibility">public</attr> + <attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='CSSParser.AttribOp']" name="visibility">public</attr> </metadata>
dotnet/android-samples
7bad1e2e99a2ed8af4cb40bcd759b55fed374985
[Button] Add uses-sdk to manifest
diff --git a/Button/Properties/AndroidManifest.xml b/Button/Properties/AndroidManifest.xml index 6c63bcd..fa0e6ab 100644 --- a/Button/Properties/AndroidManifest.xml +++ b/Button/Properties/AndroidManifest.xml @@ -1,3 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="mono.samples.button"> + <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" /> </manifest>
dotnet/android-samples
b7c57025a7395900f70da230b5a713d2884cf048
[recyclerview] better OO, formatting (#310)
diff --git a/android5.0/RecyclerViewer/RecyclerViewer/MainActivity.cs b/android5.0/RecyclerViewer/RecyclerViewer/MainActivity.cs index 89be8e0..a48de99 100644 --- a/android5.0/RecyclerViewer/RecyclerViewer/MainActivity.cs +++ b/android5.0/RecyclerViewer/RecyclerViewer/MainActivity.cs @@ -1,181 +1,181 @@ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Support.V7.Widget; using System.Collections.Generic; namespace RecyclerViewer -{ - [Activity (Label = "RecyclerViewer", MainLauncher = true, Icon = "@drawable/icon", - Theme = "@android:style/Theme.Material.Light.DarkActionBar")] - public class MainActivity : Activity - { - // RecyclerView instance that displays the photo album: - RecyclerView mRecyclerView; - - // Layout manager that lays out each card in the RecyclerView: - RecyclerView.LayoutManager mLayoutManager; - - // Adapter that accesses the data set (a photo album): - PhotoAlbumAdapter mAdapter; +{ + [Activity(Label = "RecyclerViewer", MainLauncher = true, Icon = "@drawable/icon", + Theme = "@android:style/Theme.Material.Light.DarkActionBar")] + public class MainActivity : Activity + { + // RecyclerView instance that displays the photo album: + RecyclerView mRecyclerView; + + // Layout manager that lays out each card in the RecyclerView: + RecyclerView.LayoutManager mLayoutManager; + + // Adapter that accesses the data set (a photo album): + PhotoAlbumAdapter mAdapter; // Photo album that is managed by the adapter: - PhotoAlbum mPhotoAlbum; - - protected override void OnCreate (Bundle bundle) - { - base.OnCreate (bundle); + PhotoAlbum mPhotoAlbum; + + protected override void OnCreate(Bundle bundle) + { + base.OnCreate(bundle); // Instantiate the photo album: - mPhotoAlbum = new PhotoAlbum(); - - // Set our view from the "main" layout resource: - SetContentView (Resource.Layout.Main); - - // Get our RecyclerView layout: - mRecyclerView = FindViewById<RecyclerView> (Resource.Id.recyclerView); - - //............................................................ - // Layout Manager Setup: - - // Use the built-in linear layout manager: - mLayoutManager = new LinearLayoutManager (this); + mPhotoAlbum = new PhotoAlbum(); + + // Set our view from the "main" layout resource: + SetContentView(Resource.Layout.Main); + + // Get our RecyclerView layout: + mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView); + + //............................................................ + // Layout Manager Setup: + + // Use the built-in linear layout manager: + mLayoutManager = new LinearLayoutManager(this); // Or use the built-in grid layout manager (two horizontal rows): // mLayoutManager = new GridLayoutManager // (this, 2, GridLayoutManager.Horizontal, false); // Plug the layout manager into the RecyclerView: - mRecyclerView.SetLayoutManager (mLayoutManager); - - //............................................................ - // Adapter Setup: - - // Create an adapter for the RecyclerView, and pass it the - // data set (the photo album) to manage: - mAdapter = new PhotoAlbumAdapter (mPhotoAlbum); + mRecyclerView.SetLayoutManager(mLayoutManager); + + //............................................................ + // Adapter Setup: + + // Create an adapter for the RecyclerView, and pass it the + // data set (the photo album) to manage: + mAdapter = new PhotoAlbumAdapter(mPhotoAlbum); // Register the item click handler (below) with the adapter: - mAdapter.ItemClick += OnItemClick; - - // Plug the adapter into the RecyclerView: - mRecyclerView.SetAdapter (mAdapter); + mAdapter.ItemClick += OnItemClick; + + // Plug the adapter into the RecyclerView: + mRecyclerView.SetAdapter(mAdapter); //............................................................ // Random Pick Button: // Get the button for randomly swapping a photo: Button randomPickBtn = FindViewById<Button>(Resource.Id.randPickButton); // Handler for the Random Pick Button: randomPickBtn.Click += delegate { if (mPhotoAlbum != null) { // Randomly swap a photo with the top: int idx = mPhotoAlbum.RandomSwap(); // Update the RecyclerView by notifying the adapter: // Notify that the top and a randomly-chosen photo has changed (swapped): mAdapter.NotifyItemChanged(0); mAdapter.NotifyItemChanged(idx); } - }; - } + }; + } // Handler for the item click event: - void OnItemClick (object sender, int position) + void OnItemClick(object sender, int position) { // Display a toast that briefly shows the enumeration of the selected photo: int photoNum = position + 1; Toast.MakeText(this, "This is photo number " + photoNum, ToastLength.Short).Show(); - } - } + } + } //---------------------------------------------------------------------- // VIEW HOLDER // Implement the ViewHolder pattern: each ViewHolder holds references // to the UI components (ImageView and TextView) within the CardView // that is displayed in a row of the RecyclerView: public class PhotoViewHolder : RecyclerView.ViewHolder { public ImageView Image { get; private set; } public TextView Caption { get; private set; } // Get references to the views defined in the CardView layout. - public PhotoViewHolder (View itemView, Action<int> listener) - : base (itemView) + public PhotoViewHolder(View itemView, Action<int> listener) + : base(itemView) { // Locate and cache view references: - Image = itemView.FindViewById<ImageView> (Resource.Id.imageView); - Caption = itemView.FindViewById<TextView> (Resource.Id.textView); + Image = itemView.FindViewById<ImageView>(Resource.Id.imageView); + Caption = itemView.FindViewById<TextView>(Resource.Id.textView); // Detect user clicks on the item view and report which item // was clicked (by layout position) to the listener: - itemView.Click += (sender, e) => listener (base.LayoutPosition); + itemView.Click += (sender, e) => listener(base.LayoutPosition); } } //---------------------------------------------------------------------- // ADAPTER // Adapter to connect the data set (photo album) to the RecyclerView: public class PhotoAlbumAdapter : RecyclerView.Adapter { // Event handler for item clicks: public event EventHandler<int> ItemClick; // Underlying data set (a photo album): - public PhotoAlbum mPhotoAlbum; + PhotoAlbum mPhotoAlbum; // Load the adapter with the data set (photo album) at construction time: - public PhotoAlbumAdapter (PhotoAlbum photoAlbum) + public PhotoAlbumAdapter(PhotoAlbum photoAlbum) { mPhotoAlbum = photoAlbum; } // Create a new photo CardView (invoked by the layout manager): - public override RecyclerView.ViewHolder - OnCreateViewHolder (ViewGroup parent, int viewType) + public override RecyclerView.ViewHolder + OnCreateViewHolder(ViewGroup parent, int viewType) { // Inflate the CardView for the photo: - View itemView = LayoutInflater.From (parent.Context). - Inflate (Resource.Layout.PhotoCardView, parent, false); + View itemView = LayoutInflater.From(parent.Context). + Inflate(Resource.Layout.PhotoCardView, parent, false); // Create a ViewHolder to find and hold these view references, and // register OnClick with the view holder: - PhotoViewHolder vh = new PhotoViewHolder (itemView, OnClick); + PhotoViewHolder vh = new PhotoViewHolder(itemView, OnClick); return vh; } // Fill in the contents of the photo card (invoked by the layout manager): - public override void - OnBindViewHolder (RecyclerView.ViewHolder holder, int position) + public override void + OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { PhotoViewHolder vh = holder as PhotoViewHolder; // Set the ImageView and TextView in this ViewHolder's CardView // from this position in the photo album: - vh.Image.SetImageResource (mPhotoAlbum[position].PhotoID); + vh.Image.SetImageResource(mPhotoAlbum[position].PhotoID); vh.Caption.Text = mPhotoAlbum[position].Caption; } // Return the number of photos available in the photo album: public override int ItemCount { get { return mPhotoAlbum.NumPhotos; } } // Raise an event when the item-click takes place: - void OnClick (int position) + void OnClick(int position) { if (ItemClick != null) - ItemClick (this, position); + ItemClick(this, position); } } } diff --git a/android5.0/RecyclerViewer/RecyclerViewer/PhotoAlbum.cs b/android5.0/RecyclerViewer/RecyclerViewer/PhotoAlbum.cs index 459e1a5..d3f98ff 100644 --- a/android5.0/RecyclerViewer/RecyclerViewer/PhotoAlbum.cs +++ b/android5.0/RecyclerViewer/RecyclerViewer/PhotoAlbum.cs @@ -1,179 +1,173 @@ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Support.V7.Widget; using System.Collections.Generic; namespace RecyclerViewer { // Photo: contains image resource ID and caption: public class Photo { - // Photo ID for this photo: - public int mPhotoID; - - // Caption text for this photo: - public string mCaption; - - // Return the ID of the photo: - public int PhotoID - { - get { return mPhotoID; } - } + public Photo(int id, string caption) + { + PhotoID = id; + Caption = caption; + } + + // Return the ID of the photo: + public int PhotoID { get; } // Return the Caption of the photo: - public string Caption - { - get { return mCaption; } - } + public string Caption { get; } } // Photo album: holds image resource IDs and caption: public class PhotoAlbum { // Built-in photo collection - this could be replaced with // a photo database: static Photo[] mBuiltInPhotos = { - new Photo { mPhotoID = Resource.Drawable.buckingham_guards, - mCaption = "Buckingham Palace" }, - new Photo { mPhotoID = Resource.Drawable.la_tour_eiffel, - mCaption = "The Eiffel Tower" }, - new Photo { mPhotoID = Resource.Drawable.louvre_1, - mCaption = "The Louvre" }, - new Photo { mPhotoID = Resource.Drawable.before_mobile_phones, - mCaption = "Before mobile phones" }, - new Photo { mPhotoID = Resource.Drawable.big_ben_1, - mCaption = "Big Ben skyline" }, - new Photo { mPhotoID = Resource.Drawable.big_ben_2, - mCaption = "Big Ben from below" }, - new Photo { mPhotoID = Resource.Drawable.london_eye, - mCaption = "The London Eye" }, - new Photo { mPhotoID = Resource.Drawable.eurostar, - mCaption = "Eurostar Train" }, - new Photo { mPhotoID = Resource.Drawable.arc_de_triomphe, - mCaption = "Arc de Triomphe" }, - new Photo { mPhotoID = Resource.Drawable.louvre_2, - mCaption = "Inside the Louvre" }, - new Photo { mPhotoID = Resource.Drawable.versailles_fountains, - mCaption = "Versailles fountains" }, - new Photo { mPhotoID = Resource.Drawable.modest_accomodations, - mCaption = "Modest accomodations" }, - new Photo { mPhotoID = Resource.Drawable.notre_dame, - mCaption = "Notre Dame" }, - new Photo { mPhotoID = Resource.Drawable.inside_notre_dame, - mCaption = "Inside Notre Dame" }, - new Photo { mPhotoID = Resource.Drawable.seine_river, - mCaption = "The Seine" }, - new Photo { mPhotoID = Resource.Drawable.rue_cler, - mCaption = "Rue Cler" }, - new Photo { mPhotoID = Resource.Drawable.champ_elysees, - mCaption = "The Avenue des Champs-Elysees" }, - new Photo { mPhotoID = Resource.Drawable.seine_barge, - mCaption = "Seine barge" }, - new Photo { mPhotoID = Resource.Drawable.versailles_gates, - mCaption = "Gates of Versailles" }, - new Photo { mPhotoID = Resource.Drawable.edinburgh_castle_2, - mCaption = "Edinburgh Castle" }, - new Photo { mPhotoID = Resource.Drawable.edinburgh_castle_1, - mCaption = "Edinburgh Castle up close" }, - new Photo { mPhotoID = Resource.Drawable.old_meets_new, - mCaption = "Old meets new" }, - new Photo { mPhotoID = Resource.Drawable.edinburgh_from_on_high, - mCaption = "Edinburgh from on high" }, - new Photo { mPhotoID = Resource.Drawable.edinburgh_station, - mCaption = "Edinburgh station" }, - new Photo { mPhotoID = Resource.Drawable.scott_monument, - mCaption = "Scott Monument" }, - new Photo { mPhotoID = Resource.Drawable.view_from_holyrood_park, - mCaption = "View from Holyrood Park" }, - new Photo { mPhotoID = Resource.Drawable.tower_of_london, - mCaption = "Outside the Tower of London" }, - new Photo { mPhotoID = Resource.Drawable.tower_visitors, - mCaption = "Tower of London visitors" }, - new Photo { mPhotoID = Resource.Drawable.one_o_clock_gun, - mCaption = "One O'Clock Gun" }, - new Photo { mPhotoID = Resource.Drawable.victoria_albert, - mCaption = "Victoria and Albert Museum" }, - new Photo { mPhotoID = Resource.Drawable.royal_mile, - mCaption = "The Royal Mile" }, - new Photo { mPhotoID = Resource.Drawable.museum_and_castle, - mCaption = "Edinburgh Museum and Castle" }, - new Photo { mPhotoID = Resource.Drawable.portcullis_gate, - mCaption = "Portcullis Gate" }, - new Photo { mPhotoID = Resource.Drawable.to_notre_dame, - mCaption = "Left or right?" }, - new Photo { mPhotoID = Resource.Drawable.pompidou_centre, - mCaption = "Pompidou Centre" }, - new Photo { mPhotoID = Resource.Drawable.heres_lookin_at_ya, - mCaption = "Here's Lookin' at Ya!" }, + new Photo ( Resource.Drawable.buckingham_guards, + "Buckingham Palace" ), + new Photo ( Resource.Drawable.la_tour_eiffel, + "The Eiffel Tower" ), + new Photo ( Resource.Drawable.louvre_1, + "The Louvre" ), + new Photo ( Resource.Drawable.before_mobile_phones, + "Before mobile phones" ), + new Photo ( Resource.Drawable.big_ben_1, + "Big Ben skyline" ), + new Photo ( Resource.Drawable.big_ben_2, + "Big Ben from below" ), + new Photo ( Resource.Drawable.london_eye, + "The London Eye" ), + new Photo ( Resource.Drawable.eurostar, + "Eurostar Train" ), + new Photo ( Resource.Drawable.arc_de_triomphe, + "Arc de Triomphe" ), + new Photo ( Resource.Drawable.louvre_2, + "Inside the Louvre" ), + new Photo ( Resource.Drawable.versailles_fountains, + "Versailles fountains" ), + new Photo ( Resource.Drawable.modest_accomodations, + "Modest accomodations" ), + new Photo ( Resource.Drawable.notre_dame, + "Notre Dame" ), + new Photo ( Resource.Drawable.inside_notre_dame, + "Inside Notre Dame" ), + new Photo ( Resource.Drawable.seine_river, + "The Seine" ), + new Photo ( Resource.Drawable.rue_cler, + "Rue Cler" ), + new Photo ( Resource.Drawable.champ_elysees, + "The Avenue des Champs-Elysees" ), + new Photo ( Resource.Drawable.seine_barge, + "Seine barge" ), + new Photo ( Resource.Drawable.versailles_gates, + "Gates of Versailles" ), + new Photo ( Resource.Drawable.edinburgh_castle_2, + "Edinburgh Castle" ), + new Photo ( Resource.Drawable.edinburgh_castle_1, + "Edinburgh Castle up close" ), + new Photo ( Resource.Drawable.old_meets_new, + "Old meets new" ), + new Photo ( Resource.Drawable.edinburgh_from_on_high, + "Edinburgh from on high" ), + new Photo ( Resource.Drawable.edinburgh_station, + "Edinburgh station" ), + new Photo ( Resource.Drawable.scott_monument, + "Scott Monument" ), + new Photo ( Resource.Drawable.view_from_holyrood_park, + "View from Holyrood Park" ), + new Photo ( Resource.Drawable.tower_of_london, + "Outside the Tower of London" ), + new Photo ( Resource.Drawable.tower_visitors, + "Tower of London visitors" ), + new Photo ( Resource.Drawable.one_o_clock_gun, + "One O'Clock Gun" ), + new Photo ( Resource.Drawable.victoria_albert, + "Victoria and Albert Museum" ), + new Photo ( Resource.Drawable.royal_mile, + "The Royal Mile" ), + new Photo ( Resource.Drawable.museum_and_castle, + "Edinburgh Museum and Castle" ), + new Photo ( Resource.Drawable.portcullis_gate, + "Portcullis Gate" ), + new Photo ( Resource.Drawable.to_notre_dame, + "Left or right?" ), + new Photo ( Resource.Drawable.pompidou_centre, + "Pompidou Centre" ), + new Photo ( Resource.Drawable.heres_lookin_at_ya, + "Here's Lookin' at Ya!" ), }; // Array of photos that make up the album: private Photo[] mPhotos; // Random number generator for shuffling the photos: Random mRandom; // Create an instance copy of the built-in photo list and // create the random number generator: - public PhotoAlbum () + public PhotoAlbum() { mPhotos = mBuiltInPhotos; mRandom = new Random(); } // Return the number of photos in the photo album: - public int NumPhotos - { - get { return mPhotos.Length; } + public int NumPhotos + { + get { return mPhotos.Length; } } // Indexer (read only) for accessing a photo: - public Photo this[int i] + public Photo this[int i] { get { return mPhotos[i]; } } // Pick a random photo and swap it with the top: public int RandomSwap() { // Save the photo at the top: Photo tmpPhoto = mPhotos[0]; // Generate a next random index between 1 and // Length (noninclusive): int rnd = mRandom.Next(1, mPhotos.Length); // Exchange top photo with randomly-chosen photo: mPhotos[0] = mPhotos[rnd]; mPhotos[rnd] = tmpPhoto; // Return the index of which photo was swapped with the top: return rnd; } // Shuffle the order of the photos: - public void Shuffle () - { - // Use the Fisher-Yates shuffle algorithm: + public void Shuffle() + { + // Use the Fisher-Yates shuffle algorithm: for (int idx = 0; idx < mPhotos.Length; ++idx) { // Save the photo at idx: Photo tmpPhoto = mPhotos[idx]; // Generate a next random index between idx (inclusive) and // Length (noninclusive): int rnd = mRandom.Next(idx, mPhotos.Length); // Exchange photo at idx with randomly-chosen (later) photo: mPhotos[idx] = mPhotos[rnd]; mPhotos[rnd] = tmpPhoto; } } } } diff --git a/android5.0/RecyclerViewer/RecyclerViewer/Properties/AndroidManifest.xml b/android5.0/RecyclerViewer/RecyclerViewer/Properties/AndroidManifest.xml index 0e48255..9a812f7 100644 --- a/android5.0/RecyclerViewer/RecyclerViewer/Properties/AndroidManifest.xml +++ b/android5.0/RecyclerViewer/RecyclerViewer/Properties/AndroidManifest.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="RecyclerViewer.RecyclerViewer"> - <uses-sdk /> - <application android:label="RecyclerViewer" android:hardwareAccelerated="true"> - </application> -</manifest> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="2.0" package="RecyclerViewer.RecyclerViewer"> + <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" /> + <application android:label="RecyclerViewer" android:hardwareAccelerated="true"></application> +</manifest> \ No newline at end of file diff --git a/android5.0/RecyclerViewer/RecyclerViewer/RecyclerViewer.csproj b/android5.0/RecyclerViewer/RecyclerViewer/RecyclerViewer.csproj index 8dbf62a..62ff00d 100644 --- a/android5.0/RecyclerViewer/RecyclerViewer/RecyclerViewer.csproj +++ b/android5.0/RecyclerViewer/RecyclerViewer/RecyclerViewer.csproj @@ -1,179 +1,178 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectGuid>{C7F5D818-C203-47A2-AFB4-60078932730E}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>RecyclerViewer</RootNamespace> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidApplication>True</AndroidApplication> - <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <AssemblyName>RecyclerViewer</AssemblyName> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v4.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.CardView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.CardView.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath> <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="PhotoAlbum.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\layout\PhotoCardView.axml" /> <AndroidResource Include="Resources\drawable\big_ben_1.jpg" /> <AndroidResource Include="Resources\drawable\big_ben_2.jpg" /> <AndroidResource Include="Resources\drawable\buckingham_guards.jpg" /> <AndroidResource Include="Resources\drawable\eurostar.jpg" /> <AndroidResource Include="Resources\drawable\la_tour_eiffel.jpg" /> <AndroidResource Include="Resources\drawable\london_eye.jpg" /> <AndroidResource Include="Resources\drawable\louvre_1.jpg" /> <AndroidResource Include="Resources\drawable\louvre_2.jpg" /> <AndroidResource Include="Resources\drawable\tower_of_london.jpg" /> <AndroidResource Include="Resources\drawable\tower_visitors.jpg" /> <AndroidResource Include="Resources\drawable\victoria_albert.jpg" /> <AndroidResource Include="Resources\drawable\before_mobile_phones.jpg" /> <AndroidResource Include="Resources\drawable\downtown_edinburgh.jpg" /> <AndroidResource Include="Resources\drawable\edinburgh_castle_1.jpg" /> <AndroidResource Include="Resources\drawable\edinburgh_castle_2.jpg" /> <AndroidResource Include="Resources\drawable\edinburgh_from_on_high.jpg" /> <AndroidResource Include="Resources\drawable\edinburgh_station.jpg" /> <AndroidResource Include="Resources\drawable\heres_lookin_at_ya.jpg" /> <AndroidResource Include="Resources\drawable\inside_notre_dame.jpg" /> <AndroidResource Include="Resources\drawable\medieval_siege_gun.jpg" /> <AndroidResource Include="Resources\drawable\modest_accomodations.jpg" /> <AndroidResource Include="Resources\drawable\museum_and_castle.jpg" /> <AndroidResource Include="Resources\drawable\notre_dame.jpg" /> <AndroidResource Include="Resources\drawable\old_meets_new.jpg" /> <AndroidResource Include="Resources\drawable\one_o_clock_gun.jpg" /> <AndroidResource Include="Resources\drawable\pompidou_centre.jpg" /> <AndroidResource Include="Resources\drawable\portcullis_gate.jpg" /> <AndroidResource Include="Resources\drawable\royal_mile.jpg" /> <AndroidResource Include="Resources\drawable\rue_cler.jpg" /> <AndroidResource Include="Resources\drawable\scott_monument.jpg" /> <AndroidResource Include="Resources\drawable\seine_barge.jpg" /> <AndroidResource Include="Resources\drawable\to_notre_dame.jpg" /> <AndroidResource Include="Resources\drawable\versailles_fountains.jpg" /> <AndroidResource Include="Resources\drawable\versailles_gates.jpg" /> <AndroidResource Include="Resources\drawable\view_from_holyrood_park.jpg" /> <AndroidResource Include="Resources\drawable\champ_elysees.jpg" /> <AndroidResource Include="Resources\drawable\seine_river.jpg" /> <AndroidResource Include="Resources\drawable\arc_de_triomphe.jpg" /> </ItemGroup> - <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> + <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" /> </Project>
dotnet/android-samples
8833a661715d28652b01af1e2d52cd98bb99f7a9
[ViewPagerIndicatorBinding] Bump minSdkVersion to 16
diff --git a/ViewPagerIndicatorBinding/ViewPagerIndicator-Example/Properties/AndroidManifest.xml b/ViewPagerIndicatorBinding/ViewPagerIndicator-Example/Properties/AndroidManifest.xml index 41b67de..12ba329 100644 --- a/ViewPagerIndicatorBinding/ViewPagerIndicator-Example/Properties/AndroidManifest.xml +++ b/ViewPagerIndicatorBinding/ViewPagerIndicator-Example/Properties/AndroidManifest.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="ViewPagerIndicator_Example.ViewPagerIndicator_Example"> - <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" /> + <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" /> <application android:label="ViewPagerIndicator-Example"> </application> </manifest> \ No newline at end of file
dotnet/android-samples
902fe83a3a0e9400077d85e7ad51f0cd0b449829
[CalendarDemo] fix for aapt2 (which is now default) (#306)
diff --git a/CalendarDemo/Resources/layout/CalendarList.axml b/CalendarDemo/Resources/layout/CalendarList.axml index 4296187..d08020d 100644 --- a/CalendarDemo/Resources/layout/CalendarList.axml +++ b/CalendarDemo/Resources/layout/CalendarList.axml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView - android:id="@android:id/android:list" + android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> diff --git a/CalendarDemo/Resources/layout/EventList.axml b/CalendarDemo/Resources/layout/EventList.axml index 15c8f62..b85f2d2 100644 --- a/CalendarDemo/Resources/layout/EventList.axml +++ b/CalendarDemo/Resources/layout/EventList.axml @@ -1,15 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView - android:id="@android:id/android:list" + android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/addSampleEvent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Add Sample Event" /> </LinearLayout>
dotnet/android-samples
97fa7ebffdbbbe8512e738229cc582a2f6fa40da
[gridlayout] fix readme image link
diff --git a/GridLayoutDemo/README.md b/GridLayoutDemo/README.md index 26b566c..b75f4be 100644 --- a/GridLayoutDemo/README.md +++ b/GridLayoutDemo/README.md @@ -1,18 +1,18 @@ --- name: Xamarin.Android - GridLayout Demo description: "How to use a GridLayout (Android Ice Cream Sandwich)" page_type: sample languages: - csharp products: - xamarin extensions: tags: - androidicecreamsandwich urlFragment: gridlayoutdemo --- # GridLayout Demo This example shows how to use a GridLayout with Xamarin.Android and Ice Cream Sandwich. -![Android screen with grid layout](Screenshnots/screenshot.png) +![Android screen with grid layout](Screenshots/screenshot.png)
dotnet/android-samples
68f06e7a4d2584decb3889786761a5045623eb6b
[rotation] remove duplicate sample
diff --git a/RotationDemo/README.md b/RotationDemo/README.md index 59769ca..e62d522 100644 --- a/RotationDemo/README.md +++ b/RotationDemo/README.md @@ -1,17 +1,5 @@ ---- -name: Xamarin.Android - Rotation Demo -description: This is the sample code for the article Handling Rotation. It shows various techniques for working with device orientation changes in Mono for... -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: rotationdemo ---- # Rotation Demo -This is the sample code for the article [Handling Rotation](https://docs.microsoft.com/xamarin/android/app-fundamentals/handling-rotation). +Use [ApplicationFundamentals/RotationDemo](https://github.com/xamarin/monodroid-samples/tree/master/ApplicationFundamentals/RotationDemo/RotationDemo) instead. -It shows various techniques for working with device orientation changes in Mono for Android. - -![Two Android screens with horizontal and vertical alignment](Screenshots/RotationDemo.png) \ No newline at end of file +See the article [Handling Rotation](https://docs.microsoft.com/xamarin/android/app-fundamentals/handling-rotation) for more information
dotnet/android-samples
8a8356af920883a755d50e1c0afa00d359b5fa31
[gl] disambiguate samples with same 'name'
diff --git a/TexturedCubeES30-1.0/README.md b/TexturedCubeES30-1.0/README.md index 0a14b7d..3d12852 100644 --- a/TexturedCubeES30-1.0/README.md +++ b/TexturedCubeES30-1.0/README.md @@ -1,16 +1,16 @@ --- -name: Xamarin.Android - GL Textured Cube +name: Xamarin.Android - GL Textured Cube ES30 description: "This sample demonstrates a rotating cube rendered with textures via OpenTK's GL APIs." page_type: sample languages: - csharp products: - xamarin urlFragment: texturedcubees30-10 --- # GL Textured Cube This sample demonstrates a rotating cube rendered with textures via OpenTK's GL APIs. ![App showing a 3D cube](Screenshots/plain.png) \ No newline at end of file
dotnet/android-samples
cc191f34893796aa3012132ebeaa73ba09de21a3
[local-notifications] fix screenshot link on samplepage
diff --git a/LocalNotifications/README.md b/LocalNotifications/README.md index f948ca3..6c90ea3 100644 --- a/LocalNotifications/README.md +++ b/LocalNotifications/README.md @@ -1,20 +1,20 @@ --- name: Xamarin.Android - Android Local Notifications Sample -description: This sample app accompanies the article, Walkthrough - Using Local Notifications in Xamarin.Android. +description: This sample app accompanies the article Using Local Notifications in Xamarin.Android. page_type: sample languages: - csharp products: - xamarin urlFragment: localnotifications --- # Android Local Notifications Sample This sample app accompanies the article, -[Walkthrough - Using Local Notifications in Xamarin.Android](https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/notifications/local-notifications-walkthrough). +[Walkthrough - Using Local Notifications in Xamarin.Android](https://docs.microsoft.com/xamarin/android/app-fundamentals/notifications/local-notifications-walkthrough). -![Android app screenshot](Screenshots/screenshots.png) +![Android app screenshot](Screenshots/screenshot-1.png) When you tap the button displayed in the MainActivity screen, a notification is created. When you tap the notification, it takes you to a SecondActivity screen.
dotnet/android-samples
0da16a3fccbb26653ed034fe132e7ec8c1bc3e4a
Fix duplicate sample GUID
diff --git a/AccessoryViews/AccessoryViews.csproj b/AccessoryViews/AccessoryViews.csproj index 2bdd6c4..6887204 100644 --- a/AccessoryViews/AccessoryViews.csproj +++ b/AccessoryViews/AccessoryViews.csproj @@ -1,84 +1,84 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{5D679FF9-CD92-445D-9E69-0EA807946575}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>AccessoryViews</RootNamespace> <AssemblyName>AccessoryViews</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>False</DeployExternal> <AndroidStoreUncompressedFileExtensions /> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="TableItem.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup /> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> <AndroidResource Include="Resources\Drawable\Bulbs.jpg" /> <AndroidResource Include="Resources\Drawable\FlowerBuds.jpg" /> <AndroidResource Include="Resources\Drawable\Fruits.jpg" /> <AndroidResource Include="Resources\Drawable\Legumes.jpg" /> <AndroidResource Include="Resources\Drawable\Tubers.jpg" /> <AndroidResource Include="Resources\Drawable\Vegetables.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Bulbs.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\FlowerBuds.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Fruits.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Legumes.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Tubers.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Vegetables.jpg" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/AccessoryViews/AccessoryViews.sln b/AccessoryViews/AccessoryViews.sln index efbc87c..0c5f7cc 100755 --- a/AccessoryViews/AccessoryViews.sln +++ b/AccessoryViews/AccessoryViews.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccessoryViews", "AccessoryViews.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccessoryViews", "AccessoryViews.csproj", "{5D679FF9-CD92-445D-9E69-0EA807946575}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {5D679FF9-CD92-445D-9E69-0EA807946575}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D679FF9-CD92-445D-9E69-0EA807946575}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D679FF9-CD92-445D-9E69-0EA807946575}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {5D679FF9-CD92-445D-9E69-0EA807946575}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D679FF9-CD92-445D-9E69-0EA807946575}.Release|Any CPU.Build.0 = Release|Any CPU + {5D679FF9-CD92-445D-9E69-0EA807946575}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal
dotnet/android-samples
306829655bb28daa980d2cef38826919ff8af2f3
[samples] de-duplicate GUIDs (#301)
diff --git a/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.csproj b/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.csproj index 1e07b02..8de1652 100755 --- a/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.csproj +++ b/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.csproj @@ -1,90 +1,90 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>10.0.0</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{789C36D3-D0A1-4438-BAA7-0B8FE98752A9}</ProjectGuid> + <ProjectGuid>{19A26E41-BEF9-47FA-9554-B01D549405BD}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>RotationDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>RotationDemo</AssemblyName> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <AndroidLinkMode>SdkOnly</AndroidLinkMode> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="System.Json" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="SimpleStateActivity.cs" /> <Compile Include="NonConfigInstanceActivity.cs" /> <Compile Include="CodeLayoutActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\drawable\monkey.png" /> <AndroidResource Include="Resources\drawable-land\monkey.png" /> <AndroidResource Include="Resources\layout-land\Main.axml" /> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\layout\SimpleStateView.axml" /> <AndroidResource Include="Resources\layout\ItemView.axml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <ItemGroup /> <ItemGroup> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ProjectExtensions> <MonoDevelop> <Properties> <Policies> <TextStylePolicy FileWidth="120" TabWidth="4" inheritsSet="Mono" inheritsScope="text/plain" scope="text/x-csharp" /> <CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> <TextStylePolicy FileWidth="120" TabWidth="4" inheritsSet="Mono" inheritsScope="text/plain" scope="text/plain" /> <TextStylePolicy FileWidth="120" TabWidth="4" inheritsSet="Mono" inheritsScope="text/plain" scope="application/xml" /> <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> </Policies> </Properties> </MonoDevelop> </ProjectExtensions> </Project> \ No newline at end of file diff --git a/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.sln b/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.sln index 6a88c24..8b196cf 100755 --- a/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.sln +++ b/ApplicationFundamentals/RotationDemo/RotationDemo/RotationDemo.sln @@ -1,25 +1,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RotationDemo", "RotationDemo.csproj", "{789C36D3-D0A1-4438-BAA7-0B8FE98752A9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RotationDemo", "RotationDemo.csproj", "{19A26E41-BEF9-47FA-9554-B01D549405BD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {789C36D3-D0A1-4438-BAA7-0B8FE98752A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {789C36D3-D0A1-4438-BAA7-0B8FE98752A9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {789C36D3-D0A1-4438-BAA7-0B8FE98752A9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {789C36D3-D0A1-4438-BAA7-0B8FE98752A9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {789C36D3-D0A1-4438-BAA7-0B8FE98752A9}.Release|Any CPU.Build.0 = Release|Any CPU + {19A26E41-BEF9-47FA-9554-B01D549405BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19A26E41-BEF9-47FA-9554-B01D549405BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19A26E41-BEF9-47FA-9554-B01D549405BD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {19A26E41-BEF9-47FA-9554-B01D549405BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19A26E41-BEF9-47FA-9554-B01D549405BD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = RotationDemo.csproj EndGlobalSection EndGlobal diff --git a/BasicTableAdapter/BasicTableAdapter.csproj b/BasicTableAdapter/BasicTableAdapter.csproj index b09b203..6ca64cc 100644 --- a/BasicTableAdapter/BasicTableAdapter.csproj +++ b/BasicTableAdapter/BasicTableAdapter.csproj @@ -1,72 +1,72 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{9C84A669-95F8-4F70-8DD5-44E6FE5098E8}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>BasicTableAdapter</RootNamespace> <AssemblyName>BasicTableAdapter</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>false</DeployExternal> <AndroidStoreUncompressedFileExtensions /> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="HomeScreenAdapter.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup /> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/BasicTableAdapter/BasicTableAdapter.sln b/BasicTableAdapter/BasicTableAdapter.sln index 075f778..bd4c367 100755 --- a/BasicTableAdapter/BasicTableAdapter.sln +++ b/BasicTableAdapter/BasicTableAdapter.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTableAdapter", "BasicTableAdapter.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTableAdapter", "BasicTableAdapter.csproj", "{9C84A669-95F8-4F70-8DD5-44E6FE5098E8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {9C84A669-95F8-4F70-8DD5-44E6FE5098E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C84A669-95F8-4F70-8DD5-44E6FE5098E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C84A669-95F8-4F70-8DD5-44E6FE5098E8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {9C84A669-95F8-4F70-8DD5-44E6FE5098E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C84A669-95F8-4F70-8DD5-44E6FE5098E8}.Release|Any CPU.Build.0 = Release|Any CPU + {9C84A669-95F8-4F70-8DD5-44E6FE5098E8}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/BuiltInViews/BuiltInViews.sln b/BuiltInViews/BuiltInViews.sln index f71a17f..093be9b 100755 --- a/BuiltInViews/BuiltInViews.sln +++ b/BuiltInViews/BuiltInViews.sln @@ -1,35 +1,35 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuiltInViews", "BuiltInViews\BuiltInViews.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuiltInViews", "BuiltInViews\BuiltInViews.csproj", "{5946AB92-6C36-4B1E-8090-C0313CA44150}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuiltInExpandableViews", "BuiltInExpandableViews\BuiltInExpandableViews.csproj", "{05F960F8-83D2-4197-9E55-23702D357455}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {05F960F8-83D2-4197-9E55-23702D357455}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05F960F8-83D2-4197-9E55-23702D357455}.Debug|Any CPU.Build.0 = Debug|Any CPU {05F960F8-83D2-4197-9E55-23702D357455}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {05F960F8-83D2-4197-9E55-23702D357455}.Release|Any CPU.ActiveCfg = Release|Any CPU {05F960F8-83D2-4197-9E55-23702D357455}.Release|Any CPU.Build.0 = Release|Any CPU {05F960F8-83D2-4197-9E55-23702D357455}.Release|Any CPU.Deploy.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {5946AB92-6C36-4B1E-8090-C0313CA44150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5946AB92-6C36-4B1E-8090-C0313CA44150}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5946AB92-6C36-4B1E-8090-C0313CA44150}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {5946AB92-6C36-4B1E-8090-C0313CA44150}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5946AB92-6C36-4B1E-8090-C0313CA44150}.Release|Any CPU.Build.0 = Release|Any CPU + {5946AB92-6C36-4B1E-8090-C0313CA44150}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = BuiltInViews\BuiltInViews.csproj EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/BuiltInViews/BuiltInViews/BuiltInViews.csproj b/BuiltInViews/BuiltInViews/BuiltInViews.csproj index 3157e17..82d022a 100644 --- a/BuiltInViews/BuiltInViews/BuiltInViews.csproj +++ b/BuiltInViews/BuiltInViews/BuiltInViews.csproj @@ -1,83 +1,83 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{5946AB92-6C36-4B1E-8090-C0313CA44150}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>BuiltInViews</RootNamespace> <AssemblyName>BuiltInViews</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>False</DeployExternal> <AndroidStoreUncompressedFileExtensions /> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="HomeScreenAdapter.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="TableItem.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup /> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> <AndroidResource Include="Resources\Drawable\Bulbs.jpg" /> <AndroidResource Include="Resources\Drawable\FlowerBuds.jpg" /> <AndroidResource Include="Resources\Drawable\Fruits.jpg" /> <AndroidResource Include="Resources\Drawable\Legumes.jpg" /> <AndroidResource Include="Resources\Drawable\Tubers.jpg" /> <AndroidResource Include="Resources\Drawable\Vegetables.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Bulbs.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\FlowerBuds.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Fruits.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Legumes.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Tubers.jpg" /> <AndroidResource Include="Resources\Drawable-hdpi\Vegetables.jpg" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> diff --git a/CursorTableAdapter/CursorTableAdapter.sln b/CursorTableAdapter/CursorTableAdapter.sln index ecf0320..1b12000 100755 --- a/CursorTableAdapter/CursorTableAdapter.sln +++ b/CursorTableAdapter/CursorTableAdapter.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CursorTabledapter", "CursorTabledapter.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CursorTabledapter", "CursorTabledapter.csproj", "{D46E49E6-083D-4777-B787-30B0B885B52F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {D46E49E6-083D-4777-B787-30B0B885B52F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D46E49E6-083D-4777-B787-30B0B885B52F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D46E49E6-083D-4777-B787-30B0B885B52F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {D46E49E6-083D-4777-B787-30B0B885B52F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D46E49E6-083D-4777-B787-30B0B885B52F}.Release|Any CPU.Build.0 = Release|Any CPU + {D46E49E6-083D-4777-B787-30B0B885B52F}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/CursorTableAdapter/CursorTabledapter.csproj b/CursorTableAdapter/CursorTabledapter.csproj index 4acdd4a..6b63f6a 100644 --- a/CursorTableAdapter/CursorTabledapter.csproj +++ b/CursorTableAdapter/CursorTabledapter.csproj @@ -1,77 +1,77 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{D46E49E6-083D-4777-B787-30B0B885B52F}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>CursorTableAdapter</RootNamespace> <AssemblyName>CursorTableAdapter</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>false</DeployExternal> <AndroidStoreUncompressedFileExtensions /> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="HomeScreenCursorAdapter.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="VegetableDatabase.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Layout\HomeScreen.axml"> <SubType>AndroidResource</SubType> </AndroidResource> </ItemGroup> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/CustomRowView/CustomRowView.csproj b/CustomRowView/CustomRowView.csproj index 3f31eab..437fedd 100644 --- a/CustomRowView/CustomRowView.csproj +++ b/CustomRowView/CustomRowView.csproj @@ -1,90 +1,90 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{95B16356-86E0-4DFF-B9C8-362C91C51239}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>CustomRowView</RootNamespace> <AssemblyName>CustomRowView</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>False</DeployExternal> <AndroidStoreUncompressedFileExtensions /> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="HomeScreenAdapter.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="TableItem.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Layout\HomeScreen.axml"> <SubType>Designer</SubType> </AndroidResource> </ItemGroup> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> <AndroidResource Include="Resources\Drawable\Bulbs.jpg" /> <AndroidResource Include="Resources\Drawable\FlowerBuds.jpg" /> <AndroidResource Include="Resources\Drawable\Fruits.jpg" /> <AndroidResource Include="Resources\Drawable\Legumes.jpg" /> <AndroidResource Include="Resources\Drawable\Tubers.jpg" /> <AndroidResource Include="Resources\Drawable\Vegetables.jpg" /> <AndroidResource Include="Resources\Drawable\CustomSelector.xml" /> <AndroidResource Include="Resources\Values\Colors.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Layout\CustomView.axml"> <SubType>Designer</SubType> </AndroidResource> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/CustomRowView/CustomRowView.sln b/CustomRowView/CustomRowView.sln index 54c4b2b..ff0bddf 100755 --- a/CustomRowView/CustomRowView.sln +++ b/CustomRowView/CustomRowView.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomRowView", "CustomRowView.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomRowView", "CustomRowView.csproj", "{95B16356-86E0-4DFF-B9C8-362C91C51239}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {95B16356-86E0-4DFF-B9C8-362C91C51239}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95B16356-86E0-4DFF-B9C8-362C91C51239}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95B16356-86E0-4DFF-B9C8-362C91C51239}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {95B16356-86E0-4DFF-B9C8-362C91C51239}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95B16356-86E0-4DFF-B9C8-362C91C51239}.Release|Any CPU.Build.0 = Release|Any CPU + {95B16356-86E0-4DFF-B9C8-362C91C51239}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/FastScroll/FastScroll.csproj b/FastScroll/FastScroll.csproj index 9e219f4..6af411f 100644 --- a/FastScroll/FastScroll.csproj +++ b/FastScroll/FastScroll.csproj @@ -1,73 +1,73 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{4F00A603-3DF7-4BA7-A307-57E89164E9C1}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>FastScroll</RootNamespace> <AssemblyName>FastScroll</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>False</DeployExternal> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidStoreUncompressedFileExtensions> </AndroidStoreUncompressedFileExtensions> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup /> <ItemGroup> <AndroidAsset Include="Assets\VegeData.txt" /> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/FastScroll/FastScroll.sln b/FastScroll/FastScroll.sln index 04368a6..265493e 100755 --- a/FastScroll/FastScroll.sln +++ b/FastScroll/FastScroll.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastScroll", "FastScroll.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastScroll", "FastScroll.csproj", "{4F00A603-3DF7-4BA7-A307-57E89164E9C1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {4F00A603-3DF7-4BA7-A307-57E89164E9C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F00A603-3DF7-4BA7-A307-57E89164E9C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F00A603-3DF7-4BA7-A307-57E89164E9C1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {4F00A603-3DF7-4BA7-A307-57E89164E9C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F00A603-3DF7-4BA7-A307-57E89164E9C1}.Release|Any CPU.Build.0 = Release|Any CPU + {4F00A603-3DF7-4BA7-A307-57E89164E9C1}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/GLCube-1.0/GLCube.csproj b/GLCube-1.0/GLCube.csproj index f892965..fd4d33a 100644 --- a/GLCube-1.0/GLCube.csproj +++ b/GLCube-1.0/GLCube.csproj @@ -1,87 +1,87 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238546}</ProjectGuid> + <ProjectGuid>{19812DE8-8371-4A04-AE8E-4DCDB4AB5DF9}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.GLCube</RootNamespace> <AssemblyName>GLCube</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MonoDroidLinkMode>Full</MonoDroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="OpenTK-1.0" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="GLCubeActivity.cs" /> <Compile Include="PaintingView.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\app_glcube.png" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml"> <SubType>Designer</SubType> </AndroidResource> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> </ItemGroup> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/GLCube-1.0/GLCube.sln b/GLCube-1.0/GLCube.sln index 454041d..02d001e 100644 --- a/GLCube-1.0/GLCube.sln +++ b/GLCube-1.0/GLCube.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLCube", "GLCube.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238546}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLCube", "GLCube.csproj", "{19812DE8-8371-4A04-AE8E-4DCDB4AB5DF9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Build.0 = Release|Any CPU + {19812DE8-8371-4A04-AE8E-4DCDB4AB5DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19812DE8-8371-4A04-AE8E-4DCDB4AB5DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19812DE8-8371-4A04-AE8E-4DCDB4AB5DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19812DE8-8371-4A04-AE8E-4DCDB4AB5DF9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/GLDiagnostics30/GLDiag30.csproj b/GLDiagnostics30/GLDiag30.csproj index 86540f4..958e809 100644 --- a/GLDiagnostics30/GLDiag30.csproj +++ b/GLDiagnostics30/GLDiag30.csproj @@ -1,80 +1,80 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238576}</ProjectGuid> + <ProjectGuid>{3053020A-AF6D-4365-A9A4-C3C0A5CFC6F3}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.GLDiag30</RootNamespace> <AssemblyName>GLDiag</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MonoDroidLinkMode>Full</MonoDroidLinkMode> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="OpenTK-1.0" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="GLDiagActivity.cs" /> <Compile Include="PaintingView.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\app_gldiag.jpeg" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml"> <SubType>Designer</SubType> </AndroidResource> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> </ItemGroup> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup /> </Project> \ No newline at end of file diff --git a/GLDiagnostics30/GLDiag30.sln b/GLDiagnostics30/GLDiag30.sln index c9470fb..5f15085 100644 --- a/GLDiagnostics30/GLDiag30.sln +++ b/GLDiagnostics30/GLDiag30.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLDiag30", "GLDiag30.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238576}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLDiag30", "GLDiag30.csproj", "{3053020A-AF6D-4365-A9A4-C3C0A5CFC6F3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238576}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238576}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238576}.Release|Any CPU.Build.0 = Release|Any CPU + {3053020A-AF6D-4365-A9A4-C3C0A5CFC6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3053020A-AF6D-4365-A9A4-C3C0A5CFC6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3053020A-AF6D-4365-A9A4-C3C0A5CFC6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3053020A-AF6D-4365-A9A4-C3C0A5CFC6F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = GLDiag30.csproj EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/GLNativeES30/GLNativeES30.csproj b/GLNativeES30/GLNativeES30.csproj index 07a4737..fbcd438 100644 --- a/GLNativeES30/GLNativeES30.csproj +++ b/GLNativeES30/GLNativeES30.csproj @@ -1,81 +1,81 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{F2AB5E1D-F6AB-46F8-B83B-6B0F4F06BA19}</ProjectGuid> + <ProjectGuid>{4F01A736-2369-4C6C-9409-04E2D6199181}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>GLNativeES30</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>GLNativeES20</AssemblyName> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>False</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>False</ConsolePause> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="MyGLSurfaceView.cs" /> <Compile Include="MyGLRenderer.cs" /> <Compile Include="Triangle.cs" /> <Compile Include="Square.cs" /> <Compile Include="GLNativeES30Activity.cs" /> <Compile Include="TestActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> <AndroidResource Include="Resources\layout\Test.axml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/GLNativeES30/GLNativeES30.sln b/GLNativeES30/GLNativeES30.sln index ee83d93..5caa1bc 100644 --- a/GLNativeES30/GLNativeES30.sln +++ b/GLNativeES30/GLNativeES30.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLNativeES30", "GLNativeES30.csproj", "{F2AB5E1D-F6AB-46F8-B83B-6B0F4F06BA19}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLNativeES30", "GLNativeES30.csproj", "{4F01A736-2369-4C6C-9409-04E2D6199181}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F2AB5E1D-F6AB-46F8-B83B-6B0F4F06BA19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F2AB5E1D-F6AB-46F8-B83B-6B0F4F06BA19}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F2AB5E1D-F6AB-46F8-B83B-6B0F4F06BA19}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F2AB5E1D-F6AB-46F8-B83B-6B0F4F06BA19}.Release|Any CPU.Build.0 = Release|Any CPU + {4F01A736-2369-4C6C-9409-04E2D6199181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F01A736-2369-4C6C-9409-04E2D6199181}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F01A736-2369-4C6C-9409-04E2D6199181}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F01A736-2369-4C6C-9409-04E2D6199181}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = GLNativeES30.csproj EndGlobalSection EndGlobal diff --git a/GLTriangle20/GLTriangle20.csproj b/GLTriangle20/GLTriangle20.csproj index e67492d..1983955 100644 --- a/GLTriangle20/GLTriangle20.csproj +++ b/GLTriangle20/GLTriangle20.csproj @@ -1,86 +1,86 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238546}</ProjectGuid> + <ProjectGuid>{8857A66D-5120-4545-B10D-3F305D398B1F}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.GLTriangle20</RootNamespace> <AssemblyName>GLTriangle20</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MonoDroidLinkMode>Full</MonoDroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="OpenTK" /> <Reference Include="System" /> <Reference Include="System.Core" /> </ItemGroup> <ItemGroup> <Compile Include="GLTriangle20Activity.cs" /> <Compile Include="PaintingView.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml"> <SubType>Designer</SubType> </None> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\app_gltriangle.png" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml"> <SubType>Designer</SubType> </AndroidResource> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/GLTriangle20/GLTriangle20.sln b/GLTriangle20/GLTriangle20.sln index 57ae717..972c614 100644 --- a/GLTriangle20/GLTriangle20.sln +++ b/GLTriangle20/GLTriangle20.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTriangle20", "GLTriangle20.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238546}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTriangle20", "GLTriangle20.csproj", "{8857A66D-5120-4545-B10D-3F305D398B1F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Build.0 = Release|Any CPU + {8857A66D-5120-4545-B10D-3F305D398B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8857A66D-5120-4545-B10D-3F305D398B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8857A66D-5120-4545-B10D-3F305D398B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8857A66D-5120-4545-B10D-3F305D398B1F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/GLTriangle30/GLTriangle30.csproj b/GLTriangle30/GLTriangle30.csproj index abad9b1..9f608ad 100644 --- a/GLTriangle30/GLTriangle30.csproj +++ b/GLTriangle30/GLTriangle30.csproj @@ -1,82 +1,82 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238546}</ProjectGuid> + <ProjectGuid>{71D32F89-7907-4A6F-81B9-232E6614A082}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.GLTriangle30</RootNamespace> <AssemblyName>GLTriangle20</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MonoDroidLinkMode>Full</MonoDroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="OpenTK-1.0" /> <Reference Include="System" /> <Reference Include="System.Core" /> </ItemGroup> <ItemGroup> <Compile Include="PaintingView.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="GLTriangle30Activity.cs" /> <Compile Include="TestActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml"> <SubType>Designer</SubType> </None> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable\app_gltriangle.png" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml"> <SubType>Designer</SubType> </AndroidResource> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> <AndroidResource Include="Resources\layout\Test.axml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup /> </Project> \ No newline at end of file diff --git a/GLTriangle30/GLTriangle30.sln b/GLTriangle30/GLTriangle30.sln index ea380b5..88d6c33 100644 --- a/GLTriangle30/GLTriangle30.sln +++ b/GLTriangle30/GLTriangle30.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTriangle30", "GLTriangle30.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238546}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTriangle30", "GLTriangle30.csproj", "{71D32F89-7907-4A6F-81B9-232E6614A082}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Build.0 = Release|Any CPU + {71D32F89-7907-4A6F-81B9-232E6614A082}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71D32F89-7907-4A6F-81B9-232E6614A082}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71D32F89-7907-4A6F-81B9-232E6614A082}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71D32F89-7907-4A6F-81B9-232E6614A082}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = GLTriangle30.csproj EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/GraphicsAndAnimation/AnimationsDemo.csproj b/GraphicsAndAnimation/AnimationsDemo.csproj index 81c669c..b506ef7 100644 --- a/GraphicsAndAnimation/AnimationsDemo.csproj +++ b/GraphicsAndAnimation/AnimationsDemo.csproj @@ -1,168 +1,168 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{CDD68867-1B3F-4858-9145-BFCFED057023}</ProjectGuid> + <ProjectGuid>{9770D988-3D71-4B1E-8487-2994F19263C5}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>com.xamarin.evolve2013.animationsdemo</RootNamespace> <AssemblyName>AnimationsDemo</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidSupportedAbis>armeabi-v7a%3bx86</AndroidSupportedAbis> <AndroidStoreUncompressedFileExtensions /> <MandroidI18n /> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="AnimationDrawableActivity.cs" /> <Compile Include="DrawingActivity.cs" /> <Compile Include="KarmaMeter.cs" /> <Compile Include="MainActivity.cs" /> <Compile Include="PropertyAnimationActivity.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="ShapeDrawableActivity.cs" /> <Compile Include="TouchHighlightImageButton.cs" /> <Compile Include="ViewAnimationActivity.cs" /> <Compile Include="ZoomActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <AndroidResource Include="Resources\Layout\activity_zoom.axml"> <SubType>AndroidResource</SubType> </AndroidResource> <AndroidResource Include="Resources\Layout\activity_imageandbutton.axml"> <SubType>AndroidResource</SubType> </AndroidResource> <AndroidResource Include="Resources\Layout\activity_propertyanimation.axml"> <SubType>Designer</SubType> </AndroidResource> <AndroidResource Include="Resources\Layout\activity_drawing.axml"> <SubType>AndroidResource</SubType> </AndroidResource> <AndroidResource Include="Resources\Layout\activity_shapedrawable.axml"> <SubType>AndroidResource</SubType> </AndroidResource> <AndroidResource Include="Resources\Drawable\shape_rounded_blue_rect.xml" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Values\Strings.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\ic_launcher.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-hdpi\ic_action_info.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-hdpi\ic_action_new.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-hdpi\ic_action_photo.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-hdpi\ic_launcher.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-hdpi\ic_list_remove.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-mdpi\ic_action_info.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-mdpi\ic_action_new.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-mdpi\ic_action_photo.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-mdpi\ic_launcher.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-mdpi\ic_list_remove.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_info.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_new.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_photo.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-xhdpi\ic_launcher.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-xhdpi\ic_list_remove.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-nodpi\image1.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-nodpi\image2.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-nodpi\thumb1.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-nodpi\thumb2.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\spinning_asteroid.xml" /> <AndroidResource Include="Resources\Drawable\asteroid01.png" /> <AndroidResource Include="Resources\Drawable\asteroid02.png" /> <AndroidResource Include="Resources\Drawable\asteroid03.png" /> <AndroidResource Include="Resources\Drawable\asteroid04.png" /> <AndroidResource Include="Resources\Drawable\asteroid05.png" /> <AndroidResource Include="Resources\Drawable\asteroid06.png" /> <AndroidResource Include="Resources\Drawable\ship2_2.png" /> <AndroidResource Include="Resources\anim\hyperspace.xml" /> <AndroidResource Include="Resources\Drawable\shape_oval_purple_gradient.xml" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_launcher.png" /> </ItemGroup> <ItemGroup /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> \ No newline at end of file diff --git a/GraphicsAndAnimation/AnimationsDemo.sln b/GraphicsAndAnimation/AnimationsDemo.sln index ee8afa7..bebc0fd 100755 --- a/GraphicsAndAnimation/AnimationsDemo.sln +++ b/GraphicsAndAnimation/AnimationsDemo.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationsDemo", "AnimationsDemo.csproj", "{CDD68867-1B3F-4858-9145-BFCFED057023}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationsDemo", "AnimationsDemo.csproj", "{9770D988-3D71-4B1E-8487-2994F19263C5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CDD68867-1B3F-4858-9145-BFCFED057023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CDD68867-1B3F-4858-9145-BFCFED057023}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CDD68867-1B3F-4858-9145-BFCFED057023}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {CDD68867-1B3F-4858-9145-BFCFED057023}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CDD68867-1B3F-4858-9145-BFCFED057023}.Release|Any CPU.Build.0 = Release|Any CPU - {CDD68867-1B3F-4858-9145-BFCFED057023}.Release|Any CPU.Deploy.0 = Release|Any CPU + {9770D988-3D71-4B1E-8487-2994F19263C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9770D988-3D71-4B1E-8487-2994F19263C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9770D988-3D71-4B1E-8487-2994F19263C5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {9770D988-3D71-4B1E-8487-2994F19263C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9770D988-3D71-4B1E-8487-2994F19263C5}.Release|Any CPU.Build.0 = Release|Any CPU + {9770D988-3D71-4B1E-8487-2994F19263C5}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/HelloWorldPublishing/HelloWorld.csproj b/HelloWorldPublishing/HelloWorldPublishing.csproj similarity index 95% rename from HelloWorldPublishing/HelloWorld.csproj rename to HelloWorldPublishing/HelloWorldPublishing.csproj index a3b652c..6ed78e8 100755 --- a/HelloWorldPublishing/HelloWorld.csproj +++ b/HelloWorldPublishing/HelloWorldPublishing.csproj @@ -1,74 +1,74 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{60F4286E-BC72-4C35-A584-018508BF4291}</ProjectGuid> + <ProjectGuid>{C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.HelloWorld</RootNamespace> <AssemblyName>mono.samples.helloworld</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidApplication>true</AndroidApplication> <AndroidSupportedAbis>armeabi-v7a</AndroidSupportedAbis> <MandroidI18n /> <TargetFrameworkVersion>v5.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidStoreUncompressedFileExtensions> </AndroidStoreUncompressedFileExtensions> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HelloWorld.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\values\strings.xml" /> </ItemGroup> <ItemGroup> <TransformFile Include="Properties\AndroidManifest.xml" /> </ItemGroup> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/HelloWorldPublishing/HelloWorld.sln b/HelloWorldPublishing/HelloWorldPublishing.sln similarity index 56% rename from HelloWorldPublishing/HelloWorld.sln rename to HelloWorldPublishing/HelloWorldPublishing.sln index a1566c4..022a849 100755 --- a/HelloWorldPublishing/HelloWorld.sln +++ b/HelloWorldPublishing/HelloWorldPublishing.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld.csproj", "{60F4286E-BC72-4C35-A584-018508BF4291}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorldPublishing.csproj", "{C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {60F4286E-BC72-4C35-A584-018508BF4291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {60F4286E-BC72-4C35-A584-018508BF4291}.Debug|Any CPU.Build.0 = Debug|Any CPU - {60F4286E-BC72-4C35-A584-018508BF4291}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {60F4286E-BC72-4C35-A584-018508BF4291}.Release|Any CPU.ActiveCfg = Release|Any CPU - {60F4286E-BC72-4C35-A584-018508BF4291}.Release|Any CPU.Build.0 = Release|Any CPU - {60F4286E-BC72-4C35-A584-018508BF4291}.Release|Any CPU.Deploy.0 = Release|Any CPU + {C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}.Release|Any CPU.Build.0 = Release|Any CPU + {C35AF4F1-8415-45FB-9F4C-A9C738EC6AE6}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/ModelAndVerts/ModelAndVerts.Android/ModelAndVerts.Android.csproj b/ModelAndVerts/ModelAndVerts.Android/ModelAndVerts.Android.csproj index 1586bec..9917319 100644 --- a/ModelAndVerts/ModelAndVerts.Android/ModelAndVerts.Android.csproj +++ b/ModelAndVerts/ModelAndVerts.Android/ModelAndVerts.Android.csproj @@ -1,78 +1,78 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}</ProjectGuid> + <ProjectGuid>{3004AA87-82DB-4166-9888-1D0FF8C55DF8}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>ModelAndVerts.Android</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <AssemblyName>ModelAndVerts.Android</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="GameActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <Import Project="..\packages\MonoGame.Binaries.3.2.0\build\MonoAndroid\MonoGame.Binaries.targets" /> <ItemGroup> <Folder Include="Assets\Content\" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\Content\robot.xnb" /> <AndroidAsset Include="Assets\Content\robottexture_0.xnb" /> <AndroidAsset Include="Assets\Content\checkerboard.png" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ModelAndVerts\ModelAndVerts.csproj"> - <Project>{2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}</Project> + <Project>{037C9236-B7FE-46B8-A8AB-D1034DC3315F}</Project> <Name>ModelAndVerts</Name> </ProjectReference> </ItemGroup> </Project> \ No newline at end of file diff --git a/ModelAndVerts/ModelAndVerts.sln b/ModelAndVerts/ModelAndVerts.sln index abc9797..a01f8a5 100644 --- a/ModelAndVerts/ModelAndVerts.sln +++ b/ModelAndVerts/ModelAndVerts.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelAndVerts", "ModelAndVerts\ModelAndVerts.csproj", "{2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelAndVerts", "ModelAndVerts\ModelAndVerts.csproj", "{037C9236-B7FE-46B8-A8AB-D1034DC3315F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelAndVerts.Android", "ModelAndVerts.Android\ModelAndVerts.Android.csproj", "{C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelAndVerts.Android", "ModelAndVerts.Android\ModelAndVerts.Android.csproj", "{3004AA87-82DB-4166-9888-1D0FF8C55DF8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Release|Any CPU.Build.0 = Release|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Release|Any CPU.Build.0 = Release|Any CPU + {037C9236-B7FE-46B8-A8AB-D1034DC3315F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {037C9236-B7FE-46B8-A8AB-D1034DC3315F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {037C9236-B7FE-46B8-A8AB-D1034DC3315F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {037C9236-B7FE-46B8-A8AB-D1034DC3315F}.Release|Any CPU.Build.0 = Release|Any CPU + {3004AA87-82DB-4166-9888-1D0FF8C55DF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3004AA87-82DB-4166-9888-1D0FF8C55DF8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3004AA87-82DB-4166-9888-1D0FF8C55DF8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3004AA87-82DB-4166-9888-1D0FF8C55DF8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/ModelAndVerts/ModelAndVerts/ModelAndVerts.csproj b/ModelAndVerts/ModelAndVerts/ModelAndVerts.csproj index d04da68..a546d24 100644 --- a/ModelAndVerts/ModelAndVerts/ModelAndVerts.csproj +++ b/ModelAndVerts/ModelAndVerts/ModelAndVerts.csproj @@ -1,45 +1,45 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}</ProjectGuid> + <ProjectGuid>{037C9236-B7FE-46B8-A8AB-D1034DC3315F}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>ModelAndVerts</RootNamespace> <AssemblyName>ModelAndVerts</AssemblyName> <TargetFrameworkProfile>Profile78</TargetFrameworkProfile> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Game1.cs" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <ItemGroup> <Reference Include="MonoGame.Framework"> <HintPath>..\packages\MonoGame-Portable.3.2.1\lib\portable-net45+wp8+win8\MonoGame.Framework.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <None Include="packages.config" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/MonoGame3DCamera/CameraProject.Android/CameraProject.Android.csproj b/MonoGame3DCamera/CameraProject.Android/CameraProject.Android.csproj index fb1a248..beb593e 100644 --- a/MonoGame3DCamera/CameraProject.Android/CameraProject.Android.csproj +++ b/MonoGame3DCamera/CameraProject.Android/CameraProject.Android.csproj @@ -1,78 +1,78 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}</ProjectGuid> + <ProjectGuid>{46D106B0-630D-4F2A-BA8F-7C5A23D4B4E7}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>ModelAndVerts.Android</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <AssemblyName>CameraProject.Android</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="GameActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <Import Project="..\packages\MonoGame.Binaries.3.2.0\build\MonoAndroid\MonoGame.Binaries.targets" /> <ItemGroup> <Folder Include="Assets\Content\" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\Content\robot.xnb" /> <AndroidAsset Include="Assets\Content\robottexture_0.xnb" /> <AndroidAsset Include="Assets\Content\checkerboard.png" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\CameraProject\CameraProject.csproj"> - <Project>{2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}</Project> + <Project>{9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}</Project> <Name>CameraProject</Name> </ProjectReference> </ItemGroup> </Project> \ No newline at end of file diff --git a/MonoGame3DCamera/CameraProject.sln b/MonoGame3DCamera/CameraProject.sln index 4b03388..9ffe3aa 100644 --- a/MonoGame3DCamera/CameraProject.sln +++ b/MonoGame3DCamera/CameraProject.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraProject.Android", "CameraProject.Android\CameraProject.Android.csproj", "{C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraProject.Android", "CameraProject.Android\CameraProject.Android.csproj", "{46D106B0-630D-4F2A-BA8F-7C5A23D4B4E7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraProject", "CameraProject\CameraProject.csproj", "{2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraProject", "CameraProject\CameraProject.csproj", "{9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}.Release|Any CPU.Build.0 = Release|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C94ED391-EC0A-4AAE-81E8-D6351DF8FA08}.Release|Any CPU.Build.0 = Release|Any CPU + {9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}.Release|Any CPU.Build.0 = Release|Any CPU + {46D106B0-630D-4F2A-BA8F-7C5A23D4B4E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46D106B0-630D-4F2A-BA8F-7C5A23D4B4E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46D106B0-630D-4F2A-BA8F-7C5A23D4B4E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46D106B0-630D-4F2A-BA8F-7C5A23D4B4E7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/MonoGame3DCamera/CameraProject/CameraProject.csproj b/MonoGame3DCamera/CameraProject/CameraProject.csproj index ae29320..f287ee7 100644 --- a/MonoGame3DCamera/CameraProject/CameraProject.csproj +++ b/MonoGame3DCamera/CameraProject/CameraProject.csproj @@ -1,47 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{2DC0C3EE-5FBF-4BEE-838D-DA33916568BC}</ProjectGuid> + <ProjectGuid>{9A62FDFD-BBE6-4D49-9B71-9B40F085DB00}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>CameraProject</RootNamespace> <AssemblyName>CameraProject</AssemblyName> <TargetFrameworkProfile>Profile78</TargetFrameworkProfile> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Game1.cs" /> <Compile Include="Robot.cs" /> <Compile Include="Camera.cs" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <ItemGroup> <Reference Include="MonoGame.Framework"> <HintPath>..\packages\MonoGame-Portable.3.2.1\lib\portable-net45+wp8+win8\MonoGame.Framework.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <None Include="packages.config" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/PhonewordMultiscreen/Phoneword/Phoneword.csproj b/PhonewordMultiscreen/Phoneword/PhonewordMultiscreen.csproj similarity index 95% rename from PhonewordMultiscreen/Phoneword/Phoneword.csproj rename to PhonewordMultiscreen/Phoneword/PhonewordMultiscreen.csproj index 6cf4f1d..2780e69 100644 --- a/PhonewordMultiscreen/Phoneword/Phoneword.csproj +++ b/PhonewordMultiscreen/Phoneword/PhonewordMultiscreen.csproj @@ -1,70 +1,69 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{FC0D8857-179C-430E-8D60-ED194FF75094}</ProjectGuid> + <ProjectGuid>{02677EAA-E79F-46B6-B702-4EFA9570AF2F}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>Phoneword</RootNamespace> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidApplication>True</AndroidApplication> - <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> <AssemblyName>Phoneword</AssemblyName> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <TargetFrameworkVersion>v8.0</TargetFrameworkVersion> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <ConsolePause>false</ConsolePause> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="PhoneTranslator.cs" /> <Compile Include="TranslationHistoryActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable-mdpi\Icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\Icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\Icon.png" /> <AndroidResource Include="Resources\drawable-xxxhdpi\Icon.png" /> <AndroidResource Include="Resources\drawable-hdpi\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <ItemGroup /> </Project> \ No newline at end of file diff --git a/PhonewordMultiscreen/Phoneword.sln b/PhonewordMultiscreen/PhonewordMultiscreen.sln similarity index 60% rename from PhonewordMultiscreen/Phoneword.sln rename to PhonewordMultiscreen/PhonewordMultiscreen.sln index 3db3646..5bdeba7 100755 --- a/PhonewordMultiscreen/Phoneword.sln +++ b/PhonewordMultiscreen/PhonewordMultiscreen.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phoneword", "Phoneword\Phoneword.csproj", "{FC0D8857-179C-430E-8D60-ED194FF75094}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phoneword", "Phoneword\PhonewordMultiscreen.csproj", "{02677EAA-E79F-46B6-B702-4EFA9570AF2F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FC0D8857-179C-430E-8D60-ED194FF75094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FC0D8857-179C-430E-8D60-ED194FF75094}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FC0D8857-179C-430E-8D60-ED194FF75094}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {FC0D8857-179C-430E-8D60-ED194FF75094}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FC0D8857-179C-430E-8D60-ED194FF75094}.Release|Any CPU.Build.0 = Release|Any CPU + {02677EAA-E79F-46B6-B702-4EFA9570AF2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02677EAA-E79F-46B6-B702-4EFA9570AF2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02677EAA-E79F-46B6-B702-4EFA9570AF2F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {02677EAA-E79F-46B6-B702-4EFA9570AF2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02677EAA-E79F-46B6-B702-4EFA9570AF2F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/PhonewordMultiscreen/Screenshots/01.png b/PhonewordMultiscreen/Screenshots/01.png new file mode 100644 index 0000000..370887e Binary files /dev/null and b/PhonewordMultiscreen/Screenshots/01.png differ diff --git a/PhonewordMultiscreen/Screenshots/02.png b/PhonewordMultiscreen/Screenshots/02.png new file mode 100644 index 0000000..dea3151 Binary files /dev/null and b/PhonewordMultiscreen/Screenshots/02.png differ diff --git a/PhonewordMultiscreen/Screenshots/example-screenshot.png b/PhonewordMultiscreen/Screenshots/example-screenshot.png index c8f20b8..72a4f68 100644 Binary files a/PhonewordMultiscreen/Screenshots/example-screenshot.png and b/PhonewordMultiscreen/Screenshots/example-screenshot.png differ diff --git a/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo.sln b/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo.sln index 9dc5275..db1807f 100755 --- a/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo.sln +++ b/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContactsProviderDemo", "ContactsProviderDemo\ContactsProviderDemo.csproj", "{F8EA8877-58C6-4640-B2F1-4CC92D9493EB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContactsProviderDemo", "ContactsProviderDemo\ContactsProviderDemo.csproj", "{9687510F-4D8B-462C-9700-EE9E7D0795A5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F8EA8877-58C6-4640-B2F1-4CC92D9493EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8EA8877-58C6-4640-B2F1-4CC92D9493EB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8EA8877-58C6-4640-B2F1-4CC92D9493EB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8EA8877-58C6-4640-B2F1-4CC92D9493EB}.Release|Any CPU.Build.0 = Release|Any CPU + {9687510F-4D8B-462C-9700-EE9E7D0795A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9687510F-4D8B-462C-9700-EE9E7D0795A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9687510F-4D8B-462C-9700-EE9E7D0795A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9687510F-4D8B-462C-9700-EE9E7D0795A5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = ContactsProviderDemo\ContactsProviderDemo.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo/ContactsProviderDemo.csproj b/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo/ContactsProviderDemo.csproj index 22b19c5..a99705e 100755 --- a/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo/ContactsProviderDemo.csproj +++ b/PlatformFeatures/ICS_Samples/ContactsProviderDemo/ContactsProviderDemo/ContactsProviderDemo.csproj @@ -1,63 +1,63 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{F8EA8877-58C6-4640-B2F1-4CC92D9493EB}</ProjectGuid> + <ProjectGuid>{9687510F-4D8B-462C-9700-EE9E7D0795A5}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>ContactsProviderDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>ContactsProviderDemo</AssemblyName> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo.sln b/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo.sln index 5d1aecf..3be3db2 100755 --- a/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo.sln +++ b/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridLayoutDemo", "GridLayoutDemo\GridLayoutDemo.csproj", "{32FF8070-6D3B-4B44-AC6F-284A0ECC54CD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridLayoutDemo", "GridLayoutDemo\GridLayoutDemo.csproj", "{740B2043-4DA7-41AC-A888-D338EC142D6F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {32FF8070-6D3B-4B44-AC6F-284A0ECC54CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {32FF8070-6D3B-4B44-AC6F-284A0ECC54CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {32FF8070-6D3B-4B44-AC6F-284A0ECC54CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {32FF8070-6D3B-4B44-AC6F-284A0ECC54CD}.Release|Any CPU.Build.0 = Release|Any CPU + {740B2043-4DA7-41AC-A888-D338EC142D6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {740B2043-4DA7-41AC-A888-D338EC142D6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {740B2043-4DA7-41AC-A888-D338EC142D6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {740B2043-4DA7-41AC-A888-D338EC142D6F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = GridLayoutDemo\GridLayoutDemo.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo/GridLayoutDemo.csproj b/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo/GridLayoutDemo.csproj index c53f63b..95e97db 100755 --- a/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo/GridLayoutDemo.csproj +++ b/PlatformFeatures/ICS_Samples/GridLayoutDemo/GridLayoutDemo/GridLayoutDemo.csproj @@ -1,63 +1,63 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{32FF8070-6D3B-4B44-AC6F-284A0ECC54CD}</ProjectGuid> + <ProjectGuid>{740B2043-4DA7-41AC-A888-D338EC142D6F}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>GridLayoutDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>GridLayoutDemo</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS.sln b/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS.sln index f6c8014..c39ee61 100755 --- a/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS.sln +++ b/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloTabsICS", "HelloTabsICS\HelloTabsICS.csproj", "{65034C6A-8C04-4560-B97B-42F12996939A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloTabsICS", "HelloTabsICS\HelloTabsICS.csproj", "{9B378435-A009-4703-8CFA-B78170CFB8BF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {65034C6A-8C04-4560-B97B-42F12996939A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {65034C6A-8C04-4560-B97B-42F12996939A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {65034C6A-8C04-4560-B97B-42F12996939A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {65034C6A-8C04-4560-B97B-42F12996939A}.Release|Any CPU.Build.0 = Release|Any CPU + {9B378435-A009-4703-8CFA-B78170CFB8BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B378435-A009-4703-8CFA-B78170CFB8BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B378435-A009-4703-8CFA-B78170CFB8BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B378435-A009-4703-8CFA-B78170CFB8BF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = HelloTabsICS\HelloTabsICS.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS/HelloTabsICS.csproj b/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS/HelloTabsICS.csproj index a3ceb3f..32bddfc 100644 --- a/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS/HelloTabsICS.csproj +++ b/PlatformFeatures/ICS_Samples/HelloTabsICS/HelloTabsICS/HelloTabsICS.csproj @@ -1,65 +1,65 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{65034C6A-8C04-4560-B97B-42F12996939A}</ProjectGuid> + <ProjectGuid>{9B378435-A009-4703-8CFA-B78170CFB8BF}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>HelloTabsICS</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>HelloTabsICS</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\drawable\ic_tab_white.png" /> <AndroidResource Include="Resources\layout\Tab.axml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo.sln b/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo.sln index c3855cc..841ca23 100755 --- a/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo.sln +++ b/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PopupMenuDemo", "PopupMenuDemo\PopupMenuDemo.csproj", "{66D4DE6D-4B56-4C20-A435-892687B9C26E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PopupMenuDemo", "PopupMenuDemo\PopupMenuDemo.csproj", "{BDD95E84-39B2-4237-9461-1E502867D7E6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66D4DE6D-4B56-4C20-A435-892687B9C26E}.Release|Any CPU.Build.0 = Release|Any CPU + {BDD95E84-39B2-4237-9461-1E502867D7E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDD95E84-39B2-4237-9461-1E502867D7E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDD95E84-39B2-4237-9461-1E502867D7E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDD95E84-39B2-4237-9461-1E502867D7E6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = PopupMenuDemo\PopupMenuDemo.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo/PopupMenuDemo.csproj b/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo/PopupMenuDemo.csproj index 3c4199a..73b947c 100755 --- a/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo/PopupMenuDemo.csproj +++ b/PlatformFeatures/ICS_Samples/PopupMenuDemo/PopupMenuDemo/PopupMenuDemo.csproj @@ -1,67 +1,67 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{66D4DE6D-4B56-4C20-A435-892687B9C26E}</ProjectGuid> + <ProjectGuid>{BDD95E84-39B2-4237-9461-1E502867D7E6}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>PopupMenuDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>PopupMenuDemo</AssemblyName> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\menu\popup_menu.xml" /> </ItemGroup> <ItemGroup> <Folder Include="Resources\menu\" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo.sln b/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo.sln index 5e04b87..d2e43a3 100755 --- a/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo.sln +++ b/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareActionProviderDemo", "ShareActionProviderDemo\ShareActionProviderDemo.csproj", "{E010B79F-B465-49DE-84B5-647097FDB2BF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareActionProviderDemo", "ShareActionProviderDemo\ShareActionProviderDemo.csproj", "{19065FCB-957E-4B6B-B139-F7607440BF63}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E010B79F-B465-49DE-84B5-647097FDB2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E010B79F-B465-49DE-84B5-647097FDB2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E010B79F-B465-49DE-84B5-647097FDB2BF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E010B79F-B465-49DE-84B5-647097FDB2BF}.Release|Any CPU.Build.0 = Release|Any CPU + {19065FCB-957E-4B6B-B139-F7607440BF63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19065FCB-957E-4B6B-B139-F7607440BF63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19065FCB-957E-4B6B-B139-F7607440BF63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19065FCB-957E-4B6B-B139-F7607440BF63}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = ShareActionProviderDemo\ShareActionProviderDemo.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo/ShareActionProviderDemo.csproj b/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo/ShareActionProviderDemo.csproj index 9691aa4..93567fb 100755 --- a/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo/ShareActionProviderDemo.csproj +++ b/PlatformFeatures/ICS_Samples/ShareActionProviderDemo/ShareActionProviderDemo/ShareActionProviderDemo.csproj @@ -1,70 +1,70 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{E010B79F-B465-49DE-84B5-647097FDB2BF}</ProjectGuid> + <ProjectGuid>{19065FCB-957E-4B6B-B139-F7607440BF63}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>ShareActionProviderDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>ShareActionProviderDemo</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\menu\ActionBarMenu.xml" /> </ItemGroup> <ItemGroup> <Folder Include="Resources\menu\" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\monkey.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo.sln b/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo.sln index 13b4f6c..957ea61 100755 --- a/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo.sln +++ b/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwitchDemo", "SwitchDemo\SwitchDemo.csproj", "{22AFDAC0-90FC-4831-9738-6368C9D33EC4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwitchDemo", "SwitchDemo\SwitchDemo.csproj", "{477D2F59-A3C8-43B6-9A36-026D63D45E7E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {22AFDAC0-90FC-4831-9738-6368C9D33EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22AFDAC0-90FC-4831-9738-6368C9D33EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22AFDAC0-90FC-4831-9738-6368C9D33EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22AFDAC0-90FC-4831-9738-6368C9D33EC4}.Release|Any CPU.Build.0 = Release|Any CPU + {477D2F59-A3C8-43B6-9A36-026D63D45E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {477D2F59-A3C8-43B6-9A36-026D63D45E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {477D2F59-A3C8-43B6-9A36-026D63D45E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {477D2F59-A3C8-43B6-9A36-026D63D45E7E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = SwitchDemo\SwitchDemo.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo/SwitchDemo.csproj b/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo/SwitchDemo.csproj index ef60e43..5c995d7 100755 --- a/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo/SwitchDemo.csproj +++ b/PlatformFeatures/ICS_Samples/SwitchDemo/SwitchDemo/SwitchDemo.csproj @@ -1,63 +1,63 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{22AFDAC0-90FC-4831-9738-6368C9D33EC4}</ProjectGuid> + <ProjectGuid>{477D2F59-A3C8-43B6-9A36-026D63D45E7E}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>SwitchDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>SwitchDemo</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo.sln b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo.sln index b63392c..4e7f634 100755 --- a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo.sln +++ b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemUIVisibilityDemo", "SystemUIVisibilityDemo\SystemUIVisibilityDemo.csproj", "{68E34410-AF48-46BF-B198-0A721F95E22F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemUIVisibilityDemo", "SystemUIVisibilityDemo\SystemUIVisibilityDemo.csproj", "{19E3A733-D94D-4DB1-B633-F0D305878163}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {68E34410-AF48-46BF-B198-0A721F95E22F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {68E34410-AF48-46BF-B198-0A721F95E22F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {68E34410-AF48-46BF-B198-0A721F95E22F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {68E34410-AF48-46BF-B198-0A721F95E22F}.Release|Any CPU.Build.0 = Release|Any CPU + {19E3A733-D94D-4DB1-B633-F0D305878163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19E3A733-D94D-4DB1-B633-F0D305878163}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19E3A733-D94D-4DB1-B633-F0D305878163}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19E3A733-D94D-4DB1-B633-F0D305878163}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = SystemUIVisibilityDemo\SystemUIVisibilityDemo.csproj EndGlobalSection EndGlobal diff --git a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/SystemUIVisibilityDemo.csproj b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/SystemUIVisibilityDemo.csproj index 683bfdd..03f8dae 100755 --- a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/SystemUIVisibilityDemo.csproj +++ b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/SystemUIVisibilityDemo/SystemUIVisibilityDemo.csproj @@ -1,63 +1,63 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{68E34410-AF48-46BF-B198-0A721F95E22F}</ProjectGuid> + <ProjectGuid>{19E3A733-D94D-4DB1-B633-F0D305878163}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <RootNamespace>SystemUIVisibilityDemo</RootNamespace> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AssemblyName>SystemUIVisibilityDemo</AssemblyName> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="Activity1.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.csproj b/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.csproj index 39c5c64..87329c6 100644 --- a/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.csproj +++ b/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.csproj @@ -1,83 +1,83 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{90EF85D0-71A1-4996-B9C5-14733282EC39}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>CursorTableAdapter</RootNamespace> <AssemblyName>CursorTableAdapter</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>false</DeployExternal> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> <AndroidSupportedAbis>x86</AndroidSupportedAbis> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidStoreUncompressedFileExtensions> </AndroidStoreUncompressedFileExtensions> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="VegetableDatabase.cs" /> <Compile Include="VegetableProvider.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Layout\HomeScreen.axml"> <SubType>AndroidResource</SubType> </AndroidResource> </ItemGroup> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <None Include="ClassDiagram1.cd" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.sln b/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.sln index 926ed14..aea889f 100755 --- a/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.sln +++ b/PlatformFeatures/SimpleContentProvider/SimpleContentProvider.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleContentProvider", "SimpleContentProvider.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleContentProvider", "SimpleContentProvider.csproj", "{90EF85D0-71A1-4996-B9C5-14733282EC39}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {90EF85D0-71A1-4996-B9C5-14733282EC39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90EF85D0-71A1-4996-B9C5-14733282EC39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90EF85D0-71A1-4996-B9C5-14733282EC39}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {90EF85D0-71A1-4996-B9C5-14733282EC39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90EF85D0-71A1-4996-B9C5-14733282EC39}.Release|Any CPU.Build.0 = Release|Any CPU + {90EF85D0-71A1-4996-B9C5-14733282EC39}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/SanityTests/SanityTests.csproj b/SanityTests/SanityTests.csproj index 5c2eaed..90d0e29 100644 --- a/SanityTests/SanityTests.csproj +++ b/SanityTests/SanityTests.csproj @@ -1,119 +1,119 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238546}</ProjectGuid> + <ProjectGuid>{D5BFD622-A26D-4507-9D19-CC4DE31D577D}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.SanityTests</RootNamespace> <AssemblyName>SanityTests</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidResgenFile>R.cs</AndroidResgenFile> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidApplication>true</AndroidApplication> <AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE;MONODROID_TIMING</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MandroidI18n>west</MandroidI18n> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE;MONODROID_TIMING</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MandroidI18n>west</MandroidI18n> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="Mono.Data.Sqlite" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Data" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> <Reference Include="System.Numerics" /> <Reference Include="System.Runtime.Serialization" /> <Reference Include="System.ServiceModel.Web" /> <Reference Include="Mono.Android.GoogleMaps" /> </ItemGroup> <ItemGroup> <Compile Include="Hello.cs" /> <Compile Include="LibraryActivity.cs" /> <Compile Include="ManagedAdder.cs" /> <Compile Include="R.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\attrs.xml" /> <AndroidResource Include="Resources\drawable-hdpi\StatSample.png" /> <AndroidResource Include="Resources\drawable-mdpi\StatSample.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> </ItemGroup> <ItemGroup> <AndroidJavaSource Include="TestCubeEngine.java" Condition="$(AndroidApiLevel) != '4'" /> <AndroidJavaLibrary Include="$(OutputPath)\custom.jar" /> </ItemGroup> <ItemGroup> <IncludeInCustomJar Include="Adder.java" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\Hello.txt" /> <AndroidAsset Include="Assets\Hello.txt"> <Link>Assets\Subdir\HelloWorld.txt</Link> </AndroidAsset> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <PropertyGroup> <BuildDependsOn> BuildNativeLibs;BuildNativeJars;$(BuildDependsOn) </BuildDependsOn> </PropertyGroup> <Target Name="BuildNativeLibs" Inputs="jni\foo.c;jni\bar.c;jni\Android.mk" Outputs="@(AndroidNativeLibrary)"> <Error Text="Could not locate Android NDK." Condition="!Exists ('$(_AndroidNdkDirectory)\ndk-build')" /> <Exec Command="&quot;$(_AndroidNdkDirectory)\ndk-build&quot;" /> </Target> <Target Name="BuildNativeJars" Inputs="Adder.java" Outputs="$(OutputPath)\custom.jar"> <MakeDir Directories="$(OutputPath)\classes" /> <Exec Command="javac -d $(OutputPath)\classes @(IncludeInCustomJar)" /> <Exec Command="jar cf $(OutputPath)\custom.jar -C $(OutputPath)\classes ." /> </Target> <ItemGroup> <AndroidNativeLibrary Include="libs\armeabi-v7a\libfoo.so" /> <AndroidNativeLibrary Include="libs\armeabi-v7a\libbar.so" /> <AndroidNativeLibrary Include="libs\x86\libfoo.so" /> <AndroidNativeLibrary Include="libs\x86\libbar.so" /> </ItemGroup> <PropertyGroup> <MonoDroidExtraArgs Condition="$(StaticApk) != ''">--noshared</MonoDroidExtraArgs> <MandroidI18n>west</MandroidI18n> </PropertyGroup> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> </Project> diff --git a/SanityTests/SanityTests.sln b/SanityTests/SanityTests.sln index 95877f0..60b505d 100644 --- a/SanityTests/SanityTests.sln +++ b/SanityTests/SanityTests.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SanityTests", "SanityTests.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238546}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SanityTests", "SanityTests.csproj", "{D5BFD622-A26D-4507-9D19-CC4DE31D577D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Build.0 = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Deploy.0 = Release|Any CPU + {D5BFD622-A26D-4507-9D19-CC4DE31D577D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5BFD622-A26D-4507-9D19-CC4DE31D577D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5BFD622-A26D-4507-9D19-CC4DE31D577D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {D5BFD622-A26D-4507-9D19-CC4DE31D577D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5BFD622-A26D-4507-9D19-CC4DE31D577D}.Release|Any CPU.Build.0 = Release|Any CPU + {D5BFD622-A26D-4507-9D19-CC4DE31D577D}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/SectionIndex/SectionIndex.csproj b/SectionIndex/SectionIndex.csproj index 1494489..b45d407 100644 --- a/SectionIndex/SectionIndex.csproj +++ b/SectionIndex/SectionIndex.csproj @@ -1,74 +1,74 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{F4F2D66B-5680-444B-BF51-0BE0463D98AF}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>SectionIndex</RootNamespace> <AssemblyName>SectionIndex</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>False</DeployExternal> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidStoreUncompressedFileExtensions> </AndroidStoreUncompressedFileExtensions> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="HomeScreenAdapter.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup /> <ItemGroup> <AndroidAsset Include="Assets\VegeData.txt" /> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/SectionIndex/SectionIndex.sln b/SectionIndex/SectionIndex.sln index a22c23c..beac7e1 100755 --- a/SectionIndex/SectionIndex.sln +++ b/SectionIndex/SectionIndex.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SectionIndex", "SectionIndex.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SectionIndex", "SectionIndex.csproj", "{F4F2D66B-5680-444B-BF51-0BE0463D98AF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {F4F2D66B-5680-444B-BF51-0BE0463D98AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F4F2D66B-5680-444B-BF51-0BE0463D98AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F4F2D66B-5680-444B-BF51-0BE0463D98AF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {F4F2D66B-5680-444B-BF51-0BE0463D98AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F4F2D66B-5680-444B-BF51-0BE0463D98AF}.Release|Any CPU.Build.0 = Release|Any CPU + {F4F2D66B-5680-444B-BF51-0BE0463D98AF}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/SierpinskiES31/SierpinskiTetrahedron.csproj b/SierpinskiES31/SierpinskiTetrahedron.csproj index b10d5af..0805901 100644 --- a/SierpinskiES31/SierpinskiTetrahedron.csproj +++ b/SierpinskiES31/SierpinskiTetrahedron.csproj @@ -1,99 +1,99 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238548}</ProjectGuid> + <ProjectGuid>{336470C4-5F83-4084-BB16-DD91F6FA6A11}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.Tetrahedron</RootNamespace> <AssemblyName>SierpinskiTetrahedron</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <TargetFrameworkVersion>v5.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>Full</MonoDroidLinkMode> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="OpenTK-1.0" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="PaintingView.cs"> <LogicalName>Mono.Samples.SierpinskiTetrahedron.Resources.Shader.csh</LogicalName> </Compile> <Compile Include="Tetrahedron.cs" /> <Compile Include="TetrahedronActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml" /> <AndroidResource Include="Resources\drawable-nodpi\SierpinskiTetrahedron.png" /> <AndroidResource Include="Resources\drawable-hdpi\SierpinskiTetrahedron.png" /> <AndroidResource Include="Resources\drawable-mdpi\SierpinskiTetrahedron.png" /> <AndroidResource Include="Resources\drawable-xhdpi\SierpinskiTetrahedron.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\SierpinskiTetrahedron.png" /> <AndroidResource Include="Resources\drawable-xxxhdpi\SierpinskiTetrahedron.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> <Folder Include="Resources\drawable-xxxhdpi\" /> <Folder Include="Shaders\" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Shaders\Compute.shader"> <LogicalName>Mono.Samples.SierpinskiTetrahedron.Resources.Shader.csh</LogicalName> </EmbeddedResource> <EmbeddedResource Include="Shaders\Fragment.shader"> <LogicalName>Mono.Samples.SierpinskiTetrahedron.Resources.Shader.fsh</LogicalName> </EmbeddedResource> <EmbeddedResource Include="Shaders\Vertex.shader"> <LogicalName>Mono.Samples.SierpinskiTetrahedron.Resources.Shader.vsh</LogicalName> </EmbeddedResource> </ItemGroup> </Project> diff --git a/SierpinskiES31/SierpinskiTetrahedron.sln b/SierpinskiES31/SierpinskiTetrahedron.sln index 221a792..e7ebcc4 100644 --- a/SierpinskiES31/SierpinskiTetrahedron.sln +++ b/SierpinskiES31/SierpinskiTetrahedron.sln @@ -1,38 +1,38 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SierpinskiTetrahedron", "SierpinskiTetrahedron.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238548}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SierpinskiTetrahedron", "SierpinskiTetrahedron.csproj", "{336470C4-5F83-4084-BB16-DD91F6FA6A11}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU Debug|iPhoneSimulator = Debug|iPhoneSimulator Release|iPhoneSimulator = Release|iPhoneSimulator Debug|iPhone = Debug|iPhone Release|iPhone = Release|iPhone Ad-Hoc|iPhone = Ad-Hoc|iPhone AppStore|iPhone = AppStore|iPhone EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.AppStore|iPhone.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|iPhone.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|Any CPU.Build.0 = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|iPhone.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|iPhone.Build.0 = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.AppStore|iPhone.Build.0 = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Debug|iPhone.Build.0 = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Release|Any CPU.Build.0 = Release|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Release|iPhone.ActiveCfg = Release|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Release|iPhone.Build.0 = Release|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {336470C4-5F83-4084-BB16-DD91F6FA6A11}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/SimpleCursorTableAdapter/SimpleCursorTableAdapter.csproj b/SimpleCursorTableAdapter/SimpleCursorTableAdapter.csproj index 33a6394..d2a47be 100644 --- a/SimpleCursorTableAdapter/SimpleCursorTableAdapter.csproj +++ b/SimpleCursorTableAdapter/SimpleCursorTableAdapter.csproj @@ -1,76 +1,76 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}</ProjectGuid> + <ProjectGuid>{2AA3E26E-4166-49BD-90BD-65A59D47B497}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>CursorTableAdapter</RootNamespace> <AssemblyName>CursorTableAdapter</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>true</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <DeployExternal>false</DeployExternal> <AndroidStoreUncompressedFileExtensions /> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MandroidI18n /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="HomeScreen.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="VegetableDatabase.cs" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Layout\HomeScreen.axml"> <SubType>AndroidResource</SubType> </AndroidResource> </ItemGroup> <ItemGroup> <Content Include="Properties\AndroidManifest.xml" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> </Project> \ No newline at end of file diff --git a/SimpleCursorTableAdapter/SimpleCursorTableAdapter.sln b/SimpleCursorTableAdapter/SimpleCursorTableAdapter.sln index ba80ba8..51deacc 100755 --- a/SimpleCursorTableAdapter/SimpleCursorTableAdapter.sln +++ b/SimpleCursorTableAdapter/SimpleCursorTableAdapter.sln @@ -1,22 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCursorTableAdapter", "SimpleCursorTableAdapter.csproj", "{BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCursorTableAdapter", "SimpleCursorTableAdapter.csproj", "{2AA3E26E-4166-49BD-90BD-65A59D47B497}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Build.0 = Release|Any CPU - {BB3E2E74-C763-4CE8-A2E0-757BC0BE12EA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {2AA3E26E-4166-49BD-90BD-65A59D47B497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AA3E26E-4166-49BD-90BD-65A59D47B497}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AA3E26E-4166-49BD-90BD-65A59D47B497}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {2AA3E26E-4166-49BD-90BD-65A59D47B497}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AA3E26E-4166-49BD-90BD-65A59D47B497}.Release|Any CPU.Build.0 = Release|Any CPU + {2AA3E26E-4166-49BD-90BD-65A59D47B497}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/TexturedCube/TexturedCube.csproj b/TexturedCube/TexturedCube.csproj index 421f0d0..2c6f60c 100644 --- a/TexturedCube/TexturedCube.csproj +++ b/TexturedCube/TexturedCube.csproj @@ -1,87 +1,87 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238546}</ProjectGuid> + <ProjectGuid>{81BB3348-CAB2-4DC7-87DA-C4DCE3928606}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.TexturedCube</RootNamespace> <AssemblyName>TexturedCube</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MonoDroidLinkMode>Full</MonoDroidLinkMode> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="OpenTK" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="TexturedCubeActivity.cs" /> <Compile Include="PaintingView.cs" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-nodpi\translucent.png" /> <AndroidResource Include="Resources\drawable-nodpi\pattern.png" /> <AndroidResource Include="Resources\drawable-nodpi\app_texturedcube.png" /> <AndroidResource Include="Resources\drawable-nodpi\f_spot.png" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml" /> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-mdpi\" /> </ItemGroup> </Project> diff --git a/TexturedCube/TexturedCube.sln b/TexturedCube/TexturedCube.sln index 865cc81..5927144 100644 --- a/TexturedCube/TexturedCube.sln +++ b/TexturedCube/TexturedCube.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TexturedCube", "TexturedCube.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238546}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TexturedCube", "TexturedCube.csproj", "{81BB3348-CAB2-4DC7-87DA-C4DCE3928606}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Build.0 = Release|Any CPU + {81BB3348-CAB2-4DC7-87DA-C4DCE3928606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81BB3348-CAB2-4DC7-87DA-C4DCE3928606}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81BB3348-CAB2-4DC7-87DA-C4DCE3928606}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81BB3348-CAB2-4DC7-87DA-C4DCE3928606}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/TexturedCubeES30-1.0/TexturedCube.csproj b/TexturedCubeES30-1.0/TexturedCube.csproj index 216168e..fbd17b5 100644 --- a/TexturedCubeES30-1.0/TexturedCube.csproj +++ b/TexturedCubeES30-1.0/TexturedCube.csproj @@ -1,90 +1,90 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238548}</ProjectGuid> + <ProjectGuid>{423F7F69-3E50-4D6F-97A9-741AF8BFA737}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Mono.Samples.TexturedCube</RootNamespace> <AssemblyName>TexturedCube</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidApplication>true</AndroidApplication> <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MonoDroidLinkMode>None</MonoDroidLinkMode> <AndroidLinkMode>None</AndroidLinkMode> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <MonoDroidLinkMode>Full</MonoDroidLinkMode> </PropertyGroup> <ItemGroup> <Reference Include="Mono.Android" /> <Reference Include="OpenTK-1.0" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="TexturedCubeActivity.cs" /> <Compile Include="PaintingView.cs" /> <Compile Include="CubeModel.cs" /> </ItemGroup> <ItemGroup> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\drawable-nodpi\translucent.png" /> <AndroidResource Include="Resources\drawable-nodpi\app_texturedcube.png" /> <AndroidResource Include="Resources\layout\main.xml" /> <AndroidResource Include="Resources\values\strings.xml" /> <AndroidResource Include="Resources\drawable-hdpi\icon.png" /> <AndroidResource Include="Resources\drawable-ldpi\icon.png" /> <AndroidResource Include="Resources\drawable-mdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> <AndroidResource Include="Resources\drawable-nodpi\texture1.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-ldpi\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> <ItemGroup> <AndroidAsset Include="Resources\Shader.fsh" /> <AndroidAsset Include="Resources\Shader.vsh" /> <AndroidAsset Include="Resources\ShaderPlain.fsh" /> </ItemGroup> </Project> diff --git a/TexturedCubeES30-1.0/TexturedCube.sln b/TexturedCubeES30-1.0/TexturedCube.sln index 6c40884..654af22 100644 --- a/TexturedCubeES30-1.0/TexturedCube.sln +++ b/TexturedCubeES30-1.0/TexturedCube.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TexturedCube", "TexturedCube.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238548}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TexturedCube", "TexturedCube.csproj", "{423F7F69-3E50-4D6F-97A9-741AF8BFA737}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73A74ADF-6308-42A0-8BA6-2B5D53238548}.Release|Any CPU.Build.0 = Release|Any CPU + {423F7F69-3E50-4D6F-97A9-741AF8BFA737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {423F7F69-3E50-4D6F-97A9-741AF8BFA737}.Debug|Any CPU.Build.0 = Debug|Any CPU + {423F7F69-3E50-4D6F-97A9-741AF8BFA737}.Release|Any CPU.ActiveCfg = Release|Any CPU + {423F7F69-3E50-4D6F-97A9-741AF8BFA737}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/android5.0/KitchenSink/AndroidLSamples.sln b/android5.0/KitchenSink/AndroidLSamples.sln index 34c6b43..3bfe67c 100644 --- a/android5.0/KitchenSink/AndroidLSamples.sln +++ b/android5.0/KitchenSink/AndroidLSamples.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidLSamples", "AndroidLSamples\AndroidLSamples.csproj", "{9F3C7E51-02F6-4A7C-B1E2-6B608BA21F08}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidLSamples", "AndroidLSamples\AndroidLSamples.csproj", "{321FB2D5-3790-40AA-BFFB-EB18BE612C76}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9F3C7E51-02F6-4A7C-B1E2-6B608BA21F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9F3C7E51-02F6-4A7C-B1E2-6B608BA21F08}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F3C7E51-02F6-4A7C-B1E2-6B608BA21F08}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F3C7E51-02F6-4A7C-B1E2-6B608BA21F08}.Release|Any CPU.Build.0 = Release|Any CPU + {321FB2D5-3790-40AA-BFFB-EB18BE612C76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321FB2D5-3790-40AA-BFFB-EB18BE612C76}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321FB2D5-3790-40AA-BFFB-EB18BE612C76}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321FB2D5-3790-40AA-BFFB-EB18BE612C76}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = AndroidLSamples\AndroidLSamples.csproj EndGlobalSection EndGlobal diff --git a/android5.0/KitchenSink/AndroidLSamples/AndroidLSamples.csproj b/android5.0/KitchenSink/AndroidLSamples/AndroidLSamples.csproj index 2ec87e1..8ab63d0 100644 --- a/android5.0/KitchenSink/AndroidLSamples/AndroidLSamples.csproj +++ b/android5.0/KitchenSink/AndroidLSamples/AndroidLSamples.csproj @@ -1,226 +1,226 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{9F3C7E51-02F6-4A7C-B1E2-6B608BA21F08}</ProjectGuid> + <ProjectGuid>{321FB2D5-3790-40AA-BFFB-EB18BE612C76}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>AndroidLSamples</RootNamespace> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidApplication>True</AndroidApplication> <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <AssemblyName>AndroidLSamples</AssemblyName> <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidTlsProvider> </AndroidTlsProvider> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> <Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v4.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.CardView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.CardView.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.Palette, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.Palette.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.Palette.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath> <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Utils\Photos.cs" /> <Compile Include="Utils\HeightAdjustableImageView.cs" /> <Compile Include="Activities\AnimationActivity1.cs" /> <Compile Include="Activities\AnimationActivity2.cs" /> <Compile Include="Activities\CardActivity.cs" /> <Compile Include="Activities\HomeActivity.cs" /> <Compile Include="Activities\ImageDetailPaletteActivity.cs" /> <Compile Include="Activities\ImageListActivity.cs" /> <Compile Include="Activities\NotificationsActivity.cs" /> <Compile Include="Activities\RecyclerViewActivity.cs" /> <Compile Include="Activities\RecyclerViewActivityAddRemove.cs" /> <Compile Include="Activities\ThemesActivity.cs" /> <Compile Include="Activities\AnimationActivityMoveImage1.cs" /> <Compile Include="Activities\AnimationActivityMoveImage2.cs" /> <Compile Include="Activities\EvelvationActivity.cs" /> <Compile Include="Activities\AnimationRevealActivity.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\drawable\rect_blue.xml" /> <AndroidResource Include="Resources\drawable\rect_red.xml" /> <AndroidResource Include="Resources\drawable\rect_orange.xml" /> <AndroidResource Include="Resources\drawable\xamarin.png" /> <AndroidResource Include="Resources\values\colors.xml" /> <AndroidResource Include="Resources\drawable\evolve.jpg" /> <AndroidResource Include="Resources\layout\activity_recycler_view.axml" /> <AndroidResource Include="Resources\layout\activity_image_list.axml" /> <AndroidResource Include="Resources\layout\activity_image_detail.axml" /> <AndroidResource Include="Resources\layout\grid_item.axml" /> <AndroidResource Include="Resources\layout\item.axml" /> <AndroidResource Include="Resources\layout\palette_item.axml" /> <AndroidResource Include="Resources\layout\activity_card.axml" /> <AndroidResource Include="Resources\layout\activity_animations_1.axml" /> <AndroidResource Include="Resources\layout\activity_animations_2.axml" /> <AndroidResource Include="Resources\values\dimens.xml" /> <AndroidResource Include="Resources\layout\activity_themes.axml" /> <AndroidResource Include="Resources\drawable-nodpi\flying_in_the_light_large.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\jelly_fish_2.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\lone_pine_sunset.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\look_me_in_the_eye.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\over_there.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\rainbow.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\sample1.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\sample2.jpg" /> <AndroidResource Include="Resources\drawable-nodpi\caterpiller.jpg" /> <AndroidResource Include="Resources\values\attrs.xml" /> <AndroidResource Include="Resources\layout\recycleritem_card.axml" /> <AndroidResource Include="Resources\layout\activity_recycler_view_add_remove.axml" /> <AndroidResource Include="Resources\layout\activity_notifications.axml" /> <AndroidResource Include="Resources\drawable-hdpi\ic_notification.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_notification.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_notification.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_notification.png" /> <AndroidResource Include="Resources\menu\menu1.xml" /> <AndroidResource Include="Resources\menu\menu2.xml" /> <AndroidResource Include="Resources\layout\activity_elevation.axml" /> <AndroidResource Include="Resources\values\arrays.xml" /> <AndroidResource Include="Resources\layout\activity_reveal.axml" /> <AndroidResource Include="Resources\drawable\monkey.png" /> <AndroidResource Include="Resources\drawable\xamarin_white.png" /> <AndroidResource Include="Resources\drawable\mycircle.xml" /> <AndroidResource Include="Resources\drawable\shape.xml" /> <AndroidResource Include="Resources\drawable\shape2.xml" /> <AndroidResource Include="Resources\drawable\gear.jpg" /> <AndroidResource Include="Resources\values\styles.xml" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_edit.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_edit.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_edit.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_edit.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_content_save.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <ItemGroup> <Folder Include="Resources\drawable-nodpi\" /> <Folder Include="Utils\" /> <Folder Include="Activities\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> <Folder Include="Resources\menu\" /> </ItemGroup> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.Palette.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.Palette.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.Palette.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.Palette.targets'))" /> <Error Condition="!Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets'))" /> </Target> <Import Project="..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\build\MonoAndroid80\Xamarin.Android.Arch.Core.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.targets')" /> <Import Project="..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets" Condition="Exists('..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\build\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Annotations.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.UI.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Core.Utils.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Fragment.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.Media.Compat.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v4.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v4.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.CardView.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.Palette.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.Palette.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.Palette.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.Palette.targets')" /> <Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\build\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.targets')" /> </Project> diff --git a/android5.0/Toolbar/HelloToolbar.sln b/android5.0/Toolbar/HelloToolbar.sln index 1d66f7a..f63aa86 100644 --- a/android5.0/Toolbar/HelloToolbar.sln +++ b/android5.0/Toolbar/HelloToolbar.sln @@ -1,20 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloToolbar", "HelloToolbar\HelloToolbar.csproj", "{72FF247E-48FC-4828-BB0A-6D81E803245C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloToolbar", "HelloToolbar\HelloToolbar.csproj", "{85EE1526-F63D-4F61-8A9F-77A426A6DA26}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {72FF247E-48FC-4828-BB0A-6D81E803245C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72FF247E-48FC-4828-BB0A-6D81E803245C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72FF247E-48FC-4828-BB0A-6D81E803245C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72FF247E-48FC-4828-BB0A-6D81E803245C}.Release|Any CPU.Build.0 = Release|Any CPU + {85EE1526-F63D-4F61-8A9F-77A426A6DA26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85EE1526-F63D-4F61-8A9F-77A426A6DA26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85EE1526-F63D-4F61-8A9F-77A426A6DA26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85EE1526-F63D-4F61-8A9F-77A426A6DA26}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = HelloToolbar\HelloToolbar.csproj EndGlobalSection EndGlobal diff --git a/android5.0/Toolbar/HelloToolbar/HelloToolbar.csproj b/android5.0/Toolbar/HelloToolbar/HelloToolbar.csproj index a468f51..36175bf 100644 --- a/android5.0/Toolbar/HelloToolbar/HelloToolbar.csproj +++ b/android5.0/Toolbar/HelloToolbar/HelloToolbar.csproj @@ -1,94 +1,94 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <ProjectGuid>{72FF247E-48FC-4828-BB0A-6D81E803245C}</ProjectGuid> + <ProjectGuid>{85EE1526-F63D-4F61-8A9F-77A426A6DA26}</ProjectGuid> <OutputType>Library</OutputType> <RootNamespace>HelloToolbar</RootNamespace> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidApplication>True</AndroidApplication> <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> <AssemblyName>HelloToolbar</AssemblyName> <TargetFrameworkVersion>v5.0</TargetFrameworkVersion> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <ConsolePause>false</ConsolePause> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Mono.Android" /> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> <Compile Include="Resources\Resource.designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> <None Include="Properties\AndroidManifest.xml" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\layout\toolbar.axml" /> <AndroidResource Include="Resources\drawable\monkey.jpg" /> <AndroidResource Include="Resources\values\styles.xml" /> <AndroidResource Include="Resources\menu\home.xml" /> <AndroidResource Include="Resources\menu\photo_edit.xml" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_content_redo.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_social_share.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_content_undo.png" /> <AndroidResource Include="Resources\drawable-hdpi\ic_action_content_create.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_content_redo.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_social_share.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_content_undo.png" /> <AndroidResource Include="Resources\drawable-mdpi\ic_action_content_create.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_content_redo.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_social_share.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_content_undo.png" /> <AndroidResource Include="Resources\drawable-xhdpi\ic_action_content_create.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_content_redo.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_social_share.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_content_save.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_content_undo.png" /> <AndroidResource Include="Resources\drawable-xxhdpi\ic_action_content_create.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <ItemGroup> <Folder Include="Resources\menu\" /> <Folder Include="Resources\drawable-mdpi\" /> <Folder Include="Resources\drawable-hdpi\" /> <Folder Include="Resources\drawable-xhdpi\" /> <Folder Include="Resources\drawable-xxhdpi\" /> </ItemGroup> </Project> \ No newline at end of file
dotnet/android-samples
6056e81faeee8bb4a6d5d2613404a86037fd2920
Solving #273 - Avoids multiple picture callbacks (#300)
diff --git a/android5.0/Camera2Basic/Camera2Basic/Listeners/CameraCaptureListener.cs b/android5.0/Camera2Basic/Camera2Basic/Listeners/CameraCaptureListener.cs index 17466dd..16f294c 100644 --- a/android5.0/Camera2Basic/Camera2Basic/Listeners/CameraCaptureListener.cs +++ b/android5.0/Camera2Basic/Camera2Basic/Listeners/CameraCaptureListener.cs @@ -1,84 +1,85 @@ using Android.Hardware.Camera2; using Java.IO; using Java.Lang; namespace Camera2Basic.Listeners { public class CameraCaptureListener : CameraCaptureSession.CaptureCallback { private readonly Camera2BasicFragment owner; public CameraCaptureListener(Camera2BasicFragment owner) { if (owner == null) throw new System.ArgumentNullException("owner"); this.owner = owner; } public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { Process(result); } public override void OnCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult) { Process(partialResult); } private void Process(CaptureResult result) { switch (owner.mState) { case Camera2BasicFragment.STATE_WAITING_LOCK: { Integer afState = (Integer)result.Get(CaptureResult.ControlAfState); if (afState == null) { + owner.mState = Camera2BasicFragment.STATE_PICTURE_TAKEN; // avoids multiple picture callbacks owner.CaptureStillPicture(); } else if ((((int)ControlAFState.FocusedLocked) == afState.IntValue()) || (((int)ControlAFState.NotFocusedLocked) == afState.IntValue())) { // ControlAeState can be null on some devices Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState); if (aeState == null || aeState.IntValue() == ((int)ControlAEState.Converged)) { owner.mState = Camera2BasicFragment.STATE_PICTURE_TAKEN; owner.CaptureStillPicture(); } else { owner.RunPrecaptureSequence(); } } break; } case Camera2BasicFragment.STATE_WAITING_PRECAPTURE: { // ControlAeState can be null on some devices Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState); if (aeState == null || aeState.IntValue() == ((int)ControlAEState.Precapture) || aeState.IntValue() == ((int)ControlAEState.FlashRequired)) { owner.mState = Camera2BasicFragment.STATE_WAITING_NON_PRECAPTURE; } break; } case Camera2BasicFragment.STATE_WAITING_NON_PRECAPTURE: { // ControlAeState can be null on some devices Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState); if (aeState == null || aeState.IntValue() != ((int)ControlAEState.Precapture)) { owner.mState = Camera2BasicFragment.STATE_PICTURE_TAKEN; owner.CaptureStillPicture(); } break; } } } } -} \ No newline at end of file +}
dotnet/android-samples
d348adfe3a3efe70396c28cbddd3a94f80b02aba
[yaml] update repo README
diff --git a/README.md b/README.md index 9cea5db..51cd88b 100644 --- a/README.md +++ b/README.md @@ -1,129 +1,125 @@ -MonoDroid Samples -================= +# MonoDroid (Xamarin.Android) samples This repository contains Mono for Android samples, showing usage of various -Android API wrappers from C#. Visit the [Android Sample Gallery](https://developer.xamarin.com/samples/android/all/) +Android API wrappers from C#. Visit the [Android Sample Gallery](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) to download individual samples. -License -------- +## License The Apache License 2.0 applies to all samples in this repository. Copyright 2011 Xamarin Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -Contributing ------------- +## Contributing Before adding a sample to the repository, please run either install-hook.bat or install-hook.sh depending on whether you're on Windows or a POSIX system. This will install a Git hook that runs the Xamarin code sample validator before a commit, to ensure that all samples are good to go. -Samples Submission Guidelines -============================= +## Samples Submission Guidelines ## Galleries We love samples! Application samples show off our platform and provide a great way for people to learn our stuff. And we even promote them as a first-class feature of the docs site. You can find the sample galleries here: -* [Xamarin Forms Samples](http://developer.xamarin.com/samples/xamarin-forms/all/) +- [Xamarin.Forms Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Forms) -* [iOS Samples](http://developer.xamarin.com/samples/ios/all/) +- [iOS Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.iOS) -* [Mac Samples](http://developer.xamarin.com/samples/mac/all/) +- [Mac Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Mac) -* [Android Samples](http://developer.xamarin.com/samples/android/all/) +- [Android Samples](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android) ## Sample GitHub Repositories These sample galleries are populated by samples in these GitHub repos: -* [https://github.com/xamarin/xamarin-forms-samples](https://github.com/xamarin/xamarin-forms-samples) +- [https://github.com/xamarin/xamarin-forms-samples](https://github.com/xamarin/xamarin-forms-samples) -* [https://github.com/xamarin/mobile-samples](https://github.com/xamarin/mobile-samples) +- [https://github.com/xamarin/mobile-samples](https://github.com/xamarin/mobile-samples) -* [https://github.com/xamarin/ios-samples](https://github.com/xamarin/ios-samples) +- [https://github.com/xamarin/ios-samples](https://github.com/xamarin/ios-samples) -* [https://github.com/xamarin/mac-samples](https://github.com/xamarin/mac-samples) +- [https://github.com/xamarin/mac-samples](https://github.com/xamarin/mac-samples) -* [https://github.com/xamarin/monodroid-samples](https://github.com/xamarin/monodroid-samples) +- [https://github.com/xamarin/monodroid-samples](https://github.com/xamarin/monodroid-samples) -* [https://github.com/xamarin/mac-ios-samples](https://github.com/xamarin/mac-ios-samples) +- [https://github.com/xamarin/mac-ios-samples](https://github.com/xamarin/mac-ios-samples) The [mobile-samples](https://github.com/xamarin/mobile-samples) repository is for samples that are cross-platform. The [mac-ios-samples](https://github.com/xamarin/mac-ios-samples) repository is for samples that are Mac/iOS only. ## Sample Requirements We welcome sample submissions, please start by creating an issue with your proposal. Because the sample galleries are powered by the github sample repos, each sample needs to have the following things: -* **Screenshots** - a folder called Screenshots that has at least one screen shot of the sample (preferably a screen shot for every page or every major functionality piece, people really key off these things). for the xplat samples, the folder should be split into platform folders, e.g. iOS, Android, Windows. see[ https://github.com/xamarin/mobile-samples/tree/master/Tasky/Screenshots](https://github.com/xamarin/mobile-samples/tree/master/Tasky/Screenshots) for an example of this. +- **Screenshots** - a folder called Screenshots that has at least one screen shot of the sample on each platform (preferably a screen shot for every page or every major piece of functionality). For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo/Screenshots). -* **Readme** - a[ README.md](http://readme.md/) file that has the name of the sample, a description, and author attribution. sample here:[ https://github.com/xamarin/mobile-samples/blob/master/Tasky/README.md](https://github.com/xamarin/mobile-samples/blob/master/Tasky/README.md) +- **Readme** - a `README.md` file that explains the sample, and contains metadata to help customers find it. For an example of this, see [android-p/AndroidPMiniDemo](https://github.com/xamarin/monodroid-samples/blob/master/android-p/AndroidPMiniDemo/README.md). The README file should begin with a YAML header (delimited by `---`) with the following keys/values: -* **Metadata** - Finally, it needs a Metadata.xml file ([https://github.com/xamarin/mobile-samples/blob/master/Tasky/Metadata.xml](https://github.com/xamarin/mobile-samples/blob/master/Tasky/Metadata.xml)) that has some information: + - **name** - must begin with `Xamarin.Android -` - * **ID** - A GUID for the sample. You can generate this in MD under Tools menu : Insert GUID. we need this to key between articles and their associated samples + - **description** - brief description of the sample (&lt; 150 chars) that appears in the sample code browser search - * **IsFullApplication** - Boolean flag (true or false): whether or not this is a full application such as the MWC App, Tasky, etc., or it's just a feature sample, such as, how to use 'x' feature. the basic test here is, if you would submit this to the app store because it's useful, then it's a full app, otherwise it's just a feature sample. + - **page_type** - must be the string `sample`. - * **Brief** - Short description or what your sample does. This allows us to display a nice and clean vignette on the sample page. + - **languages** - coding language/s used in the sample, such as: `csharp`, `fsharp`, `vb`, `java` - * **Level** - Beginning, Intermediate, or Advanced: this is the intended audience level for the sample. only the getting started samples are Beginning, as they are intended for people who are _just_ starting with the platform. most samples are Intermediate, and a few, that dive deep into difficult APIs, should be Advanced. + - **products**: should be `xamarin` for every sample in this repo - * **Minimum License Requirement** - Starter, Indie, Business, or Enterprise: denotes the license that a user has to have in order to build/run the sample. + - **urlFragment**: although this can be auto-generated, please supply an all-lowercase value that represents the sample's path in this repo, except directory separators are replaced with dashes (`-`) and no other punctuation. - * **Tags**: a list of relevant tags for the app. These are: - * **Data** - * **Games** - * **Graphics** (CoreDrawing, Animation, OpenGL...) - * **Media** (Video, Sound, recording, photos) - * **Platform Features** (Photo Library, Contacts, Calendars, etc.) - * **Device Features** (NFC, Accelerometer, Compass, Magnemometer, Bluetooth, RFID) - * **Cloud** (Web Services, Networking, etc.) - * **Backgrounding** - * **Maps + Location** - * **Binding + Interop** (Projections) - * **Notifications** - * **Touch** - * **Getting Started** - * **Async** - * **FSharp** + Here is a working example from [_android-p/AndroidPMiniDemo_ README raw view](https://raw.githubusercontent.com/xamarin/monodroid-samples/master/android-p/AndroidPMiniDemo/README.md). - * **SupportedPlatforms**: this is only for cross plat samples. It's a comma-separated list, and the valid values are iOS, Android, and Windows. + ```yaml + --- + name: Xamarin.Android - Android P Mini Demo + description: "Demonstrates new display cutout and image notification features (Android Pie)" + page_type: sample + languages: + - csharp + products: + - xamarin + urlFragment: android-p-androidpminidemo + --- + # Heading 1 - * **Gallery**: This tag must contain a value of true if you want the sample to show up in the samples gallery on the developer portal. + rest of README goes here, including screenshot images and requirements/instructions to get it running + ``` -* **Buildable Sln and CSProj file** - the project _must_ build and have the appropriate project scaffolding (solution + proj). + > NOTE: This must be valid YAML, so some characters in the name or description will require the entire string to be surrounded by " or ' quotes. -A good example of this stuff is here in the drawing sample:[ https://github.com/xamarin/monotouch-samples/tree/master/Drawing](https://github.com/xamarin/ios-samples/tree/master/Drawing) +- **Buildable solution and .csproj file** - the project _must_ build and have the appropriate project scaffolding (solution + .csproj files). + +This approach ensures that all samples integrate with the Microsoft [sample code browser](https://docs.microsoft.com/samples/browse/?term=Xamarin.Android). + +A good example of this stuff is here in the [Android Pie sample](https://github.com/xamarin/monodroid-samples/tree/master/android-p/AndroidPMiniDemo) For a cross-platform sample, please see: https://github.com/xamarin/mobile-samples/tree/master/Tasky ## GitHub Integration We integrate tightly with Git to make sure we always provide working samples to our customers. This is achieved through a pre-commit hook that runs before your commit goes through, as well as a post-receive hook on GitHub's end that notifies our samples gallery server when changes go through. -To you, as a sample committer, this means that before you push to the repos, you should run the "install-hook.bat" or "install-hook.sh" (depending on whether you're on Windows or OS X/Linux, respectively). These will install the Git pre-commit hook. Now, whenever you try to make a Git commit, all samples in the repo will be validated. If any sample fails to validate, the commit is aborted; otherwise, your commit goes through and you can go ahead and push. +To you, as a sample committer, this means that before you push to the repos, you should run the "install-hook.bat" or "install-hook.sh" (depending on whether you're on Windows or macOS/Linux, respectively). These will install the Git pre-commit hook. Now, whenever you try to make a Git commit, all samples in the repo will be validated. If any sample fails to validate, the commit is aborted; otherwise, your commit goes through and you can go ahead and push. This strict approach is put in place to ensure that the samples we present to our customers are always in a good state, and to ensure that all samples integrate correctly with the sample gallery (README.md, Metadata.xml, etc). Note that the master branch of each sample repo is what we present to our customers for our stable releases, so they must *always* Just Work. -Should you wish to invoke validation of samples manually, simply run "validate.windows" or "validate.posix" (again, Windows vs OS X/Linux, respectively). These must be run from a Bash shell (i.e. a terminal on OS X/Linux or the Git Bash terminal on Windows). +Should you wish to invoke validation of samples manually, simply run "validate.windows" or "validate.posix" (again, Windows vs macOS/Linux, respectively). These must be run from a Bash shell (i.e. a terminal on macOS/Linux or the Git Bash terminal on Windows). If you have any questions, don't hesitate to ask! -
dotnet/android-samples
6492910fa90f5c4d73c7c1ab3d3fa0bdd4573b1a
[jnidemo] fix duplicates with case-different folder name
diff --git a/JniDemo/Assets/AboutAssets.txt b/JniDemo/Assets/AboutAssets.txt new file mode 100644 index 0000000..a9b0638 --- /dev/null +++ b/JniDemo/Assets/AboutAssets.txt @@ -0,0 +1,19 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories) and given a Build Action of "AndroidAsset". + +These files will be deployed with your package and will be accessible using Android's +AssetManager, like this: + +public class ReadAsset : Activity +{ + protected override void OnCreate (Bundle bundle) + { + base.OnCreate (bundle); + + InputStream input = Assets.Open ("my_asset.txt"); + } +} + +Additionally, some Android functions will automatically load asset files: + +Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); diff --git a/JniDemo/JNIDemo.csproj b/JniDemo/JNIDemo.csproj new file mode 100644 index 0000000..4dd1bd9 --- /dev/null +++ b/JniDemo/JNIDemo.csproj @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ProjectGuid>{3DAFCF28-6C90-48D9-8F5D-4C556AF76DD9}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>JNIDemo</RootNamespace> + <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> + <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> + <AndroidResgenClass>Resource</AndroidResgenClass> + <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> + <AndroidApplication>True</AndroidApplication> + <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> + <AssemblyName>JNIDemo</AssemblyName> + <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> + <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AndroidLinkMode>None</AndroidLinkMode> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>full</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Xml" /> + <Reference Include="System.Core" /> + <Reference Include="Mono.Android" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Resources\Resource.designer.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Activity1.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Resources\AboutResources.txt" /> + <None Include="Assets\AboutAssets.txt" /> + <None Include="Properties\AndroidManifest.xml" /> + </ItemGroup> + <ItemGroup> + <AndroidResource Include="Resources\values\Strings.xml" /> + <AndroidResource Include="Resources\drawable\Icon.png" /> + <AndroidResource Include="Resources\layout\HelloWorld.axml" /> + <AndroidResource Include="Resources\layout\Main.axml" /> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> + <ItemGroup> + <Folder Include="Resources\layout\" /> + </ItemGroup> + <ItemGroup> + <AndroidJavaSource Include="MyActivity.java" /> + </ItemGroup> +</Project> \ No newline at end of file diff --git a/JniDemo/JNIDemo.sln b/JniDemo/JNIDemo.sln new file mode 100644 index 0000000..6604c60 --- /dev/null +++ b/JniDemo/JNIDemo.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JNIDemo", "JNIDemo.csproj", "{3DAFCF28-6C90-48D9-8F5D-4C556AF76DD9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3DAFCF28-6C90-48D9-8F5D-4C556AF76DD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DAFCF28-6C90-48D9-8F5D-4C556AF76DD9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DAFCF28-6C90-48D9-8F5D-4C556AF76DD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DAFCF28-6C90-48D9-8F5D-4C556AF76DD9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = JNIDemo.csproj + EndGlobalSection +EndGlobal diff --git a/JniDemo/Resources/drawable/Icon.png b/JniDemo/Resources/drawable/Icon.png new file mode 100644 index 0000000..a07c69f Binary files /dev/null and b/JniDemo/Resources/drawable/Icon.png differ diff --git a/JniDemo/Resources/layout/Main.axml b/JniDemo/Resources/layout/Main.axml new file mode 100644 index 0000000..39263a0 --- /dev/null +++ b/JniDemo/Resources/layout/Main.axml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <Button + android:id="@+id/MyButton" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/StartActivity" /> +</LinearLayout> \ No newline at end of file diff --git a/JniDemo/Screenshots/csharp-activity.png b/JniDemo/Screenshots/csharp-activity.png new file mode 100644 index 0000000..8cf7cce Binary files /dev/null and b/JniDemo/Screenshots/csharp-activity.png differ diff --git a/JniDemo/Screenshots/java-activity.png b/JniDemo/Screenshots/java-activity.png new file mode 100644 index 0000000..4123f8a Binary files /dev/null and b/JniDemo/Screenshots/java-activity.png differ
dotnet/android-samples
a564d2e335bfa03e1b84243c096e2175161acc43
[jnidemo] tweaks
diff --git a/JniDemo/README.md b/JniDemo/README.md index 2c8b4c8..fd4e8af 100644 --- a/JniDemo/README.md +++ b/JniDemo/README.md @@ -1,72 +1,66 @@ --- name: Xamarin.Android - Java Native Invoke description: "How to manually bind to a Java library so it can be consumed by a Xamarin.Android application" page_type: sample languages: - csharp - java products: - xamarin urlFragment: jnidemo --- # Java Native Invoke Sample This sample shows how to manually bind to a Java library so it can be consumed by a Xamarin.Android application. ## Requirements -There is one requirement in order to build and run this sample: - - 1. Mono for Android Preview 13 or later. - -Commands that need to be executed are indicated within backticks (\`), -and **$ANDROID_SDK_PATH** is the directory that contains your Android SDK -installation. +**$ANDROID_SDK_PATH** is the directory that contains your Android SDK installation. ## How it works -As Mono for Android 1.0 does not support binding arbitrary .jar +As Xamarin.Android does not support binding arbitrary .jar files (only the Android SDK android.jar is bound), alternative -mechanisms must instead used for interoperation between Java and -managed code. Two primary mechanisms are: +mechanisms must instead be used for interoperation between Java and +managed code. Two primary mechanisms are: - 1. Android.Runtime.JNIEnv for creating instances of Java objects and + 1. `Android.Runtime.JNIEnv` for creating instances of Java objects and invoking methods on them from C#. This is very similar to - System.Reflection in that everything is string based and thus + `System.Reflection` in that everything is string based and thus untyped at compile time. 2. The ability to include Java source code and .jar files into the resulting Android application. -This sample uses mechanism (2) to demonstrate the Java Native Invoke capability. +This sample uses mechanism (2) to demonstrate the Java Native Invoke (JNI) capability. The Java source code is kept in **MyActivity.java**, which is included in the project with a **Build Action** of **AndroidJavaSource**. Furthermore, edit **Properties\AndroidManifest.xml** so that it contains one additional element: 1. A `/manifest/application/activity` element must be created so that we can use `Context.StartActivity()` to create the custom activity. This translates to having the following XML in **AndroidManifest.xml**: ```xml <application android:label="Managed Maps"> <uses-library android:name="com.google.android.maps" /> <activity android:name="mono.samples.jnitest.MyActivity" /> </application> <uses-permission android:name="android.permission.INTERNET" /> ``` **MyActivity.java** uses the **Resources\Layout\HelloWorld.axml** resource, which contains a LinearLayout with a Button and a TextView. **Activity1.cs** uses `Java.Lang.Class.FindClass()` to obtain a `Java.Lang.Class` instance for the custom `MyActivity` type, then we create an `Intent` to pass to `Activity.StartActivity()` to launch `MyActivity`. ![C# activity with button to start Java activity](Screenshots/csharp-activity.png) ![Java activity with hello world button](Screenshots/java-activity.png)
dotnet/android-samples
bfc00767c761f774b3ef0d4cfbf372d48fb36024
onboard missing samples
diff --git a/ApplicationFundamentals/ServiceSamples/MessengerServiceDemo/README.md b/ApplicationFundamentals/ServiceSamples/MessengerServiceDemo/README.md index dfc34da..f51d04f 100644 --- a/ApplicationFundamentals/ServiceSamples/MessengerServiceDemo/README.md +++ b/ApplicationFundamentals/ServiceSamples/MessengerServiceDemo/README.md @@ -1,26 +1,19 @@ --- -name: Xamarin.Android - Xamarin.Android Messenger and Service Sample -description: This solution is an example of IPC communication between an Android service and an Activity (using a Messenger and a Handler). It demonstates how... +name: Xamarin.Android - Messenger and Service +description: "Example of IPC communication between an Android service and an activity (using a messenger and a handler)" page_type: sample languages: - csharp products: - xamarin urlFragment: applicationfundamentals-servicesamples-messengerservicedemo --- # Xamarin.Android Messenger and Service Sample -This solution is an example of IPC communication between an Android service and an Activity (using a Messenger and a Handler). It demonstates how to perform one-way and two-way IPC calls between an Activity and a Service running in it's own process. +This solution is an example of IPC communication between an Android service and an Activity (using a Messenger and a Handler). It demonstrates how to perform one-way and two-way IPC calls between an Activity and a Service running in it's own process. Ensure that the **MessengerService** project is installed on the device _before_ the **MessengerClient** project. If the **MessengerClient** is inadvertently installed first, it will be necessary to uninstall it, install the **MessengerService** app, and then reinstall the **MessengerClient** project. -![](./Screenshots/service-messenger-activity.png) +![Buttons to test messenger services](Screenshots/service-messenger-activity.png) **Note**: Currently it is not possible to implement an `IsolatedProcess` in Xamarin.Android. Please see [Bugzilla 51940 - Services with isolated processes and custom Application class fail to resolve overloads properly](https://bugzilla.xamarin.com/show_bug.cgi?id=51940) for more details. - - -![Xamarin.Android Messenger and Service Sample application screenshot](Screenshots/service-messenger-activity.png "Xamarin.Android Messenger and Service Sample application screenshot") - -## Authors - -Tom Opgenorth ([email protected]) diff --git a/JNIDemo/Screenshots/Screenshot - CSharp Activity.png b/JNIDemo/Screenshots/csharp-activity.png similarity index 100% rename from JNIDemo/Screenshots/Screenshot - CSharp Activity.png rename to JNIDemo/Screenshots/csharp-activity.png diff --git a/JNIDemo/Screenshots/Screenshot - Java Activity.png b/JNIDemo/Screenshots/java-activity.png similarity index 100% rename from JNIDemo/Screenshots/Screenshot - Java Activity.png rename to JNIDemo/Screenshots/java-activity.png diff --git a/JniDemo/README.md b/JniDemo/README.md index 92be8d2..2c8b4c8 100644 --- a/JniDemo/README.md +++ b/JniDemo/README.md @@ -1,70 +1,72 @@ --- -name: Xamarin.Android - Java Native Invoke Sample -description: "How to manually bind to a Java library so it can be consumed by a Mono for Android application" +name: Xamarin.Android - Java Native Invoke +description: "How to manually bind to a Java library so it can be consumed by a Xamarin.Android application" page_type: sample languages: - csharp - java products: - xamarin urlFragment: jnidemo --- # Java Native Invoke Sample This sample shows how to manually bind to a Java library so it can be consumed by a Xamarin.Android application. ## Requirements There is one requirement in order to build and run this sample: 1. Mono for Android Preview 13 or later. -Commands that need to be executed are indicated within backticks (`), +Commands that need to be executed are indicated within backticks (\`), and **$ANDROID_SDK_PATH** is the directory that contains your Android SDK installation. ## How it works As Mono for Android 1.0 does not support binding arbitrary .jar files (only the Android SDK android.jar is bound), alternative mechanisms must instead used for interoperation between Java and managed code. Two primary mechanisms are: 1. Android.Runtime.JNIEnv for creating instances of Java objects and invoking methods on them from C#. This is very similar to System.Reflection in that everything is string based and thus untyped at compile time. 2. The ability to include Java source code and .jar files into the resulting Android application. -We will be using mechanism (2) in order to demonstrate the Java Native Invoke capability. +This sample uses mechanism (2) to demonstrate the Java Native Invoke capability. The Java source code is kept in **MyActivity.java**, which is included in the project with a **Build Action** of **AndroidJavaSource**. Furthermore, edit **Properties\AndroidManifest.xml** so that it contains one additional element: 1. A `/manifest/application/activity` element must be created so that we can use `Context.StartActivity()` to create the custom activity. -This translates to having the following XML within -AndroidManifest.xml: +This translates to having the following XML in +**AndroidManifest.xml**: ```xml <application android:label="Managed Maps"> <uses-library android:name="com.google.android.maps" /> <activity android:name="mono.samples.jnitest.MyActivity" /> </application> <uses-permission android:name="android.permission.INTERNET" /> ``` **MyActivity.java** uses the **Resources\Layout\HelloWorld.axml** resource, which contains a LinearLayout with a Button and a TextView. **Activity1.cs** uses `Java.Lang.Class.FindClass()` to obtain a `Java.Lang.Class` instance for the custom `MyActivity` type, then we create an `Intent` to pass to `Activity.StartActivity()` to launch `MyActivity`. + +![C# activity with button to start Java activity](Screenshots/csharp-activity.png) ![Java activity with hello world button](Screenshots/java-activity.png)
dotnet/android-samples
fc4c9b87a52f08309447fa97712cf1e326a70886
sample yaml updates
diff --git a/RemoteNotifications/Metadata.xml b/RemoteNotifications/Metadata.xml deleted file mode 100755 index 15ed5b7..0000000 --- a/RemoteNotifications/Metadata.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>96D227D3-5EB9-41F9-B641-CBB1759D944C</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Intermediate</Level> - <Tags>Cloud</Tags> - <SupportedPlatforms>Android</SupportedPlatforms> - <Gallery>true</Gallery> - <LicenseRequirement>Indie</LicenseRequirement> -</SampleMetadata> diff --git a/RemoteNotifications/README.md b/RemoteNotifications/README.md index 491cf12..49e5e9d 100755 --- a/RemoteNotifications/README.md +++ b/RemoteNotifications/README.md @@ -1,31 +1,20 @@ ---- -name: Xamarin.Android - Android GCM Remote Notifications -description: This sample app accompanies the article Remote Notifications with Google Cloud Messaging. Before you can use this sample, you must acquire the... -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: remotenotifications ---- # Android GCM Remote Notifications -This sample app accompanies the article -[Remote Notifications with Google Cloud Messaging](http://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-gcm/). -Before you can use this sample, you must acquire the necessary -credentials to use Google's servers; this process is explained in -[Google Cloud Messaging](http://developer.xamarin.com/guides/android/application_fundamentals/notifications/google-cloud-messaging). -In particular, you will need an *API Key* and a *Sender ID* to insert -into the example code before it can connect to GCM. - +## DEPRECATED - USE FIREBASE MESSAGING + +This sample app accompanies the article +[Remote Notifications with Google Cloud Messaging](https://docs.microsoft.com/xamarin/android/data-cloud/google-messaging/remote-notifications-with-gcm). + +Before you can use this sample, you must acquire the necessary +credentials to use Google's servers; this process is explained in +[Google Cloud Messaging](https://docs.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/google-cloud-messaging). +In particular, you will need an *API Key* and a *Sender ID* to insert +into the example code before it can connect to GCM. + Most of the action takes place "behind the scenes", and is to be observed by watching the output window while the app runs from the IDE. -![Android GCM Remote Notifications application screenshot](Screenshots/notification.png "Android GCM Remote Notifications application screenshot") - -## Author - -Copyright 2016 Xamarin +## Author Mark McLemore diff --git a/SanityTests/Metadata.xml b/SanityTests/Metadata.xml deleted file mode 100644 index 623ce55..0000000 --- a/SanityTests/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>70b5b28e-b949-448e-805c-7deffab13b79</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Advanced</Level> - <Tags>Data, Device Features</Tags> - <Gallery>true</Gallery> - <Brief>SanityTests is a hodgepodge of things to test various API interactions.</Brief> -</SampleMetadata> diff --git a/SanityTests/README.md b/SanityTests/README.md index af70771..a6970ac 100644 --- a/SanityTests/README.md +++ b/SanityTests/README.md @@ -1,29 +1,19 @@ ---- -name: Xamarin.Android - Sanity Tests -description: SanityTests is a hodgepodge of things to test various interactions, such as SQLite use, JNI use, P/Invoke use, SSL, compression, and all manner of... -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: sanitytests ---- # Sanity Tests SanityTests is a hodgepodge of things to test various interactions, such as SQLite use, JNI use, P/Invoke use, SSL, compression, and all manner of other things. This sample is *not* a "HOWTO" guide for how to 'properly' (sanely) do something; it's our internal "test suite" (ha!) "thrown over the wall" as it answers frequently recurring questions on the mailing list, such as how to use Android.Runtime.JNIEnv, Java integration, and more. Ideally such things will be split out into separate, easily digestible samples in the future (presumably as part of ApiDemo), but in the interest of expediency... Note: Building this project requires that the Android NDK be installed. The Android NDK is currently installed as part of the current installer, but previous installs may lack it or require additional configuration within your IDE to provide the path to the Android NDK. diff --git a/SearchableDictionary/README.md b/SearchableDictionary/README.md index cecd229..e4c2eb6 100644 --- a/SearchableDictionary/README.md +++ b/SearchableDictionary/README.md @@ -1,15 +1,15 @@ --- -name: Xamarin.Android - Searchable Dictionary v2 -description: This is a port of the Android Searchable Dictionary v2 sample. It demonstrates using Android's search framework. +name: Xamarin.Android - Searchable Dictionary +description: "Port of the Android Searchable Dictionary v2 sample. It demonstrates using Android's search framework" page_type: sample languages: - csharp products: - xamarin urlFragment: searchabledictionary --- # Searchable Dictionary v2 This is a port of the Android Searchable Dictionary v2 sample. It demonstrates using Android's search framework. diff --git a/SectionIndex/README.md b/SectionIndex/README.md index 4a0d35a..132b7c5 100644 --- a/SectionIndex/README.md +++ b/SectionIndex/README.md @@ -1,13 +1,13 @@ --- -name: Xamarin.Android - Section Index +name: Xamarin.Android - ListView Section Index description: This sample is part of the Android ListViews and Adapters series. page_type: sample languages: - csharp products: - xamarin urlFragment: sectionindex --- # Section Index -This sample is part of the Android ListViews and Adapters series. \ No newline at end of file +This sample is part of the [Xamarin.Android ListViews and Adapters series](https://docs.microsoft.com/xamarin/android/user-interface/layouts/list-view/parts-and-functionality). \ No newline at end of file diff --git a/ShareActionProviderDemo/README.md b/ShareActionProviderDemo/README.md index f7a994d..43e5954 100644 --- a/ShareActionProviderDemo/README.md +++ b/ShareActionProviderDemo/README.md @@ -1,13 +1,16 @@ --- name: Xamarin.Android - ShareActionProvider Demo -description: This example shows how to use the ShareActionProvider to share an image using Ice Cream Sandwich. +description: "Shows how to use the ShareActionProvider to share an image (Android Ice Cream Sandwich)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidicecreamsandwich urlFragment: shareactionproviderdemo --- # ShareActionProvider Demo This example shows how to use the ShareActionProvider to share an image using Ice Cream Sandwich. diff --git a/SimpleCursorTableAdapter/README.md b/SimpleCursorTableAdapter/README.md index 088488a..bad6778 100644 --- a/SimpleCursorTableAdapter/README.md +++ b/SimpleCursorTableAdapter/README.md @@ -1,13 +1,13 @@ --- name: Xamarin.Android - Simple Cursor Table Adapter description: This sample is part of the Android ListViews and Adapters series. page_type: sample languages: - csharp products: - xamarin urlFragment: simplecursortableadapter --- # Simple Cursor Table Adapter -This sample is part of the Android ListViews and Adapters series. \ No newline at end of file +This sample is part of the [Xamarin.Android ListViews and Adapters series](https://docs.microsoft.com/xamarin/android/user-interface/layouts/list-view/populating), [using a CursorAdapter](https://docs.microsoft.com/xamarin/android/user-interface/layouts/list-view/cursor-adapters). diff --git a/SimpleWidget/README.md b/SimpleWidget/README.md index 45da26e..95f57bb 100644 --- a/SimpleWidget/README.md +++ b/SimpleWidget/README.md @@ -1,22 +1,24 @@ --- name: Xamarin.Android - Simple Widget -description: This sample shows a simple widget which fetches the word of the day from Wiktionary. To Run Deploy to target device using Build -> Deploy Long tap... +description: "Shows a simple widget which fetches the word of the day from Wiktionary" page_type: sample languages: - csharp products: - xamarin urlFragment: simplewidget --- # Simple Widget This sample shows a simple widget which fetches the word of the day from Wiktionary. -# To Run +## To Run * Deploy to target device using Build -> Deploy * Long tap on the desktop * Choose Widgets -> Wiktionary Sample -The widget will be added to your desktop. \ No newline at end of file +The widget will be added to your desktop. + +![Android with widget displayed](Screenshots/SimpleWidget.png) diff --git a/SkeletonApp/Metadata.xml b/SkeletonApp/Metadata.xml deleted file mode 100644 index 883f703..0000000 --- a/SkeletonApp/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>8cd42de2-94eb-417e-83b3-280985bc7d02</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>User Interface</Tags> - <Gallery>true</Gallery> - <Brief>This is a simple application with an EditText control and clear/back buttons, plus a custom picture.</Brief> -</SampleMetadata> diff --git a/SkeletonApp/README.md b/SkeletonApp/README.md index f9e8475..2da939b 100644 --- a/SkeletonApp/README.md +++ b/SkeletonApp/README.md @@ -1,14 +1,6 @@ ---- -name: Xamarin.Android - Skeleton App -description: This is a simple application with an EditText control and clear/back buttons, plus a custom picture. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: skeletonapp ---- # Skeleton App This is a simple application with an EditText control and clear/back buttons, plus a custom picture. + +![Sample app screenshot](Screenshots/SkeletonApp1.png) diff --git a/Snake/README.md b/Snake/README.md index da62ba4..25ccfa5 100644 --- a/Snake/README.md +++ b/Snake/README.md @@ -1,13 +1,18 @@ --- name: Xamarin.Android - Snake -description: A plain old Snake game based on a TileView. +description: "A plain old Snake game based on a TileView (game)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - game urlFragment: snake --- # Snake A plain old Snake game based on a TileView. + +![Android snake game emulator screenshot](Screenshots/Snake.png) diff --git a/SplashScreen/README.md b/SplashScreen/README.md index a7cbf08..eab1cbb 100755 --- a/SplashScreen/README.md +++ b/SplashScreen/README.md @@ -1,20 +1,17 @@ --- name: Xamarin.Android - Creating a Splash Screen -description: This sample demonstrates one technique for creating a splash screen in a Xamarin.Android application. It is the companion code for the... +description: "Demonstrates one technique for creating a splash screen in a Xamarin.Android application" page_type: sample languages: - csharp products: - xamarin urlFragment: splashscreen --- # Creating a Splash Screen This sample demonstrates one technique for creating a splash screen in a Xamarin.Android application. It is the companion code for the Xamarin.Android -guide [Creating a Splash Screen](https://docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen/). - - -![logo](https://docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen-images/splashscreen-01.png) - +guide [Creating a Splash Screen](https://docs.microsoft.com/xamarin/android/user-interface/splash-screen/). +![Xamarin logo splash screen](Screenshots/SplashScreen1.png) diff --git a/StorageClient/README.md b/StorageClient/README.md index 46ccbc6..b6b733f 100644 --- a/StorageClient/README.md +++ b/StorageClient/README.md @@ -1,18 +1,21 @@ --- name: Xamarin.Android - Storage Client -description: This sample demonstrates how to use the ACTIONOPENDOCUMENT intent to let users choose a file via the system's file browser. This intent allows a... +description: "Demonstrates how to use the ACTIONOPENDOCUMENT intent to let users choose a file via the system's file browser" page_type: sample languages: - csharp products: - xamarin urlFragment: storageclient --- # Storage Client + This sample demonstrates how to use the ACTION_OPEN_DOCUMENT -intent to let users choose a file via the system's file browser. -This intent allows a client application to access a list of +intent to let users choose a file via the system's file browser. +This intent allows a client application to access a list of document providers on the device, and choose a file from any of them. Installing this sample alongside `Storage Provider` allows this sample -to access our own document provider in addition to the others on device. \ No newline at end of file +to access our own document provider in addition to the others on device. + +![Android app showing stored files](Screenshots/StorageClient2.png) diff --git a/StorageProvider/README.md b/StorageProvider/README.md index 3cb0242..8ce75f5 100644 --- a/StorageProvider/README.md +++ b/StorageProvider/README.md @@ -1,17 +1,20 @@ --- name: Xamarin.Android - Storage Provider -description: This sample demonstrates how to use the DocumentsProvider API to manage documents and expose them to the Android system for sharing. The Storage... +description: "Demonstrates how to use the DocumentsProvider API to manage documents and expose them to the Android system for sharing" page_type: sample languages: - csharp products: - xamarin urlFragment: storageprovider --- # Storage Provider -This sample demonstrates how to use the DocumentsProvider API to manage + +This sample demonstrates how to use the DocumentsProvider API to manage documents and expose them to the Android system for sharing. The `Storage Client` sample can be used to access this provider. Toggling -the `LOG IN` button will hide or show `MyCloud` in the document providers -list within `Storage Provider`. \ No newline at end of file +the `LOG IN` button will hide or show `MyCloud` in the document providers +list within `Storage Provider`. + +![Android app screenshot](Screenshots/StorageProvider1.png) diff --git a/Supportv7/ActionBarCompat-ListPopupMenu/README.md b/Supportv7/ActionBarCompat-ListPopupMenu/README.md index 0783b26..ffcf17d 100644 --- a/Supportv7/ActionBarCompat-ListPopupMenu/README.md +++ b/Supportv7/ActionBarCompat-ListPopupMenu/README.md @@ -1,42 +1,42 @@ --- -name: Xamarin.Android - ActionBarCompat ListPopupMenu Sample -description: This sample shows how to display a pop up menu using PopupMenu from the v7 appcompat library. Introduction This sample displays a list of items and... +name: Xamarin.Android - ActionBarCompat ListPopupMenu +description: "How to display a pop up menu using PopupMenu from the v7 appcompat library" page_type: sample languages: - csharp products: - xamarin urlFragment: supportv7-actionbarcompat-listpopupmenu --- # ActionBarCompat ListPopupMenu Sample This sample shows how to display a pop up menu using PopupMenu from the v7 appcompat library. ## Introduction This sample displays a list of items and for each item, an icon can be clicked. When it is clicked, a pop up menu is shown, placed below the item, using the PopupMenu from the v7 appcompat support library. The sample uses ListFragment from the v4 support library to display the list. It shows how to instantiate and display the PopupMenu, as well as how to use `SetOnMenuItemClickListener()` to process the user actions on the PopupMenu. ## Instructions * Tap on any delicious cheese in the list * Observe a pop up menu being shown * Tap 'Remove' on pop up menu * Observe the delicious cheese being removed from the list ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.1 (API level 21). ## Screenshots -<img src="Screenshots/1-popup.png" height="400" alt="Screenshot"/> <img src="Screenshots/2-removed-item.png" height="400" alt="Screenshot"/> +![ActionBarCompat ListPopupMenu Sample application screenshot](Screenshots/1-popup.png) + +![ActionBarCompat ListPopupMenu Sample application screenshot](Screenshots/2-removed-item.png) -![ActionBarCompat ListPopupMenu Sample application screenshot](Screenshots/1-popup.png "ActionBarCompat ListPopupMenu Sample application screenshot") +## License -## Authors Copyright (c) 2014 The Android Open Source Project, Inc. Ported from [Android ActionBarCompat-ListPopupMenu Sample](https://github.com/googlesamples/android-ActionBarCompat-ListPopupMenu) - -Ported to Xamarin.Android by Dylan Kelly diff --git a/Supportv7/AppCompat/Toolbar/README.md b/Supportv7/AppCompat/Toolbar/README.md index 9f5115c..e650243 100644 --- a/Supportv7/AppCompat/Toolbar/README.md +++ b/Supportv7/AppCompat/Toolbar/README.md @@ -1,31 +1,31 @@ --- name: Xamarin.Android - Support v7 Toolbar -description: Basic sample of replacing the ActionBar with the new Support v7 app compat Toolbar. Instructions Run the project Click on the Toolbar items to see... +description: "Sample of replacing the ActionBar with the new Support v7 app compat Toolbar" page_type: sample languages: - csharp products: - xamarin urlFragment: supportv7-appcompat-toolbar --- # Support v7 Toolbar Basic sample of replacing the ActionBar with the new Support v7 app compat Toolbar. ## Instructions * Run the project * Click on the Toolbar items to see click handlers * Click photo to navigate to details page ## Build Requirements + * Xamarin Studio 5.5+ * Xamarin Android 4.20+ * Android SDK with Android 5.0 ![Support v7 Toolbar application screenshot](Screenshots/Details.png "Support v7 Toolbar application screenshot") -## Author -Copyright 2014 Xamarin +## License -Created by James Montemagno +Copyright 2014 Xamarin diff --git a/Supportv7/Pallete/README.md b/Supportv7/Pallete/README.md index 9890ecc..789214f 100644 --- a/Supportv7/Pallete/README.md +++ b/Supportv7/Pallete/README.md @@ -1,31 +1,31 @@ --- name: Xamarin.Android - Support v7 Palette -description: Basic sample of custom theming your application with the Palette support library. Instructions Run the project Click on an item in the GridView to... +description: "Sample of custom theme-ing your application with the Palette support library" page_type: sample languages: - csharp products: - xamarin urlFragment: supportv7-pallete --- # Support v7 Palette -Basic sample of custom theming your application with the Palette support library. +Basic sample of custom theme-ing your application with the Palette support library. ## Instructions * Run the project * Click on an item in the GridView to go to details page * Click Apply Palette to see palette generation ## Build Requirements + * Xamarin Studio 5.5+ * Xamarin Android 4.20+ * Android SDK with Android 5.0 ![Support v7 Palette application screenshot](Screenshots/Palette1.png "Support v7 Palette application screenshot") -## Author -Copyright 2014 Xamarin +## License -Created by James Montemagno +Copyright 2014 Xamarin diff --git a/SvgAndroid/Metadata.xml b/SvgAndroid/Metadata.xml deleted file mode 100644 index f176c02..0000000 --- a/SvgAndroid/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>92e60f0e-7084-452a-89fd-2c689fa1edc6</ID> - <IsFullApplication>true</IsFullApplication> - <Level>Beginning</Level> - <Tags>Binding + Interop</Tags> - <Gallery>true</Gallery> - <Brief>A binding example for svg-android Java library.</Brief> -</SampleMetadata> diff --git a/SvgAndroid/README.md b/SvgAndroid/README.md index c792f51..a60a850 100644 --- a/SvgAndroid/README.md +++ b/SvgAndroid/README.md @@ -1,18 +1,7 @@ ---- -name: Xamarin.Android - svg-android binding -description: 'It is a binding example for svg-android Java library. svg-android project is located at: http://code.google.com/p/svg-android/ svg-android is under...' -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: svgandroid ---- # svg-android binding It is a binding example for svg-android Java library. svg-android project is located at: http://code.google.com/p/svg-android/ svg-android is under Apache license 2.0 (see NOTICE). - diff --git a/SwipeToRefresh/README.md b/SwipeToRefresh/README.md index c8db4cd..b0c1304 100644 --- a/SwipeToRefresh/README.md +++ b/SwipeToRefresh/README.md @@ -1,13 +1,13 @@ --- name: Xamarin.Android - Swipe to Refresh -description: This sample demonstrates how to implement the swipe to refresh pattern using the support library SwipeRefreshLayout class. +description: "Demonstrates how to implement the swipe to refresh pattern using the support library SwipeRefreshLayout class" page_type: sample languages: - csharp products: - xamarin urlFragment: swipetorefresh --- # Swipe to Refresh -This sample demonstrates how to implement the swipe to refresh pattern using the support library `SwipeRefreshLayout` class. \ No newline at end of file +This sample demonstrates how to implement the swipe to refresh pattern using the support library `SwipeRefreshLayout` class.
dotnet/android-samples
105a9d4599be45afa8799ed283fc32560632f3d7
remove GL samples from gallery eligibility
diff --git a/GLCube-1.0/Metadata.xml b/GLCube-1.0/Metadata.xml deleted file mode 100644 index 3423d3a..0000000 --- a/GLCube-1.0/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>a50742de-aba9-45ea-989c-dca7b3e3456e</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>true</Gallery> - <Brief>This sample demonstrates simple drawing via OpenTK's GL APIs by drawing a rotating cube.</Brief> -</SampleMetadata> diff --git a/GLCube-1.0/README.md b/GLCube-1.0/README.md index 31f2833..fc5d957 100644 --- a/GLCube-1.0/README.md +++ b/GLCube-1.0/README.md @@ -1,17 +1,8 @@ ---- -name: Xamarin.Android - GL Rotating Cube -description: This sample demonstrates simple drawing via OpenTK's GL APIs by drawing a rotating cube. See Also GLCube -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: glcube-10 ---- # GL Rotating Cube This sample demonstrates simple drawing via OpenTK's GL APIs by drawing a rotating cube. ## See Also + * [GLCube](https://github.com/xamarin/monodroid-samples/tree/master/GLCube) diff --git a/GLCube/Metadata.xml b/GLCube/Metadata.xml deleted file mode 100644 index 0df77bf..0000000 --- a/GLCube/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>a50742de-aba9-45ea-989c-dca7b3e3456e</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>false</Gallery> - <Brief>This sample demonstrates simple drawing via OpenTK's GL APIs by drawing a rotating cube.</Brief> -</SampleMetadata> diff --git a/GLCube/README.md b/GLCube/README.md index b1b2381..df5fcc6 100644 --- a/GLCube/README.md +++ b/GLCube/README.md @@ -1,16 +1,6 @@ ---- -name: Xamarin.Android - GL Rotating Cube -description: This sample is now obsolete. Please use GLCube-1.0. This sample demonstrates simple drawing via OpenTK's GL APIs by drawing a rotating cube. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: glcube ---- # GL Rotating Cube -### This sample is now obsolete. Please use GLCube-1.0. +## This sample is now obsolete. Please use GLCube-1.0. This sample demonstrates simple drawing via OpenTK's GL APIs by drawing a rotating cube. diff --git a/GLDiagnostics-1.0/Metadata.xml b/GLDiagnostics-1.0/Metadata.xml deleted file mode 100644 index 86f2a76..0000000 --- a/GLDiagnostics-1.0/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>73A74ADF-6308-42A0-8BA6-2B5D53238549</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>true</Gallery> - <Brief>This sample tests all possible graphics configuration options and outputs valid ones.</Brief> -</SampleMetadata> diff --git a/GLDiagnostics-1.0/README.md b/GLDiagnostics-1.0/README.md index ba140e2..99e5069 100644 --- a/GLDiagnostics-1.0/README.md +++ b/GLDiagnostics-1.0/README.md @@ -1,17 +1,8 @@ ---- -name: Xamarin.Android - GL Diagnostics -description: This sample tests all possible graphics configuration options and outputs valid ones. See Also GLDiagnostics -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: gldiagnostics-10 ---- # GL Diagnostics This sample tests all possible graphics configuration options and outputs valid ones. ## See Also + * [GLDiagnostics](https://github.com/xamarin/monodroid-samples/tree/master/GLDiagnostics) diff --git a/GLDiagnostics/Metadata.xml b/GLDiagnostics/Metadata.xml deleted file mode 100644 index f66e5f6..0000000 --- a/GLDiagnostics/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>73A74ADF-6308-42A0-8BA6-2B5D53238549</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>false</Gallery> - <Brief>This sample tests all possible graphics configuration options and outputs valid ones.</Brief> -</SampleMetadata> diff --git a/GLDiagnostics/README.md b/GLDiagnostics/README.md index 21b15f0..217bd75 100644 --- a/GLDiagnostics/README.md +++ b/GLDiagnostics/README.md @@ -1,16 +1,6 @@ ---- -name: Xamarin.Android - GL Diagnostics -description: This sample is now obsolete. Please use GLDiagnostics-1.0. This sample tests all possible graphics configuration options and outputs valid ones. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: gldiagnostics ---- # GL Diagnostics -### This sample is now obsolete. Please use GLDiagnostics-1.0. +## This sample is now obsolete. Please use GLDiagnostics-1.0. This sample tests all possible graphics configuration options and outputs valid ones. diff --git a/GLDiagnostics30/Metadata.xml b/GLDiagnostics30/Metadata.xml deleted file mode 100644 index 86f2a76..0000000 --- a/GLDiagnostics30/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>73A74ADF-6308-42A0-8BA6-2B5D53238549</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>true</Gallery> - <Brief>This sample tests all possible graphics configuration options and outputs valid ones.</Brief> -</SampleMetadata> diff --git a/GLDiagnostics30/README.md b/GLDiagnostics30/README.md index b95e2df..bec4c1d 100644 --- a/GLDiagnostics30/README.md +++ b/GLDiagnostics30/README.md @@ -1,14 +1,4 @@ ---- -name: Xamarin.Android - GL Diagnostics -description: This sample tests all possible graphics configuration options and outputs valid ones. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: gldiagnostics30 ---- # GL Diagnostics This sample tests all possible graphics configuration options and outputs valid ones. diff --git a/GLTriangle20-1.0/Metadata.xml b/GLTriangle20-1.0/Metadata.xml deleted file mode 100644 index 1c259e6..0000000 --- a/GLTriangle20-1.0/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>cfe76357-6ea9-4d7c-ae03-92a37f66aaa7</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>false</Gallery> - <Brief>OpenGL ES 2.0 Demonstration.</Brief> -</SampleMetadata> diff --git a/GLTriangle20-1.0/README.md b/GLTriangle20-1.0/README.md index 6e958df..284716e 100644 --- a/GLTriangle20-1.0/README.md +++ b/GLTriangle20-1.0/README.md @@ -1,21 +1,11 @@ ---- -name: Xamarin.Android - GL Triangle 20 -description: 'OpenGL ES 2.0 Demonstration. Requirements There is one requirement to run this sample: 1. A device with OpenGL ES 2.0 support. Note that emulators...' -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: gltriangle20-10 ---- # GL Triangle 20 OpenGL ES 2.0 Demonstration. ## Requirements There is one requirement to run this sample: 1. A device with OpenGL ES 2.0 support. Note that emulators targeting API levels 1 through 13 provide only OpenGL ES 1.0 support, not 2.0. diff --git a/GLTriangle20/Metadata.xml b/GLTriangle20/Metadata.xml deleted file mode 100644 index 1c259e6..0000000 --- a/GLTriangle20/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>cfe76357-6ea9-4d7c-ae03-92a37f66aaa7</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>false</Gallery> - <Brief>OpenGL ES 2.0 Demonstration.</Brief> -</SampleMetadata> diff --git a/GLTriangle20/README.md b/GLTriangle20/README.md index 6bb519b..b966410 100644 --- a/GLTriangle20/README.md +++ b/GLTriangle20/README.md @@ -1,23 +1,13 @@ ---- -name: Xamarin.Android - GL Triangle 20 -description: 'This sample is now obsolete. Please use GLTriangle20-1.0. OpenGL ES 2.0 Demonstration. Requirements There is one requirement to run this sample: 1....' -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: gltriangle20 ---- # GL Triangle 20 -### This sample is now obsolete. Please use GLTriangle20-1.0. +## This sample is now obsolete. Please use GLTriangle20-1.0. OpenGL ES 2.0 Demonstration. ## Requirements There is one requirement to run this sample: 1. A device with OpenGL ES 2.0 support. Note that emulators targeting API levels 1 through 13 provide only OpenGL ES 1.0 support, not 2.0. diff --git a/GLTriangle30/Metadata.xml b/GLTriangle30/Metadata.xml deleted file mode 100644 index 0f24221..0000000 --- a/GLTriangle30/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>cfe76357-6ea9-4d7c-ae03-92a37f66aaa7</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Beginning</Level> - <Tags>Graphics</Tags> - <Gallery>true</Gallery> - <Brief>OpenTK 3.0 version of GLTriangle.</Brief> -</SampleMetadata> diff --git a/GLTriangle30/README.md b/GLTriangle30/README.md index f652507..12117bc 100644 --- a/GLTriangle30/README.md +++ b/GLTriangle30/README.md @@ -1,26 +1,16 @@ ---- -name: Xamarin.Android - GL Triangle 30 -description: 'OpenTK 3.0 version of GLTriangle Requirements There is one requirement to run this sample: 1. A device with OpenGL ES 3.0 support. Note that...' -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: gltriangle30 ---- # GL Triangle 30 OpenTK 3.0 version of GLTriangle ## Requirements There is one requirement to run this sample: 1. A device with OpenGL ES 3.0 support. Note that emulators targeting API levels 1 through 13 provide only OpenGL ES 1.0 support, not 2.0. - ## See Also + * [GLTriangle20](https://github.com/xamarin/monodroid-samples/tree/master/GLTriangle20) * [GLTriangle20-1.0](https://github.com/xamarin/monodroid-samples/tree/master/GLTriangle20-1.0)
dotnet/android-samples
cfc46737d670f36c4fd4622de12eacd2cc193f1c
onboard missing samples (inc Wear)
diff --git a/WalkingGameCompleteAndroid/README.md b/WalkingGameCompleteAndroid/README.md index 8171e8c..a94d346 100644 --- a/WalkingGameCompleteAndroid/README.md +++ b/WalkingGameCompleteAndroid/README.md @@ -1,21 +1,20 @@ --- name: Xamarin.Android - MonoGame WalkingGame Project for Android -description: This is a small demo game using MonoGame for Android. It is the result of working through the the entire Introduction to Monogame walkthrough. This... +description: "Small demo game using MonoGame for Android. It is the result of working through the the entire Introduction to Monogame walkthrough" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - monogame urlFragment: walkinggamecompleteandroid --- # MonoGame WalkingGame Project for Android -This is a small demo game using MonoGame for Android. It is the result of working through the the entire Introduction to Monogame walkthrough. +This is a small demo game using MonoGame for Android. It is the result of working through the the entire [Introduction to Monogame walkthrough](https://docs.microsoft.com/xamarin/graphics-games/monogame/introduction/part2). This single solution contains two projects: one for Android and one cross-platform portable class library. The demo can be played by touching the screen to move the character around the screen. - -## Author - -Victor Chelaru \ No newline at end of file diff --git a/WalkingGameEmptyAndroid/README.md b/WalkingGameEmptyAndroid/README.md index 718ec68..ffe04cf 100644 --- a/WalkingGameEmptyAndroid/README.md +++ b/WalkingGameEmptyAndroid/README.md @@ -1,23 +1,22 @@ --- -name: Xamarin.Android - MonoGame Empty Project for Android -description: This project serves as a starting-point for MonoGame Android projects. It is the result of working through the Part 2 - Creating a MonoGame Android... +name: Xamarin.Android - MonoGame Empty Project +description: "This project serves as a starting-point for MonoGame Android projects" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - monogame urlFragment: walkinggameemptyandroid --- # MonoGame Empty Project for Android -This project serves as a starting-point for MonoGame Android projects. It is the result of working through the Part 2 - Creating a MonoGame Android Project walkthrough. It is titled WalkingGame as that is the name of the project created by the full Introduction to MonoGame walkthrough. +This project serves as a starting-point for MonoGame Android projects. It is the result of working through the [Part 2 - Creating a MonoGame Android Project walkthrough](https://docs.microsoft.com/xamarin/graphics-games/monogame/introduction/part2). It is titled WalkingGame as that is the name of the project created by the full Introduction to MonoGame walkthrough. This single solution contains two projects: one for Android and one cross-platform portable class library. When executed this project displays only a blue screen. ![MonoGame Empty Project for Android application screenshot](Screenshots/Screenshot1.png "MonoGame Empty Project for Android application screenshot") - -## Author - -Victor Chelaru \ No newline at end of file diff --git a/WebViewJavaScriptInterface/README.md b/WebViewJavaScriptInterface/README.md index b1788cf..ff2de83 100644 --- a/WebViewJavaScriptInterface/README.md +++ b/WebViewJavaScriptInterface/README.md @@ -1,48 +1,48 @@ --- name: Xamarin.Android - WebView JavaScript Interface -description: This demonstrates C - to - JavaScript interoperability in WebView (through Java interface). For the API details, see:... +description: "Demonstrates C# to JavaScript interoperability in WebView (through Java interface)" page_type: sample languages: - csharp +- javascript products: - xamarin urlFragment: webviewjavascriptinterface --- # WebView JavaScript Interface -This demonstrates C# - to - JavaScript interoperability in WebView (through +This demonstrates C# to JavaScript interoperability in WebView (through Java interface). For the API details, see: -http://docs.mono-android.net/?link=M%3aAndroid.Webkit.WebView.AddJavascriptInterface%28Java.Lang.Object%2cSystem.String%29 +https://docs.microsoft.com/dotnet/api/android.webkit.webview.addjavascriptinterface This sample requires Mono for Android 4.1 or later, since it makes use of Java.Interop.ExportAttribute. - -# Testing Note +## Testing Note _DO NOT RUN_ this sample on an API 10 (Android v2.3.3) emulator; it _will_ break W/dalvikvm( 390): JNI WARNING: jarray 0x40549fe8 points to non-array object (Ljava/lang/String;) I/dalvikvm( 390): "WebViewCoreThread" prio=5 tid=11 NATIVE I/dalvikvm( 390): | group="main" sCount=0 dsCount=0 obj=0x40522a58 self=0x310c18 I/dalvikvm( 390): | sysTid=411 nice=0 sched=0/0 cgrp=default handle=3639344 I/dalvikvm( 390): | schedstat=( 420074041 479837048 123 ) I/dalvikvm( 390): at android.webkit.WebViewCore.nativeTouchUp(Native Method) I/dalvikvm( 390): at android.webkit.WebViewCore.nativeTouchUp(Native Method) I/dalvikvm( 390): at android.webkit.WebViewCore.access$3300(WebViewCore.java:53) I/dalvikvm( 390): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1158) I/dalvikvm( 390): at android.os.Handler.dispatchMessage(Handler.java:99) I/dalvikvm( 390): at android.os.Looper.loop(Looper.java:123) I/dalvikvm( 390): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629) I/dalvikvm( 390): at java.lang.Thread.run(Thread.java:1019) I/dalvikvm( 390): E/dalvikvm( 390): VM aborting W/ ( 390): Thread 0x0 may have been prematurely finalized D/Zygote ( 33): Process 390 terminated by signal (11) Why? Android bug: * http://code.google.com/p/android/issues/detail?id=12987 * http://stackoverflow.com/questions/5253916/why-does-the-webviewdemo-die diff --git a/tv/TvLeanback/README.md b/tv/TvLeanback/README.md index e83e3cc..c401615 100644 --- a/tv/TvLeanback/README.md +++ b/tv/TvLeanback/README.md @@ -1,31 +1,34 @@ --- name: Xamarin.Android - TvLeanback description: 'This sample shows a basic Android-TV application by showcasing various video provided by Google' page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidtv urlFragment: tv-tvleanback --- # TvLeanback -This sample shows a basic Android-TV application by showcasing various video provided by Google. +This sample shows a basic Android-TV application by showcasing various video provided by Google. ## Note This sample may crash due to a [bug](https://code.google.com/p/android/issues/detail?id=73920) in the native Android System. ## Build Requirements This sample is designed for Android-TV but can run on the Android L developer preview. It also requires Xamarin.Android 4.17+. ![TvLeanback application screenshot](Screenshots/home.png "TvLeanback application screenshot") ## License This project relies on the Picasso Project by Jake Warton and is used under the Apache License Version 2. The C# bindings used by this app were created by Jack Sierkstra. The original project by Jake Warton is available from: https://github.com/square/picasso The bindings are available from: https://github.com/jacksierkstra/Picasso Copyright (c) 2013, The Android Open Source Project diff --git a/tv/VisualGameController/README.md b/tv/VisualGameController/README.md index 4b65e21..f42e6e8 100644 --- a/tv/VisualGameController/README.md +++ b/tv/VisualGameController/README.md @@ -1,28 +1,31 @@ --- name: Xamarin.Android - Visual Game Controller description: AndroidTV sample that demonstrates the use of input from a game controller by displaying input events on the screen on a virtual controller page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidtv urlFragment: tv-visualgamecontroller --- # Visual Game Controller This AndroidTV sample demonstrates the use of input from a game controller by displaying input events on the screen on a virtual controller as they happen. ## Instructions * Press buttons and move axes on an attached game controller and the input that you give will be recreated on-screen. * Keep in mind that the button mapping is different for different types of game controllers. The sample has the differences between Xbox game controllers and Android game controllers in the comments as the item in question is drawn. ## Build Requirements Using this sample requires an android tv or android l device and Xamarin.Android version 4.17 or later. ![Visual Game Controller application screenshot](Screenshots/Screenshot1.png "Visual Game Controller application screenshot") ## License Copyright (c) 2005-2008, The Android Open Source Project diff --git a/wear/AgendaData/README.md b/wear/AgendaData/README.md index 369eb98..67019e8 100644 --- a/wear/AgendaData/README.md +++ b/wear/AgendaData/README.md @@ -1,31 +1,34 @@ --- -name: Xamarin.Android - AgendaData Sample +name: Xamarin.Android - Agenda Data description: This sample demonstrates sending calendar events from an Android handheld device to an Android Wear device, as well as deleting those... page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-agendadata --- # AgendaData Sample This sample demonstrates sending calendar events from an Android handheld device to an Android Wear device, as well as deleting those events. ## Instructions * Launch the AgendaData project onto the phone or tablet and the Wearable project onto the wearable device * If you have no calendar events on the phone or tablet, make one * Press the "Sync calendar events to wearable" button to add your calendar events to the wearable * Press the "Delete calendar events from wearable" to delete the events from the wearable ## Build Requirements Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![AgendaData Sample application screenshot](Screenshots/Default view.png "AgendaData Sample application screenshot") ## License Copyright (c) 2005-2008, The Android Open Source Project diff --git a/wear/DataLayer/README.md b/wear/DataLayer/README.md index 59ad520..0f7c970 100644 --- a/wear/DataLayer/README.md +++ b/wear/DataLayer/README.md @@ -1,35 +1,38 @@ --- name: Xamarin.Android - DataLayer Sample description: This sample demonstrates using the wearable APIs to send messages and stream data (an image in this sample) from Android to Android... page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-datalayer --- # DataLayer Sample This sample demonstrates using the wearable APIs to send messages and stream data (an image in this sample) from an Android device to an Android Wear device. ## Instructions * Download Xamarin Studio 5.3 or higher and open the project solution. Right click the project DataLayer and set it as the startup project, then click build in the application menu. Then right click the project Wearable, set it as the startup project, then click build in the application menu. * You will need to deploy DataLayer to a physical Android device running at least Android 4.3 Jelly Bean. Wearable can be deployed to either an Android Wear device or the Android Wear emulator. ## Build requirements Xamarin Studio 5.3+ Xamarin.Android 4.17+ The DataLayer project must be deployed to a physical android device of at least Android 4.3 Jelly bean and the Wearable project must be deployed to either an Android Wear device or emulator. Download Xamarin Studio 5.3 or higher and open the project solution. Right click the project DataLayer and set it as the startup project, then click build in the application menu. Then right click the project Wearable, set it as the startup project, then click build in the application menu. You will need to deploy DataLayer to a physical Android device running at least Android 4.3 Jelly Bean. Wearable can be deployed to either an Android Wear device or the Android Wear emulator. ![DataLayer Sample application screenshot](Screenshots/Log and Thumbnail.png "DataLayer Sample application screenshot") ## License Copyright (c) 2005-2008, The Android Open Source Project diff --git a/wear/DelayedConfirmation/README.md b/wear/DelayedConfirmation/README.md index f4382b5..4aecdfd 100644 --- a/wear/DelayedConfirmation/README.md +++ b/wear/DelayedConfirmation/README.md @@ -1,32 +1,35 @@ --- name: Xamarin.Android - Delayed Confirmation description: A simple sample which demonstrates how to send and receive messages to a connected Wearable using the new Wear APIs page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-delayedconfirmation --- # Delayed Confirmation A simple sample which demonstrates how to send and receive messages to a connected Wearable using the new Wear APIs. Ported from the Android Open Source Project sample ## Note For running on an emulator for wearable, you must run ```shell adb -d forward tcp:5601 tcp:5601 ``` Full instructions for how to connect and prepare a Wearable for use please see [Android Developers](http://developer.android.com/training/wearables/apps/creating.html#SetupEmulator) ## Build Requirements Xamarin.Android 4.17+ Xamarin Studio 5.3+ ![Delayed Confirmation application screenshot](Screenshots/handheld.png "Delayed Confirmation application screenshot") ## License Android Open Source Project (original Java) diff --git a/wear/ElizaChat/README.md b/wear/ElizaChat/README.md index cfac4b7..87b9414 100644 --- a/wear/ElizaChat/README.md +++ b/wear/ElizaChat/README.md @@ -1,35 +1,38 @@ --- name: Xamarin.Android - ElizaChat description: A wear sample demonstrating how a personal assistant may work on a wearable device. The user interacts with Eliza, the personal assistant page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-elizachat --- # ElizaChat A wear sample demonstrating how a personal assistant may work on a wearable device. The user interacts with Eliza, the personal assistant, through Wear's interactive notifications. The main application serves as a log of the different interactions. ## Note For running on an emulator for wearable, please run ```shell adb -d forward tcp:5601 tcp:5601 ``` For full instructions for how to connect and prepare a Wearable for use please see [Android Developers](http://developer.android.com/training/wearables/apps/creating.html#SetupEmulator) ## Build Requirements Xamarin.Android 4.17+ Xamarin Studio 5.3+ ![ElizaChat application screenshot](Screenshots/notification-muted.png "ElizaChat application screenshot") ## License Android Open Source Project (original Java) diff --git a/wear/FindMyPhoneSample/README.md b/wear/FindMyPhoneSample/README.md index c7ad07c..616c839 100644 --- a/wear/FindMyPhoneSample/README.md +++ b/wear/FindMyPhoneSample/README.md @@ -1,33 +1,39 @@ --- name: Xamarin.Android - FindMyPhone -description: This sample demonstrates a way to create an app that allows you to use your wear device to find your phone. Instructions Download Xamarin Studio... +description: "Demonstrates a way to create an app that allows you to use your wear device to find your phone (Android Wear)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-findmyphonesample --- # FindMyPhone + This sample demonstrates a way to create an app that allows you to use your wear device to find your phone. ## Instructions + * Download Xamarin Studio 5.3 or higher and open the project solution. Right click the project “Application” and set it as the startup project, then click build in the application menu. Then right click the project “Wearable”, set it as the startup project, then click build in the application menu. * You will need to deploy DataLayer to a physical Android device running at least Android 4.3 Jelly Bean. Wearable can be deployed to either an Android Wear device or the Android Wear emulator. * When you run the application, a notification will appear on the wearable device that will, when tapped, turn your phone’s volume all the way up and sound an alarm until you tap the notification again. * When you disconnect your phone from the wearable device via going out of range or disconnecting manually, a notification will appear on the wearable and it will vibrate. * Note - This will sometimes also happen when dismissing the notification via swipe. It should go away after ten seconds or so. ## Build requirements + Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![FindMyPhone application screenshot](Screenshots/Find Phone.png "FindMyPhone application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by John Pilczak diff --git a/wear/FlashlightSample/README.md b/wear/FlashlightSample/README.md index c4e7786..f693bb7 100644 --- a/wear/FlashlightSample/README.md +++ b/wear/FlashlightSample/README.md @@ -1,27 +1,32 @@ --- name: Xamarin.Android - Flashlight -description: This sample demonstrates how to create something similar to a flashlight on an android wear device by changing the color of the screen to a flat... +description: "Demonstrates how to create something similar to a flashlight on an Android Wear device by changing the color of the screen to a flat..." page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-flashlightsample --- # Flashlight + This sample demonstrates how to create something similar to a flashlight on an android wear device by changing the color of the screen to a flat white color. This also includes a “party light” which can be accessed by swiping left which would replace the flat white color with a flashing cycle of many colors. ## Instructions + * The default page is a white light * Swipe left to change to the party light which cycles through many colors ## Build Requirements + Xamarin.Android 4.17+ Xamarin Studio 5.3+ - ![Flashlight application screenshot](Screenshots/party_light.png "Flashlight application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by John Pilczak diff --git a/wear/Geofencing/README.md b/wear/Geofencing/README.md index 57ac94e..fc622f5 100644 --- a/wear/Geofencing/README.md +++ b/wear/Geofencing/README.md @@ -1,28 +1,32 @@ --- name: Xamarin.Android - Geofencing Wearable Sample -description: This sample demonstrates the use of geofencing with wearable devices, by sending a notification to the watch when you are within a certain area.... +description: "Demonstrates the use of geofencing with wearable devices, by sending a notification to the watch when you are within... (Android Wear)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-geofencing --- # Geofencing Wearable Sample + This sample demonstrates the use of geofencing with wearable devices, by sending a notification to the watch when you are within a certain area. ## Instructions + * Deploy the project called "Geofencing" to your phone or tablet, and the project called "Wearable" to your Android Wear device. * When you enter the specified coordinates in the constants class, a notification will be sent to the wearable. * When testing this sample you may need to change the coordinates in the class Constants in the "Geofencing" project to coordinates that are closer to your location. Changing the values YERBA_BUENA_LATITUDE and YERBA_BUENA_LONGITUDE should work. - ## Build Requirements + In order to build this solution, you will need the latest version of Xamarin Studio. This sample requires a physical Android 4.3 or higher device, that is connected to an Android Wear device or the Android Wear emulator. ![Geofencing Wearable Sample application screenshot](Screenshots/Starting geofence transition service.png "Geofencing Wearable Sample application screenshot") -## Author -Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by Christopher Blackman +## License +Copyright (c) 2005-2008, The Android Open Source Project diff --git a/wear/GridViewPager/README.md b/wear/GridViewPager/README.md index a08deac..4a5868b 100644 --- a/wear/GridViewPager/README.md +++ b/wear/GridViewPager/README.md @@ -1,26 +1,31 @@ --- name: Xamarin.Android - GridViewPager sample -description: This sample demonstrates how to use the GridViewPager and GridPagerAdapter view for Android Wear devices. GridViewPager is a view that separates... +description: "Demonstrates how to use the GridViewPager and GridPagerAdapter view for Android Wear devices. GridViewPager is a view that separates..." page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-gridviewpager --- # GridViewPager sample -This sample demonstrates how to use the GridViewPager and GridPagerAdapter view for Android Wear devices. + +This sample demonstrates how to use the GridViewPager and GridPagerAdapter view for Android Wear devices. GridViewPager is a view that separates each item onto a different page, and can be swiped through horizontally or vertically. An implementation of GridViewAdapter is included to supply the GridViewPager with views. GridViewPager is very similar to the notifications layout on the Android Wear home screen. As such, each page / item may have a background, and the control will automatically perform parallax effects between the foreground and background. ## Build Requirements + Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![GridViewPager sample application screenshot](Screenshots/About.png "GridViewPager sample application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by Christopher Blackman diff --git a/wear/JumpingJack/README.md b/wear/JumpingJack/README.md index 6fc2cea..4a27cc9 100644 --- a/wear/JumpingJack/README.md +++ b/wear/JumpingJack/README.md @@ -1,27 +1,33 @@ --- name: Xamarin.Android - Jumping Jack -description: This sample demonstrates the use of the gravity sensor in the Android Wear device through a counter for jumping jacks that the user makes while... +description: "Demonstrates the use of the gravity sensor in the Android Wear device through a counter for jumping jacks that the user makes while..." page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-jumpingjack --- # Jumping Jack + This sample demonstrates the use of the gravity sensor in the Android Wear device through a counter for jumping jacks that the user makes while wearing the device. Note: the jumping jacks must be fairly quick (2 seconds or less) for the jumping jacks to count. The counter can be reset from the settings screen accessed by swiping left. ## Instructions + * Deploy the wearable project onto an Android Wear device. * The first page will count the number of jumping jacks you do. * The second page (reached by swiping left) will contain a button allowing you to reset the counter. ## Build Requirements + Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![Jumping Jack application screenshot](Screenshots/reset.png "Jumping Jack application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by John Pilczak diff --git a/wear/Quiz/README.md b/wear/Quiz/README.md index b5cd8f2..4d8b22c 100644 --- a/wear/Quiz/README.md +++ b/wear/Quiz/README.md @@ -1,30 +1,36 @@ --- name: Xamarin.Android - Quiz -description: This wearable sample demonstrates how to create a quiz between the watch and the mobile device. The phone app will allow you to either create a... +description: "This wearable sample demonstrates how to create a quiz between the watch and the mobile device (Android Wear)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-quiz --- # Quiz + This wearable sample demonstrates how to create a quiz between the watch and the mobile device. The phone app will allow you to either create a custom quiz or load questions from a file. Once a question is added, the wearable device will display the question and allow the user to answer by tapping the page of the notification that appears that they think is the right answer. ## Instructions + * Create a quiz on the phone app by either tapping the “Read quiz from file” button or by filling in the blanks with your own question and selecting the correct answer’s radio button then pressing the “Add question” button. * Answer questions made on the phone app by swiping until you see the answer you think is correct and tapping that answer. The question will turn either green or red on the phone app showing whether you are right or wrong. * “Reset Quiz” will reset the current completed quiz * “New Quiz” will clear all current questions allowing you to create a completely new quiz ## Build Requirements + This app requires both a wear device and a phone/tablet that is api level 18+ to run. You also need Xamarin.Android 4.17 or later. ![Quiz application screenshot](Screenshots/Quiz maker.png "Quiz application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by John Pilczak \ No newline at end of file diff --git a/wear/RecipeAssistant/README.md b/wear/RecipeAssistant/README.md index 8244de0..00f38c0 100644 --- a/wear/RecipeAssistant/README.md +++ b/wear/RecipeAssistant/README.md @@ -1,27 +1,33 @@ --- -name: Xamarin.Android - RecipeAssistant -description: This sample demonstrates sending a list of notifications pages to an Android Wear device, with each page describing a step in a recipe. The actual... +name: Xamarin.Android - Recipe Assistant +description: "Demonstrates sending a list of notifications pages to an Android Wear device, with each page describing a step in a recipe" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-recipeassistant --- # RecipeAssistant + This sample demonstrates sending a list of notifications pages to an Android Wear device, with each page describing a step in a recipe. The actual creation of the notification is done in RecipeService.cs. ## Instructions + * Deploy the RecipeAssistant project to a physical Android device that is 4.3 Jelly Bean or above. * Pick a recipe from the app to send to the wearable device * The wearable device will recieve a multi-page notification with a page for each step of the recipe. You can move on to the next page by swiping left on the device. ## Build Requirements + Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![RecipeAssistant application screenshot](Screenshots/Recipe List.png "RecipeAssistant application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by Christopher Blackman diff --git a/wear/SkeletonWear/README.md b/wear/SkeletonWear/README.md index a73d458..d8434a3 100644 --- a/wear/SkeletonWear/README.md +++ b/wear/SkeletonWear/README.md @@ -1,22 +1,27 @@ --- name: Xamarin.Android - SkeletonWear -description: This sample shows the basic outline of a wearable project including Gridviews on Wearable devices and interactive notifications. Build Requirements... +description: "Shows the basic outline of a wearable project including Gridviews on Wearable devices and interactive notifications (Andriod Wear)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-skeletonwear --- # SkeletonWear + This sample shows the basic outline of a wearable project including Gridviews on Wearable devices and interactive notifications. ## Build Requirements + Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![SkeletonWear application screenshot](Screenshots/launch.png "SkeletonWear application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by Ben O'Halloran diff --git a/wear/SynchronizedNotifications/README.md b/wear/SynchronizedNotifications/README.md index bec0699..ae09540 100644 --- a/wear/SynchronizedNotifications/README.md +++ b/wear/SynchronizedNotifications/README.md @@ -1,26 +1,32 @@ --- name: Xamarin.Android - SynchronizedNotifications -description: This wearable sample demonstrates using listener services to create three kinds of notifications; a phone only notification, a wearable only... +description: "Wearable sample that demonstrates listener services that create three kinds of notifications; a phone only notification, a wearable only..." page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-synchronizednotifications --- # SynchronizedNotifications + This wearable sample demonstrates using listener services to create three kinds of notifications; a phone only notification, a wearable only notification, and a notification that appears on both the phone and wearable, with one automatically disappearing when the other is dismissed. ## Instructions -* Deploy the SynchronizedNotifications project to a 4.3 Jelly Bean or higher Android device and the Wearable project to an Android Wear device. -* Choose an item from the list to send notifications to the listed devices. + +- Deploy the SynchronizedNotifications project to a 4.3 Jelly Bean or higher Android device and the Wearable project to an Android Wear device. +- Choose an item from the list to send notifications to the listed devices. ## Build Requirements + Xamarin Studio 5.3+ Xamarin.Android 4.17+ ![SynchronizedNotifications application screenshot](Screenshots/App view.png "SynchronizedNotifications application screenshot") -## Author +## License + Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by Christopher Blackman diff --git a/wear/Timer/Metadata.xml b/wear/Timer/Metadata.xml deleted file mode 100644 index 1501401..0000000 --- a/wear/Timer/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>c26ae153-a441-4b18-ab81-30d12ece8d9c</ID> - <IsFullApplication>false</IsFullApplication> - <Level>Intermediate</Level> - <Tags>Platform Features, User Interface, Android Wear</Tags> - <Gallery>false</Gallery> - <Brief>Demonstrates a simple timer application designed for Wear.</Brief> -</SampleMetadata> diff --git a/wear/Timer/README.md b/wear/Timer/README.md index 845f188..4967919 100644 --- a/wear/Timer/README.md +++ b/wear/Timer/README.md @@ -1,31 +1,21 @@ ---- -name: Xamarin.Android - Timer -- DEPRECATED -description: A simple timer application designed for Wear. The timer is displayed as a notification with reset and delete options. Instructions Launch the app... -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: wear-timer ---- # Timer -- DEPRECATED + A simple timer application designed for Wear. The timer is displayed as a notification with reset and delete options. ## Instructions + * Launch the app onto a wearable device. * Pick a time from the list that you want the timer to be set to. * Swipe up to see the notification that appears with the timer. * Swipe left to get to the reset and delete buttons. ## Build Requirements * Xamarin.Android 4.20 * JDK 1.7 -![Timer -- DEPRECATED application screenshot](Screenshots/Delete.png "Timer -- DEPRECATED application screenshot") - ## Author Copyright (c) 2005-2008, The Android Open Source Project Ported to Xamarin.Android by Ben O'Halloran diff --git a/wear/WatchFace/README.md b/wear/WatchFace/README.md index bd41cda..2fe6464 100644 --- a/wear/WatchFace/README.md +++ b/wear/WatchFace/README.md @@ -1,48 +1,48 @@ --- name: Xamarin.Android - WatchFace -description: WatchFace is a sample app that accompanies the article, Creating a Watch Face. This sample demonstrates how to use CanvasWatchFaceService and... +description: "Demonstrates how to use CanvasWatchFaceService and CanvasWatchFaceService.Engine to implement a custom Android Wear watch face" page_type: sample languages: - csharp products: - xamarin extensions: tags: - - wear + - androidwear urlFragment: wear-watchface --- # WatchFace **WatchFace** is a sample app that accompanies the article, [Creating a Watch Face](https://docs.microsoft.com/xamarin/android/wear/platform/creating-a-watchface). This sample demonstrates how to use `CanvasWatchFaceService` and `CanvasWatchFaceService.Engine` to implement a custom Android Wear watch face. This analog-style watch face sports an hour hand, a minute hand, and a seconds hand; it also handles changes between ambient mode and interactive mode. A time zone receiver listens for time zone changes and updates the time as needed. The watch face service is packaged with a very simple app that is used only as a packaging vehicle for getting the watch face service into the Wear device (the app doesn't interact with the watch face). To run the watch face: 1. Build and deploy the solution to the Wear device. 2. Swipe right until you the default watch face appears. 3. Press down for a second to enter the watch face picker (alternately, you can enter **Setup** and tap **Change watch face**). 4. Swipe until you see the **Xamarin Sample** watch face. 5. Tap to select the **Xamarin Sample** watch face. Note that this app depends on the [Xamarin Android Wear Support Libraries](https://www.nuget.org/packages/Xamarin.Android.Wear). This sample was ported from the Java **WatchFace** sample described in the Android Developer [Drawing Watch Faces](https://developer.android.com/training/wearables/watch-faces/drawing.html) topic. diff --git a/wear/WatchViewStub/README.md b/wear/WatchViewStub/README.md index 92dd29f..cd05749 100644 --- a/wear/WatchViewStub/README.md +++ b/wear/WatchViewStub/README.md @@ -1,22 +1,27 @@ --- -name: Xamarin.Android - WatchViewStubSample -description: This wearable-only sample demonstrate using the WatchViewStub control which will automatically select a layout suited for round or rectangular... +name: Xamarin.Android - WatchViewStub +description: "This wearable-only sample demonstrate using the WatchViewStub control which will automatically select a layout suited for round... (Wear)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-watchviewstub --- -# WatchViewStubSample -This wearable-only sample demonstrate using the WatchViewStub control which will automatically select a layout suited for round or rectangular screens. Take a look at the 'Resources/layout/main_actvity.xml' layout file to see how this is done. +# WatchViewStubS ample + +This wearable-only sample demonstrate using the WatchViewStub control which will automatically select a layout suited for round or rectangular screens. Take a look at the **Resources/layout/main_actvity.xml** layout file to see how this is done. ## Build Requirements -Xamarin Studio 5.3+ -Xamarin.Android 4.17+ + +- Xamarin Studio 5.3+ +- Xamarin.Android 4.17+ ![WatchViewStubSample application screenshot](Screenshots/Main View.png "WatchViewStubSample application screenshot") -## Author -Copyright (c) 2005-2008, The Android Open Source Project -Ported to Xamarin.Android by Christopher Blackman +## License + +Copyright (c) 2005-2008, The Android Open Source Project diff --git a/wear/WearTest/README.md b/wear/WearTest/README.md index b9cf934..3fceb6f 100644 --- a/wear/WearTest/README.md +++ b/wear/WearTest/README.md @@ -1,16 +1,19 @@ --- name: Xamarin.Android - Android Wear Getting Started description: This sample app accompanies the Android Wear article, Getting Started. page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidwear urlFragment: wear-weartest --- # Android Wear getting started This sample app accompanies the Android Wear article, [Getting Started](https://docs.microsoft.com/xamarin/android/wear/get-started/). ![Android Wear on a watch](Screenshots/screenshot.png)
dotnet/android-samples
7f4c5b0e518c8e274c3f970de748f8281ad15dce
onboard missing samples
diff --git a/GridLayoutDemo/README.md b/GridLayoutDemo/README.md index 7680ca1..26b566c 100644 --- a/GridLayoutDemo/README.md +++ b/GridLayoutDemo/README.md @@ -1,18 +1,18 @@ --- name: Xamarin.Android - GridLayout Demo description: "How to use a GridLayout (Android Ice Cream Sandwich)" page_type: sample languages: - csharp products: - xamarin extensions: tags: - androidicecreamsandwich urlFragment: gridlayoutdemo --- # GridLayout Demo This example shows how to use a GridLayout with Xamarin.Android and Ice Cream Sandwich. -![Android screen with grid layout](Screenshnots/GridLayoutDemo.png) +![Android screen with grid layout](Screenshnots/screenshot.png) diff --git a/GridLayoutDemo/Screenshots/screenshot.png b/GridLayoutDemo/Screenshots/screenshot.png new file mode 100644 index 0000000..2529392 Binary files /dev/null and b/GridLayoutDemo/Screenshots/screenshot.png differ diff --git a/PlatformFeatures/ICS_Samples/GridLayoutDemo/Metadata.xml b/PlatformFeatures/ICS_Samples/GridLayoutDemo/Metadata.xml deleted file mode 100644 index b4b1a0d..0000000 --- a/PlatformFeatures/ICS_Samples/GridLayoutDemo/Metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>58ABF285-A130-4480-AADF-92E66CE3A26C</ID> - <IsFullApplication>false</IsFullApplication> - <Brief>Demonstrates use of the GridLayout widget.</Brief> - <Level>Intermediate</Level> - <LicenseRequirement>Indie</LicenseRequirement> - <Tags>Platform Features</Tags> - <SupportedPlatforms>Android</SupportedPlatforms> - <Gallery>true</Gallery> -</SampleMetadata> diff --git a/PlatformFeatures/ICS_Samples/GridLayoutDemo/README.md b/PlatformFeatures/ICS_Samples/GridLayoutDemo/README.md index 00f1bd3..c053779 100644 --- a/PlatformFeatures/ICS_Samples/GridLayoutDemo/README.md +++ b/PlatformFeatures/ICS_Samples/GridLayoutDemo/README.md @@ -1,16 +1,6 @@ ---- -name: Xamarin.Android - Grid Layout Demo -description: This sample app accompanies the article, GridLayout. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: platformfeatures-ics-samples-gridlayoutdemo ---- -# Grid Layout Demo - -This sample app accompanies the article, -[GridLayout](http://developer.xamarin.com/guides/android/user_interface/gridlayout/). +# Grid Layout Demo +This sample app accompanies the article, +[GridLayout](https://docs.microsoft.com/xamarin/android/user-interface/layouts/grid-layout). +![Grid layout in Android app](Screenshots/screenshot.png) diff --git a/PlatformFeatures/ICS_Samples/Metadata.xml b/PlatformFeatures/ICS_Samples/Metadata.xml deleted file mode 100644 index 76cab86..0000000 --- a/PlatformFeatures/ICS_Samples/Metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>70FC77E8-B26E-462A-A6DF-6F1650D0639D</ID> - <IsFullApplication>false</IsFullApplication> - <Brief>Samples for Android Ice Cream Sandwich</Brief> - <Level>Intermediate</Level> - <LicenseRequirement>Indie</LicenseRequirement> - <Tags>Platform Features</Tags> - <SupportedPlatforms>Android</SupportedPlatforms> - <Gallery>false</Gallery> -</SampleMetadata> diff --git a/PlatformFeatures/ICS_Samples/PopupMenuDemo/Metadata.xml b/PlatformFeatures/ICS_Samples/PopupMenuDemo/Metadata.xml deleted file mode 100644 index 9979cd8..0000000 --- a/PlatformFeatures/ICS_Samples/PopupMenuDemo/Metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>2F0C6D5B-FF93-412F-BDD5-3E26C685544E</ID> - <IsFullApplication>false</IsFullApplication> - <Brief>Demonstrates usage of popup menus.</Brief> - <Level>Intermediate</Level> - <LicenseRequirement>Indie</LicenseRequirement> - <Tags>Platform Features</Tags> - <SupportedPlatforms>Android</SupportedPlatforms> - <Gallery>true</Gallery> -</SampleMetadata> diff --git a/PlatformFeatures/ICS_Samples/PopupMenuDemo/README.md b/PlatformFeatures/ICS_Samples/PopupMenuDemo/README.md index 7a88a2e..92a97cd 100644 --- a/PlatformFeatures/ICS_Samples/PopupMenuDemo/README.md +++ b/PlatformFeatures/ICS_Samples/PopupMenuDemo/README.md @@ -1,16 +1,6 @@ ---- -name: Xamarin.Android - Popup Menu Demo -description: This sample app accompanies the article, PopUp Menus. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: platformfeatures-ics-samples-popupmenudemo ---- -# Popup Menu Demo - -This sample app accompanies the article, -[PopUp Menus](http://developer.xamarin.com/guides/android/user_interface/popup_menus/). +# Popup Menu Demo +This sample app accompanies the article, +[PopUp Menus](https://docs.microsoft.com/en-us/xamarin/android/user-interface/controls/popup-menu). +![Popup menu in Android](Screenshot/screenshot.png) diff --git a/PlatformFeatures/ICS_Samples/README.md b/PlatformFeatures/ICS_Samples/README.md index db29818..584749c 100644 --- a/PlatformFeatures/ICS_Samples/README.md +++ b/PlatformFeatures/ICS_Samples/README.md @@ -1,14 +1,4 @@ ---- -name: Xamarin.Android - Ice Cream Sandwich Samples -description: This collection of sample apps accompanies the article, Introduction to Ice Cream Sandwich. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: platformfeatures-ics-samples ---- # Ice Cream Sandwich Samples -This collection of sample apps accompanies the article, -[Introduction to Ice Cream Sandwich](http://developer.xamarin.com/guides/android/platform_features/introduction_to_ice_cream_sandwich/). +This collection of sample apps accompanies the article, +[Introduction to Ice Cream Sandwich](https://docs.microsoft.com/xamarin/android/platform/ice-cream-sandwich). diff --git a/PlatformFeatures/ICS_Samples/SwitchDemo/Metadata.xml b/PlatformFeatures/ICS_Samples/SwitchDemo/Metadata.xml deleted file mode 100644 index 9550a1e..0000000 --- a/PlatformFeatures/ICS_Samples/SwitchDemo/Metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>5C768B9D-F4A8-4671-A553-CF9F18766615</ID> - <IsFullApplication>false</IsFullApplication> - <Brief>Demonstrates use of the Switch widget.</Brief> - <Level>Intermediate</Level> - <LicenseRequirement>Indie</LicenseRequirement> - <Tags>Platform Features</Tags> - <SupportedPlatforms>Android</SupportedPlatforms> - <Gallery>true</Gallery> -</SampleMetadata> diff --git a/PlatformFeatures/ICS_Samples/SwitchDemo/README.md b/PlatformFeatures/ICS_Samples/SwitchDemo/README.md index aa98845..1112ceb 100644 --- a/PlatformFeatures/ICS_Samples/SwitchDemo/README.md +++ b/PlatformFeatures/ICS_Samples/SwitchDemo/README.md @@ -1,16 +1,6 @@ ---- -name: Xamarin.Android - Switch Demo -description: This sample app accompanies the article, Introduction to Switches. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: platformfeatures-ics-samples-switchdemo ---- -# Switch Demo - -This sample app accompanies the article, -[Introduction to Switches](http://developer.xamarin.com/guides/android/user_interface/intro_to_switches/). +# Switch Demo +This sample app accompanies the article, +[Introduction to Switches](https://docs.microsoft.com/xamarin/android/user-interface/controls/switch). +![Android app with a switch control](Screenshots/screenshot.png) diff --git a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/Metadata.xml b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/Metadata.xml deleted file mode 100644 index d598880..0000000 --- a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/Metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>DF5C56D5-DEA9-4F15-BE6D-206E5B930591</ID> - <IsFullApplication>false</IsFullApplication> - <Brief>Demonstates usage of the Navigation Bar.</Brief> - <Level>Intermediate</Level> - <LicenseRequirement>Indie</LicenseRequirement> - <Tags>Platform Features</Tags> - <SupportedPlatforms>Android</SupportedPlatforms> - <Gallery>false</Gallery> -</SampleMetadata> diff --git a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/README.md b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/README.md index 94b48c1..599ae1d 100644 --- a/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/README.md +++ b/PlatformFeatures/ICS_Samples/SystemUIVisibilityDemo/README.md @@ -1,16 +1,6 @@ ---- -name: Xamarin.Android - System UI Visibility Demo -description: This sample app accompanies the article, Navigation Bar. -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: platformfeatures-ics-samples-systemuivisibilitydemo ---- -# System UI Visibility Demo - -This sample app accompanies the article, -[Navigation Bar](http://developer.xamarin.com/guides/android/user_interface/navigation_bar/). +# System UI Visibility Demo +This sample app accompanies the article, +[Navigation Bar](https://docs.microsoft.com/xamarin/android/user-interface/controls/navigation-bar). +![Difference navigation bar visibility options in Android app](Screenshots/screenshot.png) diff --git a/PlatformFeatures/SimpleContentProvider/README.md b/PlatformFeatures/SimpleContentProvider/README.md index 28f412e..87707d4 100644 --- a/PlatformFeatures/SimpleContentProvider/README.md +++ b/PlatformFeatures/SimpleContentProvider/README.md @@ -1,15 +1,15 @@ --- name: Xamarin.Android - SimpleContentProvider description: Sample for Creating a Custom ContentProvider page_type: sample languages: - csharp products: - xamarin urlFragment: platformfeatures-simplecontentprovider --- # SimpleContentProvider for Xamarin.Android -Sample for [Creating a Custom ContentProvider](https://docs.microsoft.com/en-us/xamarin/android/platform/content-providers/custom-contentprovider) +Sample for [Creating a Custom ContentProvider](https://docs.microsoft.com/xamarin/android/platform/content-providers/custom-contentprovider) ![Screenshots of list using a content provider](Screenshots/ContentProvider.png) diff --git a/PlatformFeatures/TimeAnimatorExample/README.md b/PlatformFeatures/TimeAnimatorExample/README.md index 1943f4e..43cc2b6 100644 --- a/PlatformFeatures/TimeAnimatorExample/README.md +++ b/PlatformFeatures/TimeAnimatorExample/README.md @@ -1,16 +1,19 @@ --- -name: Xamarin.Android - Jelly Bean Time Animation -description: This sample app accompanies the article, Introduction to Jelly Bean. +name: Xamarin.Android - Time Animation +description: "TimeAnimator can notify an application every time a frame changes in an animation (Android Jelly Bean)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidjellybean urlFragment: platformfeatures-timeanimatorexample --- -# Jelly Bean Time Animation - -This sample app accompanies the article, -[Introduction to Jelly Bean](http://developer.xamarin.com/guides/android/platform_features/introduction_to_jelly_bean/). +# Jelly Bean Time Animation +The new TimeAnimator class provides an interface `TimeAnimator.ITimeListener` that can notify an application every time a frame changes in an animation. +This sample app accompanies the article, +[Introduction to Jelly Bean](https://docs.microsoft.com/xamarin/android/platform/jelly-bean). diff --git a/PopupMenuDemo/README.md b/PopupMenuDemo/README.md index aaa6529..52eeb04 100755 --- a/PopupMenuDemo/README.md +++ b/PopupMenuDemo/README.md @@ -1,16 +1,18 @@ --- -name: Xamarin.Android - Popup Menu Demo -description: PopupMenuDemo is a sample app that accompanies the article, PopUp Menu. It demonstrates how to add support for displaying popup menus that are... +name: Xamarin.Android - Popup Menu +description: "Demonstrates how to add support for displaying popup menus that are attached to a particular view" page_type: sample languages: - csharp products: - xamarin urlFragment: popupmenudemo --- # Popup Menu Demo **PopupMenuDemo** is a sample app that accompanies the article, -[PopUp Menu](https://docs.microsoft.com/en-us/xamarin/android/user-interface/controls/popup-menu). +[PopUp Menu](https://docs.microsoft.com/xamarin/android/user-interface/controls/popup-menu). It demonstrates how to add support for displaying popup menus that are attached to a particular view. + +![Popup menu in Android](Screenshots/PopupMenuDemo.png) diff --git a/SwitchDemo/README.md b/SwitchDemo/README.md index efd4f17..920972a 100644 --- a/SwitchDemo/README.md +++ b/SwitchDemo/README.md @@ -1,13 +1,19 @@ --- name: Xamarin.Android - Switch Demo -description: This example shows how to use a switch control with Ice Cream Sandwich. +description: "Shows how to use a switch control (Android Ice Cream Sandwich)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidicecreamsandwich urlFragment: switchdemo --- # Switch Demo -This example shows how to use a switch control with Ice Cream Sandwich. +This sample app accompanies the article, +[Introduction to Switches](https://docs.microsoft.com/xamarin/android/user-interface/controls/switch), showing how to use the Switch control in Xamarin.Android. + +![Switch control in an Android app](Screenshots/screenshot.png) diff --git a/SwitchDemo/Screenshots/screenshot.png b/SwitchDemo/Screenshots/screenshot.png new file mode 100644 index 0000000..15ed7a2 Binary files /dev/null and b/SwitchDemo/Screenshots/screenshot.png differ diff --git a/SystemUIVisibilityDemo/README.md b/SystemUIVisibilityDemo/README.md index e377092..954ab3e 100644 --- a/SystemUIVisibilityDemo/README.md +++ b/SystemUIVisibilityDemo/README.md @@ -1,15 +1,21 @@ --- name: Xamarin.Android - System UI Visibility Demo -description: This example shows how to change the appearance of the Navigation Bar in Ice Cream Sandwich. +description: "Demonstrates different visibility settings for the navigation bar (Android Ice Cream Sandwich)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidicecreamsandwich urlFragment: systemuivisibilitydemo --- # System UI Visibility Demo This example shows how to change the appearance of the Navigation Bar in Ice Cream Sandwich. -![Three screenshots showing different navigation bar views](Screenshots/SystemUIVisibility.png) \ No newline at end of file +![Different navigation bar view options in Android](Screenshots/screenshot.png) + +This sample app accompanies the article, +[Navigation Bar](https://docs.microsoft.com/xamarin/android/user-interface/controls/navigation-bar). diff --git a/SystemUIVisibilityDemo/Screenshots/screenshot.png b/SystemUIVisibilityDemo/Screenshots/screenshot.png new file mode 100644 index 0000000..5d77aea Binary files /dev/null and b/SystemUIVisibilityDemo/Screenshots/screenshot.png differ diff --git a/TextSwitcher/README.md b/TextSwitcher/README.md index 41082da..27e8977 100644 --- a/TextSwitcher/README.md +++ b/TextSwitcher/README.md @@ -1,24 +1,27 @@ --- name: Xamarin.Android - TextSwitcher Sample -description: "Illustrates the use of a TextSwitcher to display animations for text changes" +description: "Illustrates the use of a TextSwitcher to display animations for text changes (Android Oreo)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidoreo urlFragment: textswitcher --- # TextSwitcher Sample This sample illustrates the use of a TextSwitcher to display animations for text changes. ## Build Requirements Using this sample requires the Android 8.0 (API 26) and the Xamarin.Android 7.5.x or higher. ![TextSwitcher Sample application screenshot](Screenshots/Home.png "TextSwitcher Sample application screenshot") ## License Copyright (c) 2016 The Android Open Source Project, Inc. -Ported from [Android TextSwitcher Sample](https://github.com/googlesamples/android-TextSwitcher). \ No newline at end of file +Ported from [Android TextSwitcher Sample](https://github.com/googlesamples/android-TextSwitcher).
dotnet/android-samples
b213c51296b715eea87f6fc935e90dde3d86ef44
onboard missing samples
diff --git a/LabelledSections/README.md b/LabelledSections/README.md index 75a7752..36cd16a 100644 --- a/LabelledSections/README.md +++ b/LabelledSections/README.md @@ -1,37 +1,37 @@ --- name: Xamarin.Android - Labelled Sections -description: The Labelled Sections demo is a port from the Alphabetically ordered ListView with labelled sections sample, with some changes to follow .NET... +description: "Port from the Alphabetically ordered ListView with labelled sections sample, with some changes to follow .NET conventions" page_type: sample languages: - csharp products: - xamarin urlFragment: labelledsections --- # Labelled Sections The `Labelled Sections` demo is a port from the [Alphabetically ordered ListView with labelled sections](http://androidseverywhere.info/JAAB/?p=6) sample, with some changes to follow .NET conventions. The `ListItemInterface` interface is the -[IHasLabel](/LabelledSections/IHasLabel.cs) interface. +[IHasLabel](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/IHasLabel.cs) interface. The `ListItemObject` class is the -[ListItemValue](/LabelledSections/ListItemValue.cs) class. +[ListItemValue](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/ListItemValue.cs) class. The `ListItemContainer` class is the -[ListItemCollection](/LabelledSections/ListItemCollection.cs) +[ListItemCollection](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/ListItemCollection.cs) class. The `ListWithHeaders` activity is the -[Activity1](/LabelledSections/Activity1.cs) activity. +[Activity1](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/Activity1.cs) activity. The `res/layout` XML files are unchanged, though `list_item.xml` has been -renamed to [ListItem.axml](/LabelledSections/Resources/layout/ListItem.axml) +renamed to [ListItem.axml](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/Resources/layout/ListItem.axml) and `list_header.xml` has been renamed to -[ListHeader.axml](/LabelledSections/Resources/layout/ListHeader.axml). +[ListHeader.axml](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/Resources/layout/ListHeader.axml). The `SeparatedListAdapter` type is the -[SeparatedListAdapter](/LabelledSections/SeparatedListAdapter.cs) +[SeparatedListAdapter](https://github.com/xamarin/monodroid-samples/blob/master/LabelledSections/SeparatedListAdapter.cs) type. diff --git a/LeaderboardsAndAchievementsDemo/README.md b/LeaderboardsAndAchievementsDemo/README.md index 35f0ff7..9f8be2d 100644 --- a/LeaderboardsAndAchievementsDemo/README.md +++ b/LeaderboardsAndAchievementsDemo/README.md @@ -1,39 +1,33 @@ --- -name: Xamarin.Android - LeaderboardsAndAchievementsDemo -description: This is a sample xamarin android application that shows the Leaderboards and Achievements for a specific provided game of Google Play Games. Setup... +name: Xamarin.Android - Leaderboards and Achievements +description: "Xamarin.Android application that shows the Leaderboards and Achievements for a specific provided game of Google Play Games" page_type: sample languages: - csharp products: - xamarin urlFragment: leaderboardsandachievementsdemo --- -# LeaderboardsAndAchievementsDemo +# Leaderboards and Achievements Demo This is a sample xamarin android application that shows the [Leaderboards](https://developers.google.com/games/services/android/leaderboards) and [Achievements](https://developers.google.com/games/services/android/achievements) for a specific provided game of Google Play Games. -##Setup +## Setup You must have a created game in your [Google Play Developer Console](https://play.google.com/apps/publish). If you **don't have a game**, you need to create one following these steps: 1. Sign in to the Google Play Developer Console 2. Add your game to the Google Play Developer Console 3. Generate an OAuth 2.0 client ID - * Create a linked application + - Create a linked application 4. Paste you Game ID in [Strings.xml](https://github.com/xamarin/monodroid-samples/blob/master/LeaderboardsAndAchievementsDemo/Resources/values/Strings.xml) file. You have to replace the *PASTE_YOUR_GAME_ID_HERE* text. For more information, please visit this [web site](https://developers.google.com/games/services/console/enabling). -##Screenshots +## Screenshots +![Home screenshot](Screenshots/home.png "Home") -![screenshot](Screenshots/home.png "Home") +![Leaderboards screenshot](Screenshots/leaderboards.png "Leaderboards") -![screenshot](Screenshots/leaderboards.png "Leaderboards") - -![screenshot](Screenshots/achievements.png "Achievements") - - -## Author - -Gonzalo Martin +![Achievements screenshot](Screenshots/achievements.png "Achievements") diff --git a/LiveWallpaperDemo/README.md b/LiveWallpaperDemo/README.md index 2fc596e..c224322 100644 --- a/LiveWallpaperDemo/README.md +++ b/LiveWallpaperDemo/README.md @@ -1,24 +1,24 @@ --- name: Xamarin.Android - Live Wallpaper Demo -description: 'This sample demonstrates various forms of live wallpapers: A live Google Maps wallpaper. A rotating cube. A resource-based rotating cube and...' +description: 'Demonstrates various forms of live wallpapers, including a live Google Maps wallpaper, rotating cube, resource-based rotating cube...' page_type: sample languages: - csharp products: - xamarin urlFragment: livewallpaperdemo --- # Live Wallpaper Demo This sample demonstrates various forms of live wallpapers: -* A live Google Maps wallpaper. -* A rotating cube. -* A resource-based rotating cube and dodecahedron. +- A live Google Maps wallpaper. +- A rotating cube. +- A resource-based rotating cube and dodecahedron. -# To Run +## To Run -* Deploy to target device using Build -> Deploy -* Long tap on the desktop -* Choose Wallpapers -> Live wallpapers -> LiveWallpaper Demo -* Choose Set wallpaper +- Deploy to target device using Build -> Deploy +- Long tap on the desktop +- Choose Wallpapers -> Live wallpapers -> LiveWallpaper Demo +- Choose Set wallpaper diff --git a/LoadingLargeBitmaps/README.md b/LoadingLargeBitmaps/README.md index 4f8dcb8..d45d876 100644 --- a/LoadingLargeBitmaps/README.md +++ b/LoadingLargeBitmaps/README.md @@ -1,15 +1,15 @@ --- name: Xamarin.Android - Loading Large Images -description: This is a sample project that shows how to efficiently resample large images before displaying them in an Android application. The images can be... +description: "Shows how to efficiently re-sample large images before displaying them in an Android application" page_type: sample languages: - csharp products: - xamarin urlFragment: loadinglargebitmaps --- # Loading Large Images -This is a sample project that shows how to efficiently resample large images before displaying them in an Android application. The images can be reduced in size which will require less RAM one the device. +This is a sample project that shows how to efficiently re-sample large images before displaying them in an Android application. The images can be reduced in size which will require less RAM one the device. ![Android app showing an image of a dog](Screenshots/image01.png) diff --git a/LocalFiles/README.md b/LocalFiles/README.md index 5a50fcb..fe56a5e 100644 --- a/LocalFiles/README.md +++ b/LocalFiles/README.md @@ -1,17 +1,20 @@ --- name: Xamarin.Android - Local Files -description: This sample app accompanies the guide, [](). It demonstrates reading and writing to a text file using Xamarin.Android and also demonstrates... +description: "Demonstrates reading and writing to a text file (Android Marshmallow)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidmarshmallow urlFragment: localfiles --- # Local Files -This sample app accompanies the guide, [](). It demonstrates reading and -writing to a text file using Xamarin.Android and also demonstrates +This sample app accompanies the guide, [File Storage and Access](https://docs.microsoft.com/xamarin/android/platform/files/). It demonstrates reading and +writing to a text file using Xamarin.Android and also demonstrates handling the runtime-permission check. -This sample app is for Android 6.0 (API level 23) or higher. \ No newline at end of file +This sample app is for Android 6.0 (API level 23) or higher. diff --git a/ModelAndVerts/README.md b/ModelAndVerts/README.md index 94c5f5f..67d2930 100644 --- a/ModelAndVerts/README.md +++ b/ModelAndVerts/README.md @@ -1,19 +1,18 @@ --- -name: Xamarin.Android - MonoGame Project Combining Model and Vertex Drawing for Android -description: 'This project shows how to combine Model rendering with vertex array rendering in MonoGame. This single solution contains two projects: one for...' +name: Xamarin.Android - MonoGame model and vertex drawing +description: "How to combine Model rendering with vertex array rendering in MonoGame" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - monogame urlFragment: modelandverts --- # MonoGame Project Combining Model and Vertex Drawing for Android This project shows how to combine Model rendering with vertex array rendering in MonoGame. -This single solution contains two projects: one for Android and one cross-platform portable class library. It is the result of the Working with Vertex Array in MonoGame walkthrough. - -## Author - -Victor Chelaru \ No newline at end of file +This single solution contains two projects: one for Android and one cross-platform portable class library. It is the result of the [Working with Vertex Array in MonoGame](https://docs.microsoft.com/xamarin/graphics-games/monogame/3d/part2) walkthrough. diff --git a/ModelDrawing/README.md b/ModelDrawing/README.md index 46ce37a..b9e4314 100644 --- a/ModelDrawing/README.md +++ b/ModelDrawing/README.md @@ -1,21 +1,20 @@ --- -name: Xamarin.Android - MonoGame Model Drawing Project for Android -description: This project shows how to load a XNB file into a MonoGame Model instance. Once loaded the Model instance is drawn on-screen six times. It is the... +name: Xamarin.Android - MonoGame model drawing +description: "How to load a XNB file into a MonoGame Model instance. Once loaded the Model instance is drawn on-screen six times" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - monogame urlFragment: modeldrawing --- # MonoGame Model Drawing Project for Android -This project shows how to load a XNB file into a MonoGame Model instance. Once loaded the Model instance is drawn on-screen six times. It is the result of working through the MonoGame Model walkthrough. +This project shows how to load a XNB file into a MonoGame Model instance. Once loaded the Model instance is drawn on-screen six times. It is the result of working through the [MonoGame Model walkthrough](https://docs.microsoft.com/xamarin/graphics-games/monogame/3d/part1). This single solution contains two projects: one for Android and one cross-platform portable class library. ![MonoGame Model Drawing Project for Android application screenshot](Screenshots/Screenshot1.png "MonoGame Model Drawing Project for Android application screenshot") - -## Author - -Victor Chelaru \ No newline at end of file diff --git a/MonoGame3DCamera/README.md b/MonoGame3DCamera/README.md index c47d691..ccd6603 100644 --- a/MonoGame3DCamera/README.md +++ b/MonoGame3DCamera/README.md @@ -1,17 +1,20 @@ --- -name: Xamarin.Android - MonoGame Project -description: "Extends the Model with Vertex-based drawing project with 3D camera and model positioning and orientation" +name: Xamarin.Android - MonoGame 3D Camera +description: "Extends the MonoGame Model with Vertex-based drawing project with 3D camera and model positioning and orientation" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - monogame urlFragment: monogame3dcamera --- # MonoGame Project with 3D Camera and Model Positioning and Orientation This project extends the Model with Vertex-based drawing project to add a user-controlled camera and 3D Model movement/orientation. This single solution contains two projects: one for Android and one cross-platform portable class library. It is the result of the 3D Coordinates and Camera project. Refer to the [MonoGame docs](https://docs.microsoft.com/xamarin/graphics-games/monogame/). diff --git a/MonoIO/Metadata.xml b/MonoIO/Metadata.xml deleted file mode 100644 index b5870be..0000000 --- a/MonoIO/Metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<SampleMetadata> - <ID>a979f7f6-520b-4189-885d-b44df6e5960f</ID> - <IsFullApplication>true</IsFullApplication> - <Level>Intermediate</Level> - <Tags>User Interface, Data, Graphics, Maps + Location</Tags> - <Gallery>true</Gallery> - <Brief>This is a port of the [Google IO 2011 Schedule App].</Brief> -</SampleMetadata> diff --git a/MonoIO/README.md b/MonoIO/README.md index b44627c..ae4fdd2 100644 --- a/MonoIO/README.md +++ b/MonoIO/README.md @@ -1,32 +1,22 @@ ---- -name: Xamarin.Android - Google IO 2011 App in Mono for Android -description: This is a port of the [Google IO 2011 Schedule App][1] - it only works on Android 2.2 to Android 4.0.3 and it is not a port of the Google IO 2012... -page_type: sample -languages: -- csharp -products: -- xamarin -urlFragment: monoio ---- # Google IO 2011 App in Mono for Android This is a port of the [Google IO 2011 Schedule App][1] - it only works on Android 2.2 to Android 4.0.3 and it is not a port of the Google IO 2012 application. # License Copyright 2011 Google Copyright 2012 Xamarin Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. [1]: https://code.google.com/p/iosched/source/detail?r=27a82ff10b436da5914a3961df245ff8f66b6252 diff --git a/MultiResolution/README.md b/MultiResolution/README.md index ad8c2cd..2a2f126 100644 --- a/MultiResolution/README.md +++ b/MultiResolution/README.md @@ -1,15 +1,15 @@ --- name: Xamarin.Android - Multi-Resolution Graphics -description: This sample demonstrates how to display scalable/stretchable graphics using proper size units such as scale-independent pixels (sp) and... +description: "Demonstrates how to display scalable/stretchable graphics using proper size units such as scale-independent pixels and..." page_type: sample languages: - csharp products: - xamarin urlFragment: multiresolution --- # Multi-Resolution Graphics This sample demonstrates how to display scalable/stretchable graphics using proper size units such as scale-independent pixels (sp) and density-independent pixels (dip). diff --git a/NotePad-Mono.Data.Sqlite/Readme.md b/NotePad-Mono.Data.Sqlite/Readme.md index cfa1571..6d7f48b 100644 --- a/NotePad-Mono.Data.Sqlite/Readme.md +++ b/NotePad-Mono.Data.Sqlite/Readme.md @@ -1,17 +1,17 @@ --- name: Xamarin.Android - Notepad Sample (Mono.Sqlite) -description: This sample shows a simple note taking application. This sample uses MFA's included Mono.Data.Sqlite. If you want to see a similar sample using... +description: "Simple note taking application using Mono.Data.Sqlite" page_type: sample languages: - csharp products: - xamarin urlFragment: notepad-monodatasqlite --- # Notepad Sample (Mono.Sqlite) This sample shows a simple note taking application. This sample uses MFA's included Mono.Data.Sqlite. If you want to see a similar sample using Android.Database.Sqlite, see: https://github.com/xamarin/monodroid-samples/tree/master/NotePad diff --git a/OneABIPerAPK/README.md b/OneABIPerAPK/README.md index e8f6051..8a83f94 100644 --- a/OneABIPerAPK/README.md +++ b/OneABIPerAPK/README.md @@ -1,26 +1,25 @@ --- name: Xamarin.Android - OneABIPerAPK -description: This solution will build a simple HelloWorld style of project. There will be three APK's built, one for each ABI. This solution demonstrates how to... +description: "This solution will build a simple HelloWorld style of project. There will be three APK's built, one for each ABI" page_type: sample languages: - csharp products: - xamarin urlFragment: oneabiperapk --- # OneABIPerAPK This solution will build a simple HelloWorld style of project. There will be three APK's built, one for each ABI. This solution demonstrates how to create a unique `android:versionCode` for each APK. To build the solution run the following at the command line: - rake build - -This will create three folders with the APK: +```cmd +rake build +``` - bin.armeabi - bin.armeabi-v7a - bin.x86 - - +This will create three folders with the APK: +- bin.armeabi +- bin.armeabi-v7a +- bin.x86 diff --git a/OsmDroidBindingExample/README.md b/OsmDroidBindingExample/README.md index a82caf2..54fafea 100644 --- a/OsmDroidBindingExample/README.md +++ b/OsmDroidBindingExample/README.md @@ -1,20 +1,21 @@ --- name: Xamarin.Android - OSMDroid Bindings for Xamarin.Android -description: This is an example of how to create bindings for a .jar file using a Java Binding Project in Xamarin.Android. This example creates a binding for... +description: "This is an example of how to create bindings for a .jar file using a Java Binding Project in Xamarin.Android" page_type: sample languages: - csharp +- java products: - xamarin urlFragment: osmdroidbindingexample --- # OSMDroid Bindings for Xamarin.Android This is an example of how to create bindings for a .jar file using a Java Binding Project in Xamarin.Android. This example creates a binding for [osmdroid](http://code.google.com/p/osmdroid/) - an alternative to Google Maps based on the [OpenStreetMap](http://www.openstreetmap.org). There are two projects: * `OsmDroid.csproj` is the solution that holds the Java Binding Project for the `osmdroid.jar`. The is project is kept in the directory `OsmDroid`. * `OsmDroidTest.csproj` is a Xamarin.Android application that gives a quick example of using the new binding. The code for this project is kept in the directory `OsmDroidTest`. Because of a [bug](https://bugzilla.xamarin.com/show_bug.cgi?id=6695) in Xamarin.Android, the binding `OsmDroid` is built as a DLL and then copied to the `lib` folder. This DLL is then referenced by `OsmDroidTest`, and not the project file `OsmDroidBinding.csproj`. The lib folder holds the two reference `.jar` files that are necessary to bind OSMDroid. diff --git a/Phoneword/README.md b/Phoneword/README.md index af667ed..9ae5390 100644 --- a/Phoneword/README.md +++ b/Phoneword/README.md @@ -1,19 +1,21 @@ --- name: Xamarin.Android - Phoneword -description: This sample app accompanies the article, Hello, Android (Quickstart). This version of Phoneword incorporates all of the functionality explained in... +description: "Sample app for the article, Hello, Android (Quickstart). This version of Phoneword incorporates all of the functionality... (get started)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - getstarted urlFragment: phoneword --- # Phoneword -This sample app accompanies the article, -[Hello, Android (Quickstart)](http://developer.xamarin.com/guides/android/getting_started/hello,android/hello,android_quickstart/). -This version of **Phoneword** incorporates all of the functionality -explained in this article, and it can be used as the starting point for -the article, -[Hello, Android Multiscreen (Quickstart)](http://developer.xamarin.com/guides/android/getting_started/hello,android_multiscreen/hello,android_multiscreen_quickstart/). - +This sample app accompanies the article, +[Hello, Android (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android/hello-android-quickstart). +This version of **Phoneword** incorporates all of the functionality +explained in this article, and it can be used as the starting point for +the article, +[Hello, Android Multiscreen (Quickstart)](https://docs.microsoft.com/xamarin/android/get-started/hello-android-multiscreen/hello-android-multiscreen-quickstart).
dotnet/android-samples
057c07f3ec82d4913f40a8fc5b492f12e9c9dbdb
onboard missing samples: google-services
diff --git a/GridLayoutDemo/README.md b/GridLayoutDemo/README.md index 897a1b9..7680ca1 100644 --- a/GridLayoutDemo/README.md +++ b/GridLayoutDemo/README.md @@ -1,13 +1,18 @@ --- name: Xamarin.Android - GridLayout Demo -description: This example shows how to use a GridLayout with Ice Cream Sandwich. +description: "How to use a GridLayout (Android Ice Cream Sandwich)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidicecreamsandwich urlFragment: gridlayoutdemo --- # GridLayout Demo -This example shows how to use a GridLayout with Ice Cream Sandwich. +This example shows how to use a GridLayout with Xamarin.Android and Ice Cream Sandwich. + +![Android screen with grid layout](Screenshnots/GridLayoutDemo.png) diff --git a/HoneycombGallery/README.md b/HoneycombGallery/README.md index f28e042..33cd379 100644 --- a/HoneycombGallery/README.md +++ b/HoneycombGallery/README.md @@ -1,16 +1,21 @@ --- name: Xamarin.Android - Honeycomb Gallery -description: This is a port of Android SDK samples. It demonstrates a couple of new APIs in Honeycomb e.g. fragments, ActionBar and the new animation framework. +description: "Port of Android SDK samples. It demonstrates new APIs e.g. fragments, ActionBar and the new animation framework (Android Honeycomb)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidhoneycomb urlFragment: honeycombgallery --- # Honeycomb Gallery This is a port of Android SDK samples. It demonstrates a couple of new APIs in Honeycomb e.g. fragments, ActionBar and the new animation framework. + +![Android app screenshot](ScreenshotsHoneycombGallery.png) diff --git a/JetBoy/README.md b/JetBoy/README.md index b54ada6..584c468 100644 --- a/JetBoy/README.md +++ b/JetBoy/README.md @@ -1,13 +1,15 @@ --- name: Xamarin.Android - Jet Boy description: A simple game demonstrating usage of the JET audio engine. page_type: sample languages: - csharp products: - xamarin urlFragment: jetboy --- # Jet Boy A simple game demonstrating usage of the JET audio engine. + +![Android game screenshot](Screenshots/JetBoy2.png) diff --git a/JniDemo/README.md b/JniDemo/README.md index 419ff93..92be8d2 100644 --- a/JniDemo/README.md +++ b/JniDemo/README.md @@ -1,67 +1,70 @@ --- name: Xamarin.Android - Java Native Invoke Sample -description: This sample shows how to manually bind to a Java library so it can be consumed by a Mono for Android application. Requirements There is one... +description: "How to manually bind to a Java library so it can be consumed by a Mono for Android application" page_type: sample languages: - csharp +- java products: - xamarin urlFragment: jnidemo --- # Java Native Invoke Sample This sample shows how to manually bind to a Java library so it can -be consumed by a Mono for Android application. +be consumed by a Xamarin.Android application. ## Requirements There is one requirement in order to build and run this sample: - 1. Mono for Android Preiew 13 or later. + 1. Mono for Android Preview 13 or later. -Commands that need to be executed are indicated within backtics (`), -and $ANDROID_SDK_PATH is the directory that contains your Android SDK +Commands that need to be executed are indicated within backticks (`), +and **$ANDROID_SDK_PATH** is the directory that contains your Android SDK installation. ## How it works As Mono for Android 1.0 does not support binding arbitrary .jar files (only the Android SDK android.jar is bound), alternative mechanisms must instead used for interoperation between Java and managed code. Two primary mechanisms are: 1. Android.Runtime.JNIEnv for creating instances of Java objects and invoking methods on them from C#. This is very similar to System.Reflection in that everything is string based and thus untyped at compile time. 2. The ability to include Java source code and .jar files into the resulting Android application. -We will be using mechanism (2) in order to demonstrate the Jave Native Invoke capability. +We will be using mechanism (2) in order to demonstrate the Java Native Invoke capability. -The Java source code is kept in MyActivity.java, which is included -in the project with a Build Action of AndroidJavaSource. +The Java source code is kept in **MyActivity.java**, which is included +in the project with a **Build Action** of **AndroidJavaSource**. -Furthermore, we edit Properties\AndroidManifest.xml so that it +Furthermore, edit **Properties\AndroidManifest.xml** so that it contains one additional element: -1. A /manifest/application/activity element must be created so that - we can use Context.StartActivity() to create the custom activity. +1. A `/manifest/application/activity` element must be created so that + we can use `Context.StartActivity()` to create the custom activity. This translates to having the following XML within AndroidManifest.xml: - <application android:label="Managed Maps"> - <uses-library android:name="com.google.android.maps" /> - <activity android:name="mono.samples.jnitest.MyActivity" /> - </application> - <uses-permission android:name="android.permission.INTERNET" /> +```xml +<application android:label="Managed Maps"> + <uses-library android:name="com.google.android.maps" /> + <activity android:name="mono.samples.jnitest.MyActivity" /> +</application> +<uses-permission android:name="android.permission.INTERNET" /> +``` -MyActivity.java uses the Resources\Layout\HelloWorld.axml resource, which +**MyActivity.java** uses the **Resources\Layout\HelloWorld.axml** resource, which contains a LinearLayout with a Button and a TextView. -Activity1.cs uses Java.Lang.Class.FindClass() to obtain a -Java.Lang.Class instance for the custom MyActivity type, then we -create an Intent to pass to Activity.StartActivity() to launch -MyActivity. +**Activity1.cs** uses `Java.Lang.Class.FindClass()` to obtain a +`Java.Lang.Class` instance for the custom `MyActivity` type, then we +create an `Intent` to pass to `Activity.StartActivity()` to launch +`MyActivity`. diff --git a/google-services/Location/ActivityRecognition/README.md b/google-services/Location/ActivityRecognition/README.md index ab6d8be..534aacf 100644 --- a/google-services/Location/ActivityRecognition/README.md +++ b/google-services/Location/ActivityRecognition/README.md @@ -1,32 +1,34 @@ --- -name: Xamarin.Android - Activity Recognition Sample -description: This sample demonstrates how to use the ActivityRecognitionApi to recognize a user's current activity type (e.g. walking, driving, or standing... +name: Xamarin.Android - Activity Recognition +description: "Demonstrates how to use the ActivityRecognitionApi to recognize current activity e.g. walking, driving, or standing... (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-location-activityrecognition --- # Activity Recognition Sample This sample demonstrates how to use the ActivityRecognitionApi to recognize a user's current activity type (e.g. walking, driving, or standing still). ## Instructions -* Tap the "Request Updates" button to begin receiving activity updates. -* While the app is running, update information will begin to populate. -* Tap the "Remove Updates" button to stop receiving updates and clear existing activity data. - +- Tap the "Request Updates" button to begin receiving activity updates. +- While the app is running, update information will begin to populate. +- Tap the "Remove Updates" button to stop receiving updates and clear existing activity data. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Activity Recognition Sample application screenshot](Screenshots/screenshot1.png "Activity Recognition Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Recognizing the User's Current Activity Sample](https://github.com/googlesamples/android-play-location/tree/master/ActivityRecognition) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Location/BasicLocationSample/README.md b/google-services/Location/BasicLocationSample/README.md index dcd87ca..35b2af7 100644 --- a/google-services/Location/BasicLocationSample/README.md +++ b/google-services/Location/BasicLocationSample/README.md @@ -1,30 +1,32 @@ --- -name: Xamarin.Android - Basic Location Sample -description: This sample demonstrates how to use the Google Play services Location API to retrieve the last known location for a device. Instructions Launch the... +name: Xamarin.Android - Basic Location +description: "Demonstrates how to use the Google Play services Location API to retrieve the last known location for a device (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-location-basiclocationsample --- # Basic Location Sample This sample demonstrates how to use the Google Play services Location API to retrieve the last known location for a device. ## Instructions -* Launch the app to view the last known course location of the device. - +- Launch the app to view the last known course location of the device. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Basic Location Sample application screenshot](Screenshots/screenshot1.png "Basic Location Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Basic Location Sample](https://github.com/googlesamples/android-play-location/tree/master/BasicLocationSample) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Location/Geofencing/README.md b/google-services/Location/Geofencing/README.md index da9551e..412205a 100644 --- a/google-services/Location/Geofencing/README.md +++ b/google-services/Location/Geofencing/README.md @@ -1,30 +1,33 @@ --- -name: Xamarin.Android - Geofencing Sample -description: This sample demonstrates how to create and remove geofences using the GeofencingApi. Instructions Modify the LatLng dictionary in Constants.cs to... +name: Xamarin.Android - Geofencing +description: "Demonstrates how to create and remove geofences using the GeofencingApi (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-location-geofencing --- # Geofencing Sample This sample demonstrates how to create and remove geofences using the GeofencingApi. ## Instructions -* Modify the LatLng dictionary in Constants.cs to include locations near you. -* Launch the app, and tap 'Add Geofences'. -* A notification will be displayed when one of the geofences is entered. - +- Modify the LatLng dictionary in Constants.cs to include locations near you. +- Launch the app, and tap 'Add Geofences'. +- A notification will be displayed when one of the geofences is entered. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Geofencing Sample application screenshot](Screenshots/screenshot1.png "Geofencing Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Creating and Monitoring Geofences](https://github.com/googlesamples/android-play-location/tree/master/Geofencing) -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Location/LocationAddress/README.md b/google-services/Location/LocationAddress/README.md index a34ac56..4f2812e 100644 --- a/google-services/Location/LocationAddress/README.md +++ b/google-services/Location/LocationAddress/README.md @@ -1,30 +1,32 @@ --- -name: Xamarin.Android - Location Address Sample -description: This sample demonstrates how to use the Geocode API and reverse geocoding to display a device's location as an address. Instructions Tap the Fetch... +name: Xamarin.Android - Location Address +description: "Demonstrates how to use the Geocode API and reverse geocoding to display a device's location as an address (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-location-locationaddress --- # Location Address Sample This sample demonstrates how to use the Geocode API and reverse geocoding to display a device's location as an address. ## Instructions -* Tap the "Fetch Address" button to display the nearest address to your current location. - +- Tap the "Fetch Address" button to display the nearest address to your current location. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Location Address Sample application screenshot](Screenshots/screenshot1.png "Location Address Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Location Address Sample](https://github.com/googlesamples/android-play-location/tree/master/LocationAddress) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Location/LocationSettings/README.md b/google-services/Location/LocationSettings/README.md index 3b65003..706b3a7 100644 --- a/google-services/Location/LocationSettings/README.md +++ b/google-services/Location/LocationSettings/README.md @@ -1,32 +1,31 @@ --- -name: Xamarin.Android - Location Settings Sample -description: This sample demonstrates how to use the Location SettingsApi to check if a device has the location settings required by an application, and... +name: Xamarin.Android - Location Settings +description: "Demonstrates how to use the Location SettingsApi to check if a device has the location settings required by an app (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-location-locationsettings --- # Location Settings Sample -This sample demonstrates how to use the Location SettingsApi to check if a device has the location settings +This sample demonstrates how to use the Location SettingsApi to check if a device has the location settings required by an application, and optionally provide a location dialog to update the device's location settings. ## Instructions -* Tap the "Start Updates" button to start receiving location updates. -* Tap the "Stop Updates" button to stop receiving location updates. - +- Tap the "Start Updates" button to start receiving location updates. +- Tap the "Stop Updates" button to stop receiving location updates. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Location Settings Sample application screenshot](Screenshots/screenshot1.png "Location Settings Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Location Settings Sample](https://github.com/googlesamples/android-play-location/tree/master/LocationSettings) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Location/LocationUpdates/README.md b/google-services/Location/LocationUpdates/README.md index 76cf4bc..47a1b6c 100644 --- a/google-services/Location/LocationUpdates/README.md +++ b/google-services/Location/LocationUpdates/README.md @@ -1,31 +1,33 @@ --- -name: Xamarin.Android - Location Updates Sample -description: This sample demonstrates how to use the Fused Location Provider API to get updates about a device's location. Instructions Tap the Start Updates... +name: Xamarin.Android - Location Updates +description: "Demonstrates how to use the Fused Location Provider API to get updates about a device's location (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-location-locationupdates --- # Location Updates Sample This sample demonstrates how to use the Fused Location Provider API to get updates about a device's location. ## Instructions -* Tap the "Start Updates" button to start receiving location updates. -* Tap the "Stop Updates" button to stop receiving location updates. - +- Tap the "Start Updates" button to start receiving location updates. +- Tap the "Stop Updates" button to stop receiving location updates. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Location Updates Sample application screenshot](Screenshots/screenshot1.png "Location Updates Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Location Updates Sample](https://github.com/googlesamples/android-play-location/tree/master/LocationUpdates) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Nearby/ConnectionsQuickstart/README.md b/google-services/Nearby/ConnectionsQuickstart/README.md index a586d78..0b7d4b9 100644 --- a/google-services/Nearby/ConnectionsQuickstart/README.md +++ b/google-services/Nearby/ConnectionsQuickstart/README.md @@ -1,34 +1,37 @@ --- -name: Xamarin.Android - Nearby Connections Sample +name: Xamarin.Android - Nearby Connections description: "Demonstrates how to use the Nearby Connections API to establish a connection between two devices and send messages between them...." page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-nearby-connectionsquickstart --- # Nearby Connections Sample This sample demonstrates how to use the Nearby Connections API to establish a connection between two devices and send messages between them. ## Prerequisites * Requires two devices running Android 4.4 "KitKat" or higher. ## Instructions * Tap the "Advertise" button on one device running the app. * Tap the "Discover" button on the other device running the app in order to discover the first device. ## Build Requirements Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Nearby Connections Sample application screenshot](Screenshots/Screenshot1.png "Nearby Connections Sample application screenshot") ## License Copyright (c) 2015 Google, Inc. Ported from [Nearby Connections Quickstart Sample](https://github.com/googlesamples/android-nearby/tree/master/connections-quickstart)
dotnet/android-samples
a98d7f7f05f5a5369a80211be2fba9a88ac3385c
onboard missing samples (Android Fit)
diff --git a/HowsMyTls/README.md b/HowsMyTls/README.md index ea5bcb0..fbbcf1a 100644 --- a/HowsMyTls/README.md +++ b/HowsMyTls/README.md @@ -1,15 +1,18 @@ --- name: Xamarin.Android - How's my TLS? -description: 'This sample demonstrates how to make a basic TLS connection using different classes availbale for Xamarin.Android developers: HttpWebRequest +...' +description: 'Demonstrates how to make a basic TLS connection using different classes available for Xamarin.Android developers' page_type: sample languages: - csharp products: - xamarin urlFragment: howsmytls --- # How's my TLS? -This sample demonstrates how to make a basic TLS connection using different classes availbale for Xamarin.Android developers: -* `HttpWebRequest` + `WebResponce` - doesn't have support of TLSv1.2, maximum version of supported TLS is 1.0 -* `AndroidClientHandler` + `HttpClient` + `AndroidHttpResponseMessage` - allows to establish secure TLSv1.2 connections +This sample demonstrates how to make a basic TLS connection using different classes available for Xamarin.Android developers: + +- `HttpWebRequest` + `WebResponce` - doesn't have support of TLSv1.2, maximum version of supported TLS is 1.0 +- `AndroidClientHandler` + `HttpClient` + `AndroidHttpResponseMessage` - allows to establish secure TLSv1.2 connections + +![Android screenshot showing TLS settings](Screenshots/0.png) diff --git a/google-services/Fitness/BasicHistoryApi/README.md b/google-services/Fitness/BasicHistoryApi/README.md index 2def7e3..04eddb3 100644 --- a/google-services/Fitness/BasicHistoryApi/README.md +++ b/google-services/Fitness/BasicHistoryApi/README.md @@ -1,31 +1,33 @@ --- -name: Xamarin.Android - Android Fit History Api Sample -description: This sample demonstrates how to use the Android Fit History API. Instructions Make sure to enable 'Google Sign-In' for your application via the... +name: Xamarin.Android - Android Fit History Api +description: "Demonstrates how to use the Android Fit History API (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-fitness-basichistoryapi --- # Android Fit History Api Sample This sample demonstrates how to use the Android Fit History API. ## Instructions -* Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). -* Log into a Google account to display mock step count data. - +- Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). +- Log into a Google account to display mock step count data. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Android Fit History Api Sample application screenshot](Screenshots/screenshot1.png "Android Fit History Api Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Android Fit History Api Sample](https://github.com/googlesamples/android-fit/tree/master/BasicHistoryApi) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Fitness/BasicHistorySessions/README.md b/google-services/Fitness/BasicHistorySessions/README.md index ef1b30e..9007902 100644 --- a/google-services/Fitness/BasicHistorySessions/README.md +++ b/google-services/Fitness/BasicHistorySessions/README.md @@ -1,32 +1,33 @@ --- -name: Xamarin.Android - Android Fit History Api Sessions Sample -description: This sample demonstrates how to use the Android Fit History API. Instructions Make sure to enable 'Google Sign-In' for your application via the... +name: Xamarin.Android - Android Fit History Api Sessions +description: "Demonstrates how to use the Android Fit History API (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-fitness-basichistorysessions --- # Android Fit History Api Sessions Sample This sample demonstrates how to use the Android Fit History API. ## Instructions -* Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). -* Log into a Google account to display mock session data. - +- Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). +- Log into a Google account to display mock session data. ## Build Requirements -Using this sample requires the Android SDK platform for Android 5.0 (API level 21). +Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Android Fit History Api Sessions Sample application screenshot](Screenshots/screenshot1.png "Android Fit History Api Sessions Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Android Fit History Api Sessions Sample](https://github.com/googlesamples/android-fit/tree/master/BasicHistorySessions) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Fitness/BasicRecordingApi/README.md b/google-services/Fitness/BasicRecordingApi/README.md index db63273..7b9f17f 100644 --- a/google-services/Fitness/BasicRecordingApi/README.md +++ b/google-services/Fitness/BasicRecordingApi/README.md @@ -1,31 +1,33 @@ --- -name: Xamarin.Android - Android Fit Recording Api Sessions Sample -description: This sample demonstrates how to use the Android Fit Recording API. Instructions Make sure to enable 'Google Sign-In' for your application via the... +name: Xamarin.Android - Android Fit Recording Api Sessions +description: "Demonstrates how to use the Android Fit Recording API (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-fitness-basicrecordingapi --- # Android Fit Recording Api Sessions Sample This sample demonstrates how to use the Android Fit Recording API. ## Instructions -* Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). -* Log into a Google account to display mock subscription data. - +- Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). +- Log into a Google account to display mock subscription data. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Android Fit Recording Api Sessions Sample application screenshot](Screenshots/screenshot1.png "Android Fit Recording Api Sessions Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Android Fit Recording Api Sessions Sample](https://github.com/googlesamples/android-fit/tree/master/BasicRecordingApi) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Fitness/BasicSensorsApi/README.md b/google-services/Fitness/BasicSensorsApi/README.md index 9fcb2e8..ead8c1d 100644 --- a/google-services/Fitness/BasicSensorsApi/README.md +++ b/google-services/Fitness/BasicSensorsApi/README.md @@ -1,31 +1,33 @@ --- -name: Xamarin.Android - Android Fit Sensors Api Sample -description: This sample demonstrates how to use the Android Fit Sensors API. Instructions Make sure to enable 'Google Sign-In' for your application via the... +name: Xamarin.Android - Android Fit Sensors Api +description: "Demonstrates how to use the Android Fit Sensors API (Android Lollipop)" page_type: sample languages: - csharp products: - xamarin +extensions: + tags: + - androidlollipop urlFragment: google-services-fitness-basicsensorsapi --- # Android Fit Sensors Api Sample This sample demonstrates how to use the Android Fit Sensors API. ## Instructions -* Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). -* Log into a Google account to display mock sensor data. - +- Make sure to enable 'Google Sign-In' for your application via the [Developer Console](https://developers.google.com/mobile/add?platform=android). +- Log into a Google account to display mock sensor data. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Android Fit Sensors Api Sample application screenshot](Screenshots/screenshot1.png "Android Fit Sensors Api Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Android Fit Sensors Api Sample](https://github.com/googlesamples/android-fit/tree/master/BasicSensorsApi) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file
dotnet/android-samples
718e00107621ebb92f036a3008b3c3da0f160d0a
onboard missing samples
diff --git a/google-services/AdMobExample/README.md b/google-services/AdMobExample/README.md index fdbf18c..7a63e35 100644 --- a/google-services/AdMobExample/README.md +++ b/google-services/AdMobExample/README.md @@ -1,31 +1,29 @@ --- name: Xamarin.Android - AdMobExample Sample -description: This sample demonstrates how to display different types of ads using Google AdMob with Google Play Services. Instructions Tap the Show Interstitial... +description: "Demonstrates how to display different types of ads using Google AdMob with Google Play Services" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-admobexample --- # AdMobExample Sample This sample demonstrates how to display different types of ads using Google AdMob with Google Play Services. ## Instructions * Tap the Show Interstitial Ad button to display an ad in between activity transition. - ## Build Requirements -Using this sample requires the Android SDK platform for Android 5.0 (API level 21). +Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![AdMobExample Sample application screenshot](Screenshots/fullscreen_ad.png "AdMobExample Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Google AdMob Quickstart Sample](https://github.com/googlesamples/google-services/tree/master/android/admob) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Analytics/README.md b/google-services/Analytics/README.md index 6eb905b..a8ecc10 100644 --- a/google-services/Analytics/README.md +++ b/google-services/Analytics/README.md @@ -1,33 +1,31 @@ --- name: Xamarin.Android - Analytics Sample -description: This sample demonstrates how to report screen views to Google Analytics. Instructions Add your Google Analytics Tracking ID in place of... +description: "Demonstrates how to report screen views to Google Analytics" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-analytics --- # Analytics Sample This sample demonstrates how to report screen views to Google Analytics. ## Instructions * Add your Google Analytics Tracking ID in place of "UA-XXXXXXX-X" in AnalyticsApplication.cs * Build and run. * Swipe between images to register screen views. - ## Build Requirements -Using this sample requires the Android SDK platform for Android 5.0 (API level 21). +Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Analytics Sample application screenshot](Screenshots/view_b.png "Analytics Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Google Analytics Quickstart](https://github.com/googlesamples/google-services/tree/master/android/analytics) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/AppIndexing/README.md b/google-services/AppIndexing/README.md index d56de7d..15e92bd 100644 --- a/google-services/AppIndexing/README.md +++ b/google-services/AppIndexing/README.md @@ -1,22 +1,22 @@ --- name: Xamarin.Android - App Indexing Sample -description: This sample demonstrates how to make your app viewable in Google Search using Google App Indexing. Instructions On the device's web browser,... +description: "Demonstrates how to make your app viewable in Google Search using Google App Indexing" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-appindexing --- # App Indexing Sample This sample demonstrates how to make your app viewable in Google Search using Google App Indexing. ## Instructions * On the device's web browser, navigate to the deep link URL defined in MainActivity.cs. -## Authors +## Licednse + Copyright (c) 2015 Google, Inc. Ported from [Google App Indexing Quickstart Sample](https://github.com/googlesamples/google-services/tree/master/android/app-indexing) -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/AppInvite/README.md b/google-services/AppInvite/README.md index 4f7b3b8..af89c7e 100644 --- a/google-services/AppInvite/README.md +++ b/google-services/AppInvite/README.md @@ -1,35 +1,33 @@ --- name: Xamarin.Android - App Invite Sample -description: This sample demonstrates how to allow your users to invite people they know to use your app using Google App Invites. Instructions Tap the Invite... +description: "Demonstrates how to allow your users to invite people they know to use your app using Google App Invites" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-appinvite --- # App Invite Sample This sample demonstrates how to allow your users to invite people they know to use your app using Google App Invites. ## Instructions * Tap the Invite Friends button and Log in to a valid Google developer account. * Follow these steps to [enable Google services for your app.](https://developers.google.com/mobile/add?platform=android&cntapi=appinvite&cnturl=https:%2F%2Fdevelopers.google.com%2Fapp-invites%2Fandroid%2Fguides%2Fapp%3Fconfigured%3Dtrue%23add-config&cntlbl=Continue%20Adding%20App%20Invites) * Make sure to provide the correct package name - `com.xamarin.appinvite` for the sample when configuring. * Refer to the following [documentation](https://docs.xamarin.com/guides/android/deployment,_testing,_and_metrics/MD5_SHA1/offline.pdf) if you need help locating your keystore's SHA1 signature. * Once the service is configured, you'll be able to send an invite to an email address or phone number. - ## Build Requirements -Using this sample requires the Android SDK platform for Android 5.0 (API level 21). +Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![App Invite Sample application screenshot](Screenshots/app-invites-sample.png "App Invite Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Google App Invites Quickstart Sample](https://github.com/googlesamples/google-services/tree/master/android/appinvites) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/GCMSample/README.md b/google-services/GCMSample/README.md index 8c3fdd6..581c901 100644 --- a/google-services/GCMSample/README.md +++ b/google-services/GCMSample/README.md @@ -1,39 +1,39 @@ --- name: Xamarin.Android - Google Cloud Messaging Sample -description: This sample demonstrates how to use Google Cloud Messaging to register an Android app for GCM and handle the receipt of a GCM message. Instructions... +description: "Demonstrates how to use Google Cloud Messaging to register an Android app for GCM and handle the receipt of a GCM message" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-gcmsample --- # Google Cloud Messaging Sample This sample demonstrates how to use Google Cloud Messaging to register an Android app for GCM and handle the receipt of a GCM message. ## Instructions + * Authorize your app in the Google Developers Console (link below) to get your API Key and Sender ID * Replace the value for `gcm_defaultSenderId` in `GCMSample/Resources/values/strings.xml` with your Sender ID. * Replace the value for `API_KEY` in `GcmSender/GcmSender.cs` with your API Key. * Replace all instances of `com.xamarin.gcmquickstart` in the AndroidManifest.xml with your package name (com.yourcompany.______). * Launch the app and observe it authenticating with the server. * Send a message using the console application project while the app is still open. * Observe the notification being sent to your device/emulator. ## Troubleshooting -Note: Make sure you've authorized the app in the [Google Developers Console](https://developers.google.com/mobile/add) before use. +Note: Make sure you've authorized the app in the [Google Developers Console](https://developers.google.com/mobile/add) before use. ## Build Requirements -Using this sample requires the Android SDK platform for Android 5.0 (API level 21). +Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Google Cloud Messaging Sample application screenshot](Screenshots/Screenshot1.png "Google Cloud Messaging Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Google Cloud Messaging Sample](https://github.com/googlesamples/google-services/tree/master/android/gcm) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/Nearby/ConnectionsQuickstart/README.md b/google-services/Nearby/ConnectionsQuickstart/README.md index 5512528..a586d78 100644 --- a/google-services/Nearby/ConnectionsQuickstart/README.md +++ b/google-services/Nearby/ConnectionsQuickstart/README.md @@ -1,33 +1,34 @@ --- name: Xamarin.Android - Nearby Connections Sample -description: This sample demonstrates how to use the Nearby Connections API to establish a connection between two devices and send messages between them.... +description: "Demonstrates how to use the Nearby Connections API to establish a connection between two devices and send messages between them...." page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-nearby-connectionsquickstart --- # Nearby Connections Sample This sample demonstrates how to use the Nearby Connections API to establish a connection between two devices and send messages between them. ## Prerequisites + * Requires two devices running Android 4.4 "KitKat" or higher. ## Instructions * Tap the "Advertise" button on one device running the app. * Tap the "Discover" button on the other device running the app in order to discover the first device. ## Build Requirements + Using this sample requires the Android SDK platform for Android 5.0 (API level 21). ![Nearby Connections Sample application screenshot](Screenshots/Screenshot1.png "Nearby Connections Sample application screenshot") -## Authors +## License + Copyright (c) 2015 Google, Inc. Ported from [Nearby Connections Quickstart Sample](https://github.com/googlesamples/android-nearby/tree/master/connections-quickstart) - -Ported to Xamarin.Android by Aaron Sky \ No newline at end of file diff --git a/google-services/SigninQuickstart/README.md b/google-services/SigninQuickstart/README.md index 7602467..e45631e 100644 --- a/google-services/SigninQuickstart/README.md +++ b/google-services/SigninQuickstart/README.md @@ -1,43 +1,43 @@ --- name: Xamarin.Android - Google Sign-In Sample -description: This sample demonstrates how to authenticate a user with the Google Api Client in Google Play Services. Setup You must follow the next guide to... +description: "Demonstrates how to authenticate a user with the Google Api Client in Google Play Services" page_type: sample languages: - csharp products: - xamarin urlFragment: google-services-signinquickstart --- # Google Sign-In Sample This sample demonstrates how to authenticate a user with the Google Api Client in Google Play Services. ## Setup * You must follow the next guide to configure the Sign-In feature: https://developers.google.com/identity/sign-in/android/start * On Step 2 (Configuration File), you can open [this URL](https://developers.google.com/mobile/add?platform=android&cntapi=signin&cntapp=SignInQuickstart&cntpkg=com.xamarin.signinquickstart&cnturl=https:%2F%2Fdevelopers.google.com%2Fidentity%2Fsign-in%2Fandroid%2Fstart%3Fconfigured%3Dtrue&cntlbl=Continue%20with%20Try%20Sign-In) for this specific sample. * Replace the google-services.json file by your generated file. ## Instructions * Tap the "Sign in with Google" button to sign in. * Tap the "Sign Out" button to sign out of the current session. * Tap "Disconnect" button to disconnect sign in with the app. ## Troubleshooting * DEVELOPER_ERROR: Make sure you're using the generated android debug keystore by Xamarin for generate SHA-1. Check [this article](https://docs.microsoft.com/xamarin/android/deploy-test/signing/keystore-signature) to get it. Note: Make sure you've authorized the app in the [Google Developers Console](https://console.developers.google.com/project) before use. ## Build Requirements Using this sample requires the Android SDK platform for Android 5.0+ (API level 21). ![Google Sign-In Sample application screenshot](Screenshots/promt.png "Google Sign-In Sample application screenshot") ## License Copyright (c) 2015 Google, Inc. Ported from [Google Sign-In Sample](https://developers.google.com/mobile/add)
dotnet/android-samples
a6752c694f0fae6014c2915383f7fd9968848726
onboard missing samples
diff --git a/FragmentTransition/README.md b/FragmentTransition/README.md index 4daf735..db66922 100644 --- a/FragmentTransition/README.md +++ b/FragmentTransition/README.md @@ -1,14 +1,16 @@ --- name: Xamarin.Android - Fragment Transition -description: This sample demonstrates how to start a transition right after a fragment transaction. This allows for more fluid transitions and animations... +description: "Demonstrates how to start a transition right after a fragment transaction. This allows for more fluid transitions and animations..." page_type: sample languages: - csharp products: - xamarin urlFragment: fragmenttransition --- # Fragment Transition -This sample demonstrates how to start a transition right after a fragment transaction. This allows for more fluid transitions and animations between different fragments such has holding a image in place as the fragment exits and then expand to it's new location/size. + +This sample demonstrates how to start a transition right after a fragment transaction. This allows for more fluid transitions and animations between different fragments such has holding a image in place as the fragment exits and then expand to it's new location/size. Note: This sample is not fluid on Android L Developer Preview. This problem exists for both the Monodroid port and the original Java sample from Google. -Ported By: Ben O'Halloran \ No newline at end of file + +![Android app screen showing fragments](Screenshots/log.png) diff --git a/FusedLocationProvider/README.md b/FusedLocationProvider/README.md index 1ddc95b..eeada70 100644 --- a/FusedLocationProvider/README.md +++ b/FusedLocationProvider/README.md @@ -1,17 +1,18 @@ --- name: Xamarin.Android - FusedLocationProvider Sample -description: This sample provides an example of gathering location data using the FusedLocationProvider, available as part of Google Play services. A detailed... +description: "Example gathering location data using the FusedLocationProvider, available as part of Google Play services" page_type: sample languages: - csharp products: - xamarin urlFragment: fusedlocationprovider --- # FusedLocationProvider Sample -This sample provides an example of gathering location data using the -FusedLocationProvider, available as part of Google Play services. A detailed -walkthrough of the sample code can be found in the -[Xamarin Location Services](https://developer.xamarin.com/guides/android/platform_features/maps_and_location/location/) -guide. \ No newline at end of file +This sample provides an example of gathering location data using the +FusedLocationProvider, available as part of Google Play services. A detailed +walkthrough of the sample code can be found in the +[Xamarin Location Services](https://docs.microsoft.com/xamarin/android/platform/maps-and-location/location) guide. + +![Android screen showing latitude, longitude coordinates](Screenshots/loc2.png) diff --git a/GestureBuilder/README.md b/GestureBuilder/README.md index 35d5deb..4c4a9b2 100644 --- a/GestureBuilder/README.md +++ b/GestureBuilder/README.md @@ -1,19 +1,18 @@ --- name: Xamarin.Android - GestureBuilder -description: This is a port of Android SDK sample GestureBuilder which is a showcase for android.gesture API. +description: "Port of Android SDK sample GestureBuilder which is a showcase for android.gesture API" page_type: sample languages: - csharp products: - xamarin urlFragment: gesturebuilder --- # GestureBuilder This is a port of Android SDK sample "GestureBuilder" which is a showcase -for android.gesture API. +for `android.gesture` API. -## Authors -Android Open Source Project (original Java) -Atsushi Eno (C# port) +## License +Android Open Source Project (original Java)