Revert "Draft: simple web server added"

This commit is contained in:
vshcherb 2020-09-01 16:35:23 +02:00 committed by GitHub
parent fe36f0e8d4
commit 0310eb92f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 0 additions and 34937 deletions

View file

@ -408,7 +408,6 @@
</intent-filter>
</receiver>
<activity android:name=".activities.ServerActivity" android:label="@string/shared_string_settings" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.activities.SettingsActivity" android:label="@string/shared_string_settings" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.activities.SettingsGeneralActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation" />

View file

@ -1,110 +0,0 @@
body {
margin:0;
padding:20px;
max-width: 1250px;
}
table {
border-collapse: collapse;
}
.send-private-giveaway, .register-giveaway, .access-server-logs, .update-btc-report {
margin: 20px 0px;
border: 1px solid #e6e6e6;
width: 50%;
}
.wrapper {
list-style-type: none;
padding: 0;
border-radius: 3px;
}
.form-row {
display: flex;
justify-content: flex-start;
align-items: flex-start;
padding: 5px;
text-align: left;
}
.form-row > label {
flex: 1;
}
.form-row > input {
flex: 1;
width: auto;
}
.form-row > button {
flex: 1;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
tr:hover {background-color: #d5d5d5;}
th {
background-color: #4CAF50;
color: white;
}
.loader,
.loader:before,
.loader:after {
border-radius: 50%;
width: 2.5em;
height: 2.5em;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: load7 1.8s infinite ease-in-out;
animation: load7 1.8s infinite ease-in-out;
}
.loader {
color: #00ffff;
font-size: 10px;
margin: 25px auto;
position: relative;
text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
.loader:before,
.loader:after {
content: '';
position: absolute;
top: 0;
}
.loader:before {
left: -3.5em;
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.loader:after {
left: 3.5em;
}
@-webkit-keyframes load7 {
0%,
80%,
100% {
box-shadow: 0 2.5em 0 -1.3em;
}
40% {
box-shadow: 0 2.5em 0 0;
}
}
@keyframes load7 {
0%,
80%,
100% {
box-shadow: 0 2.5em 0 -1.3em;
}
40% {
box-shadow: 0 2.5em 0 0;
}
}

View file

@ -1,606 +0,0 @@
::-webkit-input-placeholder {color:#000;}
::-moz-placeholder {color:#000;}
:-moz-placeholder {color:#000;}
:-ms-input-placeholder {color:#000;}
h2, h3 {
font-size: 20px;
}
.nav-holder {
padding: 0 20px;
background: #ff8e01;
}
.navigation {
max-width: 1100px;
margin: 0 auto;
}
.navigation li {
margin-right: 30px;
}
.navigation a {
display: block;
padding: 30px 0;
color: rgba(255, 255, 255, 0.5);
font-size: 15px;
font-weight: bold;
text-decoration: none;
text-transform: uppercase;
border-bottom: 4px solid #ff8e01;
outline: none;
}
.navigation a:hover {
color: #fff;
}
.navigation li {
display: inline-block;
vertical-align: middle;
}
.navigation li.active a,
.navigation li.active a:focus,
.navigation li.active a:hover {
color: #fff;
border-bottom: 4px solid #4464ad;
}
#month-selection {
margin-bottom: 10px;
}
#region-selection {
margin-bottom: 10px;
}
.infobox {
font-size: 16px;
line-height: 150%;
}
.infobox h2 {
font-size: 33px;
}
.infobox h3 {
margin-top: 35px;
font-weight: bold;
}
.infobox ul {
list-style-type: disc;
list-style-position: inside;
}
.report-period-group {
padding: 20px;
background: #f2f2f2;
}
.report-period-group.supporters {
float: left;
width: 30%;
height: 120px;
}
.supporters-total {
float: right;
width: 70%;
height: 120px;
border: 1px solid #ddd;
border-left: 0 none;
}
.supporters-total-holder:after {
content: '';
display: table;
clear: both;
float: none;
}
.report-group {
display: inline-block;
vertical-align: top;
}
.report-group.period {
width: 100%;
max-width: 250px;
margin-right: 40px;
}
.supporters .report-group.period {
margin-right: 0;
}
.report-group.region {
width: 100%;
max-width: 420px;
}
.styled-select {
position: relative;
width: 100%;
height: 42px;
overflow: hidden;
background: #fff;
border: 1px solid #ccc;
border-radius: 2px;
}
.styled-select:before {
z-index: 0;
content: '';
position: absolute;
top: 10px;
left: 10px;
width: 20px;
height: 20px;
background: url('../images/main-sprite.png') no-repeat;
}
.styled-select:after {
z-index: 0;
content: '';
position: absolute;
top: 12px;
right: 10px;
width: 20px;
height: 20px;
background: url('../images/main-sprite.png') no-repeat -200px -80px;
}
.report-group.period .styled-select:before {
background-position: -251px -110px;
}
.report-group.region .styled-select:before {
background-position: -290px -110px;
}
.report-group.round .styled-select:before {
background-position: -290px -110px;
}
.styled-select select {
position: relative;
z-index: 1;
display: block;
width: 110%;
height: 42px;
padding: 10px 45px 10px 35px;
border: 0 none;
border-radius: 0;
background: transparent;
text-overflow: ellipsis;
}
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
select:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
.report-total-div {
border: 1px solid #e6e6e6;
border-top: 0 none;
}
.overview-body {
padding: 15px 15px 0;
}
.overview-hint {
font-weight: bold;
margin: 5px 0 20px;
}
.overview-hint span {
color: #484dde;
}
.overview {
position: relative;
display: inline-block;
vertical-align: top;
padding-left: 50px;
margin-right: 80px;
margin-bottom: 20px;
text-align: left;
}
.overview:last-child {
margin-right: 0;
}
.overview:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 40px;
background: url('../images/main-sprite.png') no-repeat;
}
.overview-changes:before {
background-position: -0px -280px;
}
.overview-users:before {
background-position: -40px -280px;
}
.overview-region:before {
background-position: -80px -280px;
}
.overview-active_supporters:before {
background-position: -40px -280px;
}
.overview-register_supporters:before {
background-position: -120px -280px;
}
.overview-btc:before {
background-position: -160px -280px;
}
.overview-total_weight:before {
background-position: -200px -280px;
}
.overview p {
margin: 0;
margin-bottom: -10px;
font-size: 30px;
font-weight: bold;
line-height: 1.2;
}
.overview span {
color: #999;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 2px;
}
#report-ranking,
#users-ranking,
#support-country-table-header,
#support-table-header,
#recipients-table-header {
margin-top: 50px;
font-size: 20px;
}
#report-ranking span {
display: block;
font-size: 13px;
font-weight: normal;
color: #999;
text-transform: uppercase;
}
.table {
font-size: 14px;
}
.table thead span {
display: block;
color: #999;
font-size: 11px;
text-transform: uppercase;
}
.table tbody tr td {
padding: 12px;
font-weight: bold;
}
.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
vertical-align: middle;
border-bottom-color: #ff8f00;
font-weight: normal;
}
.table-controls.hidden {
display: none;
}
.table-controls {
position: relative;
padding-right: 185px;
}
.tc.search {
position: relative;
}
.tc.search:before {
content: '';
position: absolute;
top: 10px;
left: 12px;
width: 20px;
height: 20px;
background: url('../images/main-sprite.png') no-repeat -300px -80px;
}
.tc.search input {
max-width: 350px;
height: 42px;
padding-left: 40px;
border-radius: 2px;
}
.tc.entries {
position: absolute;
top: 0;
right: 0;
width: 100%;
max-width: 180px;
font-size: 14px;
}
.tc.entries .styled-select {
display: inline-block;
vertical-align: middle;
width: 80px;
}
.tc.entries .styled-select:before {
content: none;
}
.tc.entries label {
display: block;
text-align: right;
}
.tc.entries select {
display: inline-block;
vertical-align: middle;
width: 125%;
padding: 10px 0 10px 10px;
}
.sorting_desc,
.sorting_asc,
.sorting {
position: relative;
}
.sorting_desc:after,
.sorting_asc:after {
content: '' !important;
position: absolute;
top: 50%;
right: 0;
width: 20px;
height: 20px;
background: url('../images/main-sprite.png') no-repeat;
transform: translate(0, -50%);
}
.sorting_asc:after {
background-position: -160px -140px;
}
.sorting_desc:after {
background-position: -200px -140px;
}
.sorting:after {
content: '' !important;
position: absolute;
top: 50%;
right: 0;
width: 20px;
height: 20px;
background: url('../images/main-sprite.png') no-repeat -180px -140px;
transform: translate(0, -50%);
}
.pagination > .active > a,
.pagination > .active > a:focus,
.pagination > .active > a:hover,
.pagination > .active > span,
.pagination > .active > span:focus,
.pagination > .active > span:hover {
background-color: #ff8f00;
border-color: #ff8f00;
}
.pagination > li > a,
.pagination > li > span {
color: #000;
}
.pagination > li > a:hover,
.pagination > li > span:hover {
background-color: rgba(255, 143, 0, 0.5);
border-color: #ff8f00;
color: #fff;
}
.registration {
display: inline-block;
vertical-align: top;
width: 49%;
min-height: 420px;
padding: 20px;
margin-top: 20px;
margin-right: 1%;
background: #f2f2f2;
}
.registration.contributor-registration {
margin-right: 0;
}
.registration h4 {
margin-top: 0;
font-size: 20px;
}
.recipient-registration label {
margin-top: 10px;
font-size: 14px;
font-weight: normal;
}
.recipient-registration .form-control {
margin: 0;
border-radius: 2px;
height: 42px;
padding-left: 40px;
}
.recipient-registration .input-holder {
position: relative;
}
#agree_osm_live {
margin-left: 5px;
margin-top: 3px;
}
.agree_osm_live_label {
position: relative;
cursor: pointer;
font-size: 14px;
margin-left: 7px;
margin-bottom: 15px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
.recipient-registration .input-holder:before {
content: '';
position: absolute;
top: 10px;
left: 12px;
width: 20px;
height: 20px;
background: url('../images/main-sprite.png') no-repeat;
}
.recipient-registration .input-holder.input-user:before {
background-position: -180px -80px;
}
.recipient-registration .input-holder.input-pass:before {
height: 21px;
background-position: -172px -109px;
}
.recipient-registration .input-holder.input-bitcoin:before {
background-position: -210px -110px;
}
.recipient-registration .input-hint {
color: #999;
line-height: 1.4;
}
.recipient-registration .btn,
.recipient-registration .btn:active {
background: #575bde;
border: 1px solid #3d42bf;
color: #fff;
font-weight: bold;
}
.registration-badges img {
border: none;
height: 45px;
margin-bottom: 20px;
}
.contributor-registration p {
font-size: 14px;
line-height: 1.4;
}
.contributor-registration .btc-address {
padding: 15px 10px;
margin-bottom: 10px;
background: #ff8f00;
border-radius: 2px;
color: #fff;
font-size: 14px;
font-weight: bold;
}
#recipients-info-div {
margin-top: 20px;
margin-bottom: 20px;
}
.maincontainer {
background-color: white;
}
.full-width-banner {
width: 100%;
margin: 20px auto;
}
.full-width-banner img {
display: block;
max-width: 100%;
}
.vlabel {
font-size: 16px;
font-weight: bold;
}
.form-control {
margin-bottom: 10px;
}
.tab-content {
margin-top: 25px;
}
.container {
max-width: 1135px;
margin: 10px auto 50px;
}
#recipients-table td:nth-child(7) {
word-break: break-all;
padding: 8px 5px !important;
}
@media screen and (max-width: 1200px) {
.nav-holder .navigation{
max-width: 940px;
}
}
@media screen and (max-width: 991px) {
.nav-holder .navigation{
max-width: 720px;
}
.report-group.period {
max-width: 420px;
margin-right: 0;
}
.supporters-total .overview {
margin-right: 20px;
}
}
@media screen and (max-width: 770px) {
.report-period-group.supporters {
float: none;
width: 100%;
height: 120px;
}
.supporters-total {
float: none;
width: 100%;
height: auto;
border: 1px solid #ddd;
border-top: 0 none;
}
.supporters-total:after {
content: '';
display: table;
clear: both;
float: none;
}
.registration {
width: 100%;
min-height: auto;
margin-right: 0;
margin-bottom: 20px;
}
}
@media screen and (max-width: 650px) {
#recipients-table th:nth-child(4),
#recipients-table td:nth-child(4),
#recipients-table th:nth-child(3),
#recipients-table td:nth-child(3) {
display: none;
}
.navigation li a,
.navigation li.active a,
.navigation li.active a:focus,
.navigation li.active a:hover {
border-bottom: 0 none;
padding: 15px 0;
}
}
@media screen and (max-width: 550px) {
.table {
font-size: 13px;
}
.table thead {
font-size: 11px;
}
.table thead span {
text-transform: lowercase;
}
.table th,
.table td {
padding: 8px 2px !important;
vertical-align: middle !important;
font-weight: normal !important;
text-align: center;
}
.table th.sorting_asc:before,
.table th.sorting_desc:before {
content: '';
position: absolute;
left: 50%;
margin-left: -2px;
border: 4px solid transparent;
}
.table th.sorting_asc:before {
bottom: 1px;
border-top-color: #ff8f00;
}
.table th.sorting_desc:before {
top: 1px;
border-bottom-color: #ff8f00;
}
.table th:after {
content: none !important;
}
.table-controls {
padding-right: 145px;
}
.tc.entries {
font-size: 12px;
}
.tc.entries span {
display: inline-block;
vertical-align: middle;
width: 30%;
text-align: center;
}
.contributor-registration .btc-address {
word-break: break-all;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,117 +0,0 @@
/* Slider */
.slick-slider
{
position: relative;
display: block;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list
{
position: relative;
display: block;
overflow: hidden;
margin: 0;
padding: 0;
}
.slick-list:focus
{
outline: none;
}
.slick-list.dragging
{
cursor: pointer;
cursor: hand;
}
.slick-slider .slick-track,
.slick-slider .slick-list
{
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track
{
position: relative;
top: 0;
left: 0;
display: block;
}
.slick-track:before,
.slick-track:after
{
display: table;
content: '';
}
.slick-track:after
{
clear: both;
}
.slick-loading .slick-track
{
visibility: hidden;
}
.slick-slide
{
display: none;
float: left;
height: 100%;
min-height: 1px;
}
[dir='rtl'] .slick-slide
{
float: right;
}
.slick-slide img
{
display: block;
}
.slick-slide.slick-loading img
{
display: none;
}
.slick-slide.dragging img
{
pointer-events: none;
}
.slick-initialized .slick-slide
{
display: block;
}
.slick-loading .slick-slide
{
visibility: hidden;
}
.slick-vertical .slick-slide
{
display: block;
height: auto;
border: 1px solid transparent;
}
.slick-arrow.slick-hidden {
display: none;
}

View file

@ -1,98 +0,0 @@
/* Slider */
.slick-slider {
position: relative;
display: block;
box-sizing: border-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list {
position: relative;
overflow: hidden;
display: block;
margin: 0;
padding: 0;
&:focus {
outline: none;
}
&.dragging {
cursor: pointer;
cursor: hand;
}
}
.slick-slider .slick-track,
.slick-slider .slick-list {
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track {
position: relative;
left: 0;
top: 0;
display: block;
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
.slick-loading & {
visibility: hidden;
}
}
.slick-slide {
float: left;
height: 100%;
min-height: 1px;
[dir="rtl"] & {
float: right;
}
img {
display: block;
}
&.slick-loading img {
display: none;
}
display: none;
&.dragging img {
pointer-events: none;
}
.slick-initialized & {
display: block;
}
.slick-loading & {
visibility: hidden;
}
.slick-vertical & {
display: block;
height: auto;
border: 1px solid transparent;
}
}
.slick-arrow.slick-hidden {
display: none;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,43 +0,0 @@
@font-family: 'Roboto Regular';
@text-color: #000;
@oposite-text-color: #fff;
@header-color: #536dfe;
@read-more-color: #adadad;
@brand-orange: #ff8f00;
@opacity-orange-overlay: 0.9;
@separator-bg: #ffbb00;
@badge-free: #f3f3f3;
@badge-free-text: #737373;
@badge-paid: #62c452;
@badge-paid-text: #fff;
@footer-bg: #292f33;
@footer-text-color: #fff;
@footer-header-color: #698d8f;
@footer-header-underline-color: #2f4445;
@footer-copyright-color: #525e66;
@footer-font-family: Arial;
@footer-contact-btn-border: #394247;
@index-app-features-header: #ffa516;
@index-app-features-subheader: #c1c1c1;
@index-banner-btn-bg: #ffa516;
@index-header-color: #000;
@index-subheader-color: #737373;
@index-slider-btn-active: #ffa516;
@index-slider-btn-passive: #d4d4d4;
@index-recomendations-username: #212121;
@index-recomendations-service: #9e9e9e;
@index-news-link-color: #266ce0;
@index-news-read-more-link: #adadad;
@index-news-timestamp: #adadad;
@index-poll-btn-bg: #ff8f00;
@index-poll-result-btn-bg: #ff6c00;
@index-poll-radio-btn-active: #ff8f00;
@index-poll-radio-btn-border: #bbb;
@blog-article-header: #536dfe;
@help-question-link: #454ade;
@help-question-border: #e6e7ec;

View file

@ -1,2 +0,0 @@
/***********************EMPTY USED BY HELP inlining but already defined in site.css
*********************************************/

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 574 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 584 KiB

View file

@ -1,98 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OsmAnd - Offline Mobile Maps and Navigation</title>
<link rel="stylesheet" type="text/css" href="/css/site.css?v=4"/>
<!-- <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.1.0/dist/leaflet.js"></script>
<script type="text/javascript" src="/scripts/jquery-3.1.0.min.js"></script>
<!--
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
-->
<script type="text/javascript" src="/scripts/js.cookie.js"></script>
<script type="text/javascript" src="/scripts/go.js?v=5"></script>
<script>
function getMarkerContent(feature) {
var p = feature.properties;
var popupContent = p.title;
if(p.opr_id) {
popupContent += " (" + p.opr_id+") ";
}
if(p.tags) {
for (var t in p.tags) {
popupContent += "<br>" + t + " " + p.tags[t];
}
}
if(p.opr_id) {
popupContent += "<br><a href=\'/api/admin?view=objects&browse=type&type=opr.place&subtype=id&key=" +
p.opr_id + "\'>OpenPlaceReviews</a>";
}
if(p.osm_id) {
popupContent += "<br><a href=\'https://www.openstreetmap.org/" +
p.osm_type + "/" + p.osm_id + "\'>OpenStreetMap</a>";
}
return popupContent;
}
function markerClick(e){
}
function setupMarkers(){
$.ajax({
type: 'GET',
url: "/favorites",
async: false,
contentType: "application/json",
dataType: 'json',
complete: function(r) {
var points = JSON.parse(r.responseText);
points.forEach(e => {
window.goMap.map.addPopupMarker(e,markerClick);
});
},
error: function(e) {
alert("Error happened while getting favourite points "+e.message);
}
});
}
$( document ).ready(function() {
setupMarkers();
});
</script>
</head>
<body>
<div class="gocontainer" id="gocontainer">
<div class="goheader">
<a href="/"><img src="/images/logo-grey.png" class="logo"/></a>
<div class="coordinatescontainer">
<div><span class="title">LAT</span><span class="coordinate latitude"></span></div>
<div><span class="title">LON</span><span class="coordinate longitude"></span></div>
</div>
<div class="clear:both;"></div>
</div>
<div id="map"></div>
<div class="overlay" style="display:none;"></div>
<div class="popup" style="display:none;">
<div class="logo"></div>
<h1>Did you know</h1>
<p>OsmAnd has an iOS application</p>
<a class="button yes" href="javascript:void(0);">Yep, I've already got it</a>
<a class="button no" href="javascript::void(0);">Nope, but I'd love to try it</a>
<a class="button cancel" href="javascript:void(0);">Leave me alone</a>
</div>
</div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -1,86 +0,0 @@
var blogArticles = [
{title:'OsmAnd for iPhone is released', url:'blog.html?id=osmand-ios', id:'osmand-ios', gatag:'osmand_ios'},
{title:'Nautical charts', url:'blog.html?id=nautical-charts', id:'nautical-charts', gatag:'nautical_charts'},
{title:'OsmAnd DVR goes live', url:'blog.html?id=osmand-dvr-goes-live', id:'osmand-dvr-goes-live', gatag:'osmand_dvr_goes_live'},
{title:'OsmAnd 1.9', url:'blog.html?id=osmand-1-9-released', id:'osmand-1-9-released', gatag:'osmand_1_9'},
{title:'OsmAnd 1.8', url:'blog.html?id=osmand-1-8-released', id:'osmand-1-8-released', gatag:'osmand_1_8'},
{title:'OsmAnd 1.7', url:'blog.html?id=osmand-1-7-released', id:'osmand-1-7-released', gatag:'osmand_1_7'},
{title:'OsmAnd 1.6 Released', url:'blog.html?id=osmand-1-6-released', id:'osmand-1-6-released', gatag:'osmand_1_6'},
{title:'OsmAnd 1.5 Released', url:'blog.html?id=osmand-1-5-released', id:'osmand-1-5-released', gatag:'osmand_1_5'}
];
var webSiteUrl = "http://osmand.net";
$.urlParam = function(url, name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url);
if (results==null){
return null;
}
else{
return results[1] || 0;
}
}
function blog(container){
var getFullArticleUrl = function(articleObj){
return webSiteUrl + "/" + articleObj.url;
}
var fixTwitter =function (){
$('#___plusone_0 iframe').css('height', '21px');
}
var updateMetaTags = function(articleObj){
if (articleObj && articleObj != null){
var articleFullUrl = getFullArticleUrl(articleObj);
$('meta[property="og:title"]').attr('content', articleObj.title);
$('meta[property="og:url"]').attr('content', articleFullUrl);
$('meta[property="og:description"]').attr('content', articleObj.title);
$('link[rel="canonical"]').attr('href', articleFullUrl);
$('div.fb-like').attr('data-href', articleFullUrl);
$('.twitter-share-button').attr('data-url', articleFullUrl);
}
}
var getArticleById = function(articleid){
for(var i=0; i < blogArticles.length;++i){
if (blogArticles[i].id === articleid){
return blogArticles[i];
}
}
return null;
}
var init = function(){
container.empty();
for(var i=0; i < blogArticles.length; ++i){
var link = blogArticles[i];
container.append('<li><a data-gatag="' +link.gatag+ '" data-index="' + link.index+ '" href="' + link.url + '">' + link.title + '</a></li>');
}
var articleid = $.urlParam(window.location.href, 'id');
if (!articleid || articleid == null){
articleid = blogArticles[0].id;
}
//hide share buttons
$('.share_buttons').css('display', 'none');
updateMetaTags(getArticleById(articleid));
var url = 'blog_articles' + '/' + articleid + ".html";
$( ".article" ).load(url, function( response, status, xhr) {
if ( status != "error" ) {
$('.share_buttons').css('display', 'block');
setTimeout(fixTwitter, 5000);
}
});
}
init();
}

View file

@ -1,268 +0,0 @@
var requestUtils={
'getParamValue':function(paramName){
let value= (location.search.split(paramName + '=')[1]||'').split('&')[0];
if (value && value.length > 0){
return value;
}
return null;
},
'isIOS':function(){
return /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
},
'redirect':function(newUrl){
document.location = newUrl;
}
};
var goMap = {
'config':{
'containerid': 'gocontainer',
'defaults':{
'lat':50.27,
'lon':30.30,
'zoom':13
}
},
'utils':{
'getPointFromUrl':function(){
let point = {};
point.lat = requestUtils.getParamValue('lat');
point.lon = requestUtils.getParamValue('lon');
point.zoom = requestUtils.getParamValue('z');
return point;
},
'isPointComplete':function(point){
if (!point.lat || !point.lon){
return false;
}
return true;
},
'extendPoint':function(initialPoint, newPoint){
let point={};
point.lat=newPoint.lat;
if (!point.lat || point.lat == null){
point.lat = initialPoint.lat;
}
point.lon=newPoint.lon;
if (!point.lon || point.lon == null){
point.lon = initialPoint.lon;
}
point.zoom=newPoint.zoom;
if (!point.zoom || point.zoom == null){
point.zoom = initialPoint.zoom;
}
return point;
}
},
'init': function(config){
if (config && typeof (config) == 'object') {
$.extend(goMap.config, config);
}
goMap.$container = $('#' + goMap.config.containerid);
goMap.$footer = goMap.$container.find('.gofooter');
goMap.$latitude = goMap.$container.find('.latitude');
goMap.$longitude = goMap.$container.find('.longitude');
let inputPoint = goMap.utils.getPointFromUrl();
goMap.point = goMap.utils.extendPoint(goMap.config.defaults, inputPoint);
goMap.refreshCoordinates();
goMap.map =$.mapwidget();
goMap.map.showPoint(goMap.point);
let inputComplete = goMap.utils.isPointComplete(inputPoint);
if (inputComplete){
goMap.map.addMarker(goMap.point);
}
goMap.point = goMap.utils.getPointFromUrl();
},
'refreshCoordinates':function(){
goMap.$latitude.text(goMap.point.lat);
goMap.$longitude.text(goMap.point.lon);
}
};
function toColor(num) {
num >>>= 0;
var b = num & 0xFF,
g = (num & 0xFF00) >>> 8,
r = (num & 0xFF0000) >>> 16,
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
return "rgba(" + [r, g, b, a].join(",") + ")";
}
(function($) {
$.mapwidget = function(config) {
var loc = goMap.point.lat + '/' + goMap.point.lon;
var lparams = '?mlat='+goMap.point.lat + '&mlon=' + goMap.point.lon;
var mapobj={
config: $.extend({
'mapid':'map',
'maxzoom':20,
'maxnativezoom':19,
'sourceurl':'https://tile.osmand.net/hd/{z}/{x}/{y}.png',
'attribution':'&copy; <a href="https://www.openstreetmap.org/'+lparams+'#map=15/'+loc+'">OpenStreetMap</a> contributors'
}, config),
init:function(){
mapobj.map = L.map(mapobj.config.mapid);
L.tileLayer(mapobj.config.sourceurl, {
attribution: mapobj.config.attribution,
maxZoom: mapobj.config.maxzoom,
maxNativeZoom: mapobj.config.maxnativezoom
}).addTo(mapobj.map);
},
showPoint:function(point){
mapobj.map.setView([point.lat, point.lon], point.zoom);
},
addMarker:function(point){
L.marker([point.lat, point.lon]).addTo(mapobj.map);
},
addPopupMarker:function(favorite,onClickEvent){
window.point = favorite;
var point = {};
point.lat = favorite.latitude;
point.lon = favorite.longitude;
var popup = L.popup().setContent(
"name: <b>" + favorite.name + "</b><br/>" +
"address: <i>" + favorite.address + "</i><br/>"
+ "category: " + favorite.category);
L.marker([point.lat, point.lon])
.bindPopup(popup)
.addTo(mapobj.map)
.on('click', function(e) {
onClickEvent(e);
});
}
};
mapobj.init();
return {
showPoint: mapobj.showPoint,
addMarker: mapobj.addMarker,
addPopupMarker: mapobj.addPopupMarker
};
};
})(jQuery);
(function($) {
$.timer=function(config){
var timerobj={
config: $.extend({
'timeoutInMs':300,
'maxActionDelayInMs':2000,
'action':function(){},
'actionparams':null
}, config),
init:function(){
timerobj.timer = null;
timerobj.startDate = null;
},
start:function(){
timerobj.cancel();
timerobj.startDate = new Date();
timerobj.timer=setTimeout(timerobj.onTimer, timerobj.config.timeoutInMs);
},
cancel:function(){
if (timerobj.timer != null){
clearTimeout(timerobj.timer);
timerobj.timer = null;
timerobj.startDate = null;
}
},
onTimer:function(){
timerobj.timer= null;
let now = new Date();
if(now - timerobj.startDate < timerobj.config.maxActionDelayInMs){
timerobj.config.action(timerobj.config.actionparams);
}
}
};
timerobj.init();
return {
start:timerobj.start,
cancel:timerobj.cancel
};
};
})(jQuery);
var iosAppRedirect = {
config:{
appPrefix:'osmandmaps://',
containerid:'gocontainer',
cookieName:'OsmAndInstalled',
cookieNoExpirationTimeoutInDays:30
},
init:function(config){
if (config && typeof (config) == 'object') {
$.extend(iosAppRedirect.config, config);
}
if (!requestUtils.isIOS()){
return;
}
iosAppRedirect.$container = $('#' + iosAppRedirect.config.containerid);
iosAppRedirect.$overlay = iosAppRedirect.$container.find('.overlay');
iosAppRedirect.$popup = iosAppRedirect.$container.find('.popup');
iosAppRedirect.$yesBtn = iosAppRedirect.$container.find('.yes');
iosAppRedirect.$noBtn = iosAppRedirect.$container.find('.no');
iosAppRedirect.$cancelBtn = iosAppRedirect.$container.find('.cancel');
iosAppRedirect.applestorelink = iosAppRedirect.$container.find('.gobadges .apple a').attr('href');
iosAppRedirect.applink = iosAppRedirect.config.appPrefix + document.location.search;
if (iosAppRedirect.isAppInstalled() === "yes"){
iosAppRedirect.redirectToApp();
return;
}
if (iosAppRedirect.isAppInstalled() === "no"){
return;
}
iosAppRedirect.$yesBtn.on('click', function(){
iosAppRedirect.redirectToApp();
iosAppRedirect.closePopup();
});
iosAppRedirect.$noBtn.on('click', function(){
iosAppRedirect.setCookie(true);
iosAppRedirect.closePopup();
window.open(iosAppRedirect.applestorelink , '_blank');
});
iosAppRedirect.$cancelBtn.on('click', function(){
iosAppRedirect.setCookie(false);
iosAppRedirect.closePopup();
});
iosAppRedirect.openPopup();
},
isAppInstalled:function(){
return Cookies.get('OsmAndInstalled');
},
redirectToApp:function(){
iosAppRedirect.timer = $.timer({action:iosAppRedirect.clearCookie});
iosAppRedirect.timer.start();
requestUtils.redirect(iosAppRedirect.applink);
},
setCookie:function(appInstalled){
if (appInstalled === true){
Cookies.set(iosAppRedirect.config.cookieName, "yes");
}else{
Cookies.set(iosAppRedirect.config.cookieName, "no", { expires: iosAppRedirect.config.cookieNoExpirationTimeoutInDays });
}
},
clearCookie:function(){
Cookies.remove('OsmAndInstalled');
},
openPopup:function(){
iosAppRedirect.$overlay.show();
iosAppRedirect.$popup.show();
},
closePopup:function(){
iosAppRedirect.$overlay.hide();
iosAppRedirect.$popup.hide();
}
};
$( document ).ready(function() {
goMap.init();
iosAppRedirect.init();
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,38 +0,0 @@
(function($) {
$.fn.ellipsis = function()
{
return this.each(function()
{
var el = $(this);
if(el.css("overflow") == "hidden")
{
var text = el.html();
var multiline = el.hasClass('multiline');
var t = $(this.cloneNode(true))
.hide()
.css('position', 'absolute')
.css('overflow', 'visible')
.width(multiline ? el.width() : 'auto')
.height(multiline ? 'auto' : el.height())
;
el.after(t);
function height() { return t.height() > el.height(); };
function width() { return t.width() > el.width(); };
var func = multiline ? height : width;
while (text.length > 0 && func())
{
text = text.substr(0, text.length - 1);
t.html(text + "...");
}
el.html(t.html());
t.remove();
}
});
};
})(jQuery);

View file

@ -1,165 +0,0 @@
/*!
* JavaScript Cookie v2.1.4
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(function (factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
define(factory);
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init (converter) {
function api (key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}
if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}
stringifiedAttributes += '=' + attributes[attributeName];
}
return (document.cookie = key + '=' + value + stringifiedAttributes);
}
// Read
if (!key) {
result = {};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');
if (cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}
if (key === name) {
result = cookie;
break;
}
if (!key) {
result[name] = cookie;
}
} catch (e) {}
}
return result;
}
api.set = api;
api.get = function (key) {
return api.call(api, key);
};
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};
api.withConverter = init;
return api;
}
return init(function () {});
}));

View file

@ -1,29 +0,0 @@
function mapselector(container){
var $cnt = $(container);
var $selectbox = $cnt.find(".selectbox");
$cnt.find("label").on('click', function(){
refreshMap();
});
var refreshMap = function(){
var selectedStyle = getSelectedStyle().val();
var selectedMap = getSelectedMap().val();
if (selectedStyle && selectedMap){
var imageName = selectedMap + "-" + selectedStyle + ".png";
$cnt.css('background-image', "url('/images/" + imageName + "')");
}
}
var getSelectedStyle = function(){
return $selectbox.find("input[name='style']:checked");
}
var getSelectedMap = function(){
return $selectbox.find("input[name='show']:checked");
}
refreshMap();
}

View file

@ -1,35 +0,0 @@
function applyPolStyles(){
if ($('.pds-box').length > 0){
$('.pds-box').css('border', 'none');
$('.pds-vote-button').css('float', 'left');
$('.pds-vote-button').css('background', 'none');
$('.pds-vote-button').css('background-color', '#FF8F00');
$('.pds-vote-button').css('color', '#fff');
$('.pds-vote-button').css('border', 'none');
$('.pds-vote-button').css('border-radius', '5px');
$('.pds-box-outer').css('padding', '0');
$('.pds-view-results').on('click', function(){
subscribeToReturnToPoll();
});
}else{
setTimeout(applyPolStyles, timeout);
}
}
function subscribeToReturnToPoll(){
if ($('.pds-return-poll').length > 0){
$('.pds-return-poll').on('click', function(){applyStyleOnBackToPoll();});
applyPolStyles();
}else{
setTimeout(subscribeToReturnToPoll, timeout);
}
}
function applyStyleOnBackToPoll(){
if ($('.pds-view-results').length >0){
applyPolStyles();
}else{
setTimeout(applyStyleOnBackToPoll, timeout);
}
}

File diff suppressed because one or more lines are too long

View file

@ -1,129 +0,0 @@
var images_android=[
"promo-1s.png",
"promo-2s.png",
"promo-3s.png",
"promo-4s.png",
"promo-5s.png",
"promo-6s.png",
"promo-7s.png",
"promo-8s.png",
"promo-9s.png",
"promo-10s.png",
"promo-11s.png",
"promo-12s.png"
];
var images_ios=[
"ios-1s.png",
"ios-2s.png",
"ios-3s.png",
"ios-4s.png",
"ios-5s.png"
];
function slider(container){
var $cnt = $(container);
var $img1 = $cnt.find("#screenshot1");
var $img2 =$cnt.find("#screenshot2");
var $img3 = $cnt.find("#screenshot3");
var $img4 = $cnt.find("#screenshot4");
var $leftarrow = $cnt.find(".arrow.left");
var $rightarrow = $cnt.find(".arrow.right");
var $btnleft = $cnt.find(".button.left");
var $btnright = $cnt.find(".button.right");
var currentPosition =0;
var count =4;
var images = images_android;
var init = function(){
updatePictures();
updateArrows();
$leftarrow.on('click', function(){
if (currentPosition > 0){
currentPosition-=count;
updatePictures();
updateArrows();
}
});
$rightarrow.on('click', function(){
if (currentPosition + count < images.length){
currentPosition+=count;
updatePictures();
updateArrows();
}
});
$btnleft.on('click', function(){
if (!$btnleft.hasClass("active")){
$btnleft.addClass("active");
$btnright.removeClass("active");
$btnright.addClass
images = images_android;
currentPosition = 0;
updatePictures();
updateArrows();
}
});
$btnright.on('click', function(){
if (!$btnright.hasClass("active")){
$btnright.addClass("active");
$btnleft.removeClass("active");
images = images_ios;
currentPosition = 0;
updatePictures();
updateArrows();
}
});
}
var changePicture = function(img, index){
if (index < images.length){
img.attr("src", "images/" + images[index]);
}else{
img.attr("src", "images/empty.png");
}
}
var updatePictures = function(){
changePicture( $img1, currentPosition);
changePicture( $img2, currentPosition+1);
changePicture( $img3, currentPosition+2);
changePicture( $img4, currentPosition+3);
}
var updateArrows = function(){
if (currentPosition + count < images.length){
enableRightArrow();
}else{
disableRightArrow();
}
if (currentPosition== 0 ){
disableLeftArrow();
}else{
enableLeftArrow();
}
}
var enableLeftArrow = function(){
$leftarrow.attr("src", "images/left_arrow_orange.png");
while ($leftarrow.hasClass("disabled")){
$leftarrow.removeClass("disabled");
}
}
var disableLeftArrow = function(){
$leftarrow.attr("src", "images/left_arrow_grey.png");
$leftarrow.addClass("disabled");
}
var enableRightArrow = function(){
$rightarrow.attr("src", "images/right_arrow_orange.png");
while ($rightarrow.hasClass("disabled")){
$rightarrow.removeClass("disabled");
}
}
var disableRightArrow = function(){
$rightarrow.attr("src", "images/right_arrow_grey.png");
$rightarrow.addClass("disabled");
}
init();
}

View file

@ -542,7 +542,6 @@ dependencies {
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
implementation 'org.nanohttpd:nanohttpd:2.2.0'
// JS core
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
// size restrictions

View file

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:padding="10px">
<RelativeLayout
android:id="@+id/RelativeLayout03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20px"
android:layout_marginBottom="40px">
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:autoLink="web"
android:text="Click button to start server"></TextView>
</RelativeLayout>
<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/RelativeLayout03"
android:layout_alignParentLeft="true"
android:layout_marginBottom="40px"
android:text="Start"></Button>
<Button
android:id="@+id/Button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/Button01"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:text="Stop"></Button>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/Button03"
android:fitsSystemWindows="true"
android:lines="14"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="8dp" />
</RelativeLayout>

View file

@ -58,7 +58,6 @@
<string name="shared_string_gpx_files">Tracks</string>
<string name="add_segment_to_the_track">Add to a track file</string>
<string name="shared_string_save_as_gpx">Save as new track file</string>
<string name="web_server">Web server</string>
<string name="in_case_of_reverse_direction">In case of reverse direction</string>
<string name="plan_route_exit_dialog_descr">Are you sure you want to close Plan route without saving? You will lose all changes.</string>
<string name="street_level_imagery">Street-level imagery</string>

View file

@ -1009,20 +1009,6 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
*/
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.web_server, mapActivity)
.setId("SERVER_ID")
.setIcon(R.drawable.mm_shop_computer)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_help_open");
Intent intent = new Intent(mapActivity, ServerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
.setId(DRAWER_HELP_ID)
.setIcon(R.drawable.ic_action_help)

View file

@ -1,104 +0,0 @@
package net.osmand.plus.activities;
import android.net.TrafficStats;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.StrictMode;
import android.text.format.Formatter;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.server.OsmAndHttpServer;
import java.io.IOException;
public class ServerActivity extends AppCompatActivity {
private boolean initialized = false;
private OsmAndHttpServer server;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
enableStrictMode();
super.onCreate(savedInstanceState);
setContentView(R.layout.server_activity);
findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!initialized) {
updateTextView("Click second button to deactivate server");
initServer();
}
}
});
findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (initialized) {
updateTextView("Click first button to activate server");
deInitServer();
}
}
});
}
public static void enableStrictMode() {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.setVmPolicy(
new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.build());
}
private void updateTextView(String text) {
((TextView) findViewById(R.id.TextView02)).setText(text);
}
private void initServer() {
final int THREAD_ID = 10000;
TrafficStats.setThreadStatsTag(THREAD_ID);
OsmAndHttpServer.HOSTNAME = getDeviceAddress();
try {
server = new OsmAndHttpServer();
server.setAndroidApplication((OsmandApplication)this.getApplication());
initialized = true;
updateTextView("Server started at: http://" + getDeviceAddress() + ":" + OsmAndHttpServer.PORT);
} catch (IOException e) {
Toast.makeText(this,
e.getLocalizedMessage(),
Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
private String getDeviceAddress() {
WifiManager wm = (WifiManager) this.getApplicationContext().getSystemService(WIFI_SERVICE);
String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
return ip != null ? ip : "0.0.0.0";
}
private void deInitServer() {
server.closeAllConnections();
server.stop();
initialized = false;
}
@Override
protected void onDestroy() {
deInitServer();
super.onDestroy();
}
}

View file

@ -1,18 +0,0 @@
package net.osmand.plus.server;
import java.util.concurrent.Callable;
import fi.iki.elonen.NanoHTTPD;
public class ApiEndpoint{
public String uri = "";
public ApiCall apiCall;
public NanoHTTPD.Response run(NanoHTTPD.IHTTPSession session){
return apiCall.call(session);
}
public interface ApiCall{
NanoHTTPD.Response call(NanoHTTPD.IHTTPSession session);
}
}

View file

@ -1,186 +0,0 @@
package net.osmand.plus.server;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.google.gson.Gson;
import net.osmand.data.FavouritePoint;
import net.osmand.plus.OsmandApplication;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import fi.iki.elonen.NanoHTTPD;
import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse;
public class ApiRouter {
private OsmandApplication androidContext;
public OsmandApplication getAndroidContext() {
return androidContext;
}
private final String FOLDER_NAME = "server";
private Gson gson = new Gson();
private Map<String, ApiEndpoint> endpoints = new HashMap<>();
public ApiRouter(){
initFavorites();
}
private void initFavorites() {
ApiEndpoint favorites = new ApiEndpoint();
favorites.uri = "/favorites";
favorites.apiCall = new ApiEndpoint.ApiCall(){
@Override
public NanoHTTPD.Response call(NanoHTTPD.IHTTPSession session) {
return newFixedLengthResponse(getFavoritesJson());
}
};
endpoints.put(favorites.uri,favorites);
}
public void setAndroidContext(OsmandApplication androidContext) {
this.androidContext = androidContext;
}
public NanoHTTPD.Response route(NanoHTTPD.IHTTPSession session) {
Log.d("SERVER", "URI: " + session.getUri());
String uri = session.getUri();
if (uri.equals("/")) return getStatic("/go.html");
if (uri.contains("/scripts/") ||
uri.contains("/images/") ||
uri.contains("/css/") ||
uri.contains("/fonts/") ||
uri.contains("/favicon.ico")
) return getStatic(uri);
if (isApiUrl(uri)){
return routeApi(session);
}
else {
return routeContent(session);
}
}
private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) {
String uri = session.getUri();
ApiEndpoint endpoint = endpoints.get(uri);
if (endpoint != null){
return endpoint.apiCall.call(session);
}
return ErrorResponses.response404;
}
private boolean isApiUrl(String uri) {
for (String endpoint : endpoints.keySet()){
if (endpoint.equals(uri)) return true;
}
return false;
}
private NanoHTTPD.Response routeContent(NanoHTTPD.IHTTPSession session) {
String url = session.getUri();
//add index page
String responseText = getHtmlPage(url);
if (responseText != null) {
return newFixedLengthResponse(responseText);
} else {
return ErrorResponses.response404;
}
}
public NanoHTTPD.Response getStatic(String uri) {
InputStream is = null;
String mimeType = parseMimeType(uri);
if (androidContext != null) {
try {
is = androidContext.getAssets().open(FOLDER_NAME + uri);
if (is.available() == 0) {
return ErrorResponses.response404;
}
return newFixedLengthResponse(
NanoHTTPD.Response.Status.OK,
mimeType,
is,
is.available());
} catch (IOException e) {
return ErrorResponses.response404;
}
}
return ErrorResponses.response500;
}
private String parseMimeType(String url) {
String type = null;
if (url.endsWith(".js")) return "text/javascript";
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
if (extension != null) {
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
}
return type;
}
private String readHTMLFromFile(String filename) {
StringBuilder sb = new StringBuilder();
try {
InputStream is = androidContext.getAssets().open(FOLDER_NAME + filename);
BufferedReader br = new BufferedReader(new InputStreamReader(is,
Charset.forName("UTF-8")));
String str;
while ((str = br.readLine()) != null) {
sb.append(str);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
return sb.toString();
}
public String getHtmlPage(String name) {
String responseText = "";
if (androidContext != null) {
responseText = readHTMLFromFile(name);
}
if (responseText == null) {
return null;
}
return responseText;
}
private String getFavoritesJson() {
List<FavouritePoint> points = androidContext.getFavorites().getFavouritePoints();
StringBuilder text = new StringBuilder();
for (FavouritePoint p : points) {
String json = jsonFromFavorite(p);
text.append(json);
text.append(",");
}
return "[" + text.substring(0,text.length()-1) + "]";
}
private String jsonFromFavorite(FavouritePoint favouritePoint) {
return gson.toJson(favouritePoint);
}
static class ErrorResponses {
static NanoHTTPD.Response response404 =
newFixedLengthResponse(NanoHTTPD.Response.Status.NOT_FOUND,
NanoHTTPD.MIME_PLAINTEXT, "404 Not Found");
static NanoHTTPD.Response response500 =
newFixedLengthResponse(NanoHTTPD.Response.Status.INTERNAL_ERROR,
NanoHTTPD.MIME_PLAINTEXT, "500 Internal Server Error");
}
}

View file

@ -1,34 +0,0 @@
package net.osmand.plus.server;
import net.osmand.plus.OsmandApplication;
import java.io.IOException;
import fi.iki.elonen.NanoHTTPD;
public class OsmAndHttpServer extends NanoHTTPD {
public static int PORT = 24990;
public static String HOSTNAME = "0.0.0.0";
private ServerSessionHandler sessionHandler = new ServerSessionHandler();
private OsmandApplication androidApplication;
public OsmandApplication getAndroidApplication() {
return androidApplication;
}
public void setAndroidApplication(OsmandApplication androidApplication) {
this.androidApplication = androidApplication;
sessionHandler.setAndroidApplication(androidApplication);
}
public OsmAndHttpServer() throws IOException {
super(HOSTNAME,PORT);
start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
}
@Override
public Response serve(IHTTPSession session) {
return sessionHandler.handle(session);
}
}

View file

@ -1,24 +0,0 @@
package net.osmand.plus.server;
import net.osmand.plus.OsmandApplication;
import fi.iki.elonen.NanoHTTPD;
public class ServerSessionHandler {
private OsmandApplication androidApplication;
private ApiRouter router = new ApiRouter();
public OsmandApplication getAndroidApplication() {
return androidApplication;
}
public void setAndroidApplication(OsmandApplication androidApplication) {
this.androidApplication = androidApplication;
router.setAndroidContext(androidApplication);
}
public NanoHTTPD.Response handle(NanoHTTPD.IHTTPSession session) {
return router.route(session);
}
}