mirror of https://github.com/jlelse/teleposter
Little progress
This commit is contained in:
parent
5fa27db79c
commit
6dba70c4d8
|
@ -5,15 +5,17 @@ android {
|
||||||
buildToolsVersion "25.0.0"
|
buildToolsVersion "25.0.0"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "telegra.ph"
|
applicationId "telegra.ph"
|
||||||
minSdkVersion 9
|
minSdkVersion 13
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "0.1 beta"
|
versionName "0.2 beta"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
applicationIdSuffix '.debug'
|
||||||
|
versionNameSuffix ' debug'
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
|
@ -24,4 +26,5 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:appcompat-v7:25.0.1'
|
compile 'com.android.support:appcompat-v7:25.0.1'
|
||||||
|
compile 'com.afollestad.material-dialogs:core:0.9.1.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
<?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"
|
||||||
package="telegra.ph">
|
package="telegra.ph">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="false"
|
||||||
android:icon="@drawable/telegraph"
|
android:icon="@drawable/telegraph"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<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"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<data android:scheme="http"/>
|
||||||
|
<data android:scheme="https"/>
|
||||||
|
<data android:host="telegra.ph"/>
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -8,16 +8,15 @@ import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.*;
|
||||||
import android.webkit.WebResourceRequest;
|
|
||||||
import android.webkit.WebSettings;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private WebSettings webSettings;
|
private WebViewClient webViewClient;
|
||||||
|
private WebChromeClient webChromeClient;
|
||||||
|
|
||||||
|
private static final String TELEGRAPH = "http://telegra.ph/";
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,35 +24,50 @@ public class MainActivity extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
|
||||||
webView = (WebView) findViewById(R.id.webView);
|
webView = (WebView) findViewById(R.id.webView);
|
||||||
webSettings = webView.getSettings();
|
WebSettings webSettings = webView.getSettings();
|
||||||
|
|
||||||
// Enable Javascript
|
// Enable Javascript
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
// Allow File Access
|
||||||
|
webSettings.setAllowFileAccess(true);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
webSettings.setAllowFileAccessFromFileURLs(true);
|
||||||
|
}
|
||||||
|
// Add Database support
|
||||||
|
webSettings.setDatabaseEnabled(true);
|
||||||
|
webSettings.setDomStorageEnabled(true);
|
||||||
|
// Add Cache support
|
||||||
|
webSettings.setAppCacheEnabled(true);
|
||||||
|
|
||||||
// Set WebViewClient
|
// Set WebViewClient
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
webViewClient = new WebViewClient() {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
return handleUrl(url);
|
return urlAllowed(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||||
return handleUrl(request.getUrl().toString());
|
return urlAllowed(request.getUrl().toString());
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
webView.setWebViewClient(webViewClient);
|
||||||
|
|
||||||
// Set WebChromeClient
|
// Set WebChromeClient
|
||||||
webView.setWebChromeClient(new WebChromeClient() {
|
webChromeClient = new WebChromeClient() {
|
||||||
|
};
|
||||||
|
webView.setWebChromeClient(webChromeClient);
|
||||||
|
|
||||||
});
|
// Check if app is opened to show special page
|
||||||
|
String urlToLoad = TELEGRAPH;
|
||||||
|
if (getIntent() != null && getIntent().getAction().equals(Intent.ACTION_VIEW) && getIntent().getDataString() != null && getIntent().getDataString().contains("telegra.ph"))
|
||||||
|
urlToLoad = getIntent().getDataString();
|
||||||
|
|
||||||
// Load Telegra.ph
|
// Load URL
|
||||||
webView.loadUrl("http://telegra.ph");
|
webView.loadUrl(urlToLoad);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +94,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Own methods
|
// Extra methods
|
||||||
private boolean handleUrl(String url) {
|
private boolean urlAllowed(String url) {
|
||||||
return url.contains("telegra.ph");
|
return url.contains("telegra.ph");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue