overwrite web style, change min sdk to 16 and add German hints
This commit is contained in:
@@ -4,7 +4,7 @@ android {
|
|||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "de.weseng.wifiweatherstation"
|
applicationId "de.weseng.wifiweatherstation"
|
||||||
minSdkVersion 15
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 20190302
|
versionCode 20190302
|
||||||
versionName "2019.3.2"
|
versionName "2019.3.2"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="de.weseng.wifiweatherstation">
|
package="de.weseng.wifiweatherstation">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
@@ -14,7 +15,8 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/DarkTheme"
|
android:theme="@style/DarkTheme"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true"
|
||||||
|
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
3
app/src/main/assets/style.css
Normal file
3
app/src/main/assets/style.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
body {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package de.weseng.wifiweatherstation;
|
package de.weseng.wifiweatherstation;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -14,6 +15,7 @@ import android.net.wifi.WifiInfo;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Base64;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -22,6 +24,7 @@ import android.webkit.WebView;
|
|||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +33,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
WebView myWebView;
|
WebView myWebView;
|
||||||
public static String MESSAGE = "de.weseng.wifiweatherstation.MESSAGE";
|
public static String MESSAGE = "de.weseng.wifiweatherstation.MESSAGE";
|
||||||
|
|
||||||
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -71,8 +75,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
// Inject CSS when page is done loading
|
||||||
|
injectCSS();
|
||||||
|
|
||||||
pd.dismiss();
|
pd.dismiss();
|
||||||
String webUrl = myWebView.getUrl();
|
//String webUrl = myWebView.getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,6 +181,30 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
myWebView.restoreState(savedInstanceState);
|
myWebView.restoreState(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Inject CSS method: read style.css from assets folder
|
||||||
|
// Append stylesheet to document head
|
||||||
|
private void injectCSS() {
|
||||||
|
try {
|
||||||
|
InputStream inputStream = getAssets().open("style.css");
|
||||||
|
byte[] buffer = new byte[inputStream.available()];
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
inputStream.read(buffer); // read is necessary!
|
||||||
|
inputStream.close();
|
||||||
|
String encoded = Base64.encodeToString(buffer, Base64.NO_WRAP);
|
||||||
|
myWebView.loadUrl("javascript:(function() {" +
|
||||||
|
"var parent = document.getElementsByTagName('head').item(0);" +
|
||||||
|
"var style = document.createElement('style');" +
|
||||||
|
"style.type = 'text/css';" +
|
||||||
|
// Tell the browser to BASE64-decode the string into your script !!!
|
||||||
|
"style.innerHTML = window.atob('" + encoded + "');" +
|
||||||
|
"parent.appendChild(style)" +
|
||||||
|
"})()");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when the user taps the Send button */
|
/** Called when the user taps the Send button */
|
||||||
public void settings() {
|
public void settings() {
|
||||||
Intent intentSettings = new Intent(this, SettingsActivity.class);
|
Intent intentSettings = new Intent(this, SettingsActivity.class);
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
package de.weseng.wifiweatherstation;
|
package de.weseng.wifiweatherstation;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.NetworkInfo;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import static de.weseng.wifiweatherstation.MainActivity.PREFS_NAME;
|
|
||||||
|
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
public static final String PREFS_NAME = "Settings";
|
public static final String PREFS_NAME = "Settings";
|
||||||
@@ -99,7 +91,6 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
// platform.
|
// platform.
|
||||||
save_all();
|
save_all();
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -122,6 +113,6 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
editor.putString(key, value);
|
editor.putString(key, value);
|
||||||
|
|
||||||
// Commit the edits!
|
// Commit the edits!
|
||||||
editor.commit();
|
editor.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:text="TextView"
|
android:text=""
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
android:id="@+id/editTextSsidLocal"
|
android:id="@+id/editTextSsidLocal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="SSID"
|
android:hint="@string/hint_ssid"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
android:id="@+id/editTextUrlLocal"
|
android:id="@+id/editTextUrlLocal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="Local URL"
|
android:hint="@string/hint_url_local"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
@@ -66,10 +66,8 @@
|
|||||||
android:id="@+id/editTextUrlGlobal"
|
android:id="@+id/editTextUrlGlobal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="Global URL"
|
android:hint="@string/hint_url_global"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:id="@+id/settings"
|
<item android:id="@+id/settings"
|
||||||
android:title="@string/settings"/>
|
android:title="@string/settings"/>
|
||||||
//android:icon="@drawable/ic_new_game"
|
<!--android:icon="@drawable/ic_new_game"-->
|
||||||
//android:showAsAction="ifRoom"
|
<!--android:showAsAction="ifRoom"-->
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">WiFi-Wetter-Station</string>
|
<string name="app_name">WiFi-Wetter-Station</string>
|
||||||
<string name="settings">Einstellungen</string>
|
<string name="settings">Einstellungen</string>
|
||||||
<string name="loading">Bitte warten, die Ansicht wird geladen...</string>
|
<string name="loading">Bitte warten, die Ansicht wird geladen…</string>
|
||||||
|
<string name="hint_url_local">Lokale URL</string>
|
||||||
|
<string name="hint_url_global">Globale URL</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">WiFi Weather Station</string>
|
<string name="app_name">WiFi Weather Station</string>
|
||||||
<string name="settings">Settings</string>
|
<string name="settings">Settings</string>
|
||||||
<string name="loading">Please wait, the view is loading...</string>
|
<string name="loading">Please wait, the view is loading…</string>
|
||||||
<string name="ssid" translatable="false">NETGEAR26-5G-2</string>
|
<string name="ssid" translatable="false">NETGEAR26-5G-2</string>
|
||||||
<string name="url_local" translatable="false">http://192.168.1.5/site/wifi-weather-station/</string>
|
<string name="url_local" translatable="false">http://192.168.1.5/site/wifi-weather-station/</string>
|
||||||
<string name="url_global" translatable="false">http://inetsrv.no-ip.org/site/wifi-weather-station/</string>
|
<string name="url_global" translatable="false">http://inetsrv.no-ip.org/site/wifi-weather-station/</string>
|
||||||
|
<string name="hint_ssid" translatable="false">SSID</string>
|
||||||
|
<string name="hint_url_local">Local URL</string>
|
||||||
|
<string name="hint_url_global">Global URL</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user