Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Co-authored-by: frknkrc44 <[email protected]>
Signed-off-by: NaytSeyd <[email protected]>
Signed-off-by: frknkrc44 <[email protected]>
  • Loading branch information
naytseyd and frknkrc44 committed Aug 5, 2020
0 parents commit b291ea2
Show file tree
Hide file tree
Showing 13 changed files with 1,031 additions and 0 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.0"

defaultConfig {
applicationId "org.fk.tdu"
minSdkVersion 14
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fk.tdu" >

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ecem"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:resizeableActivity="true">
<activity
android:configChanges="mcc|mnc|keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

139 changes: 139 additions & 0 deletions app/src/main/java/org/fk/tdu/Helper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package org.fk.tdu;

import android.app.*;
import android.content.*;
import android.content.res.*;
import android.graphics.*;
import android.net.*;
import android.net.http.*;
import android.util.*;
import android.view.*;
import android.webkit.*;
import android.widget.*;
import java.lang.reflect.*;
import android.os.*;
import android.content.pm.*;

public class Helper {

private Helper(){}

public static WebView createWebView(final Context c){
final WebView v = new WebView(c);
v.setBackgroundColor(0);
WebSettings s = v.getSettings();
accessToMethod(s,boolean.class,"setJavaScriptEnabled",true);
accessToMethod(s,int.class,"setLightTouchEnabled",true);
s.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.32 Safari/537.36");
accessToMethod(s,boolean.class,"setBuiltInZoomControls",true);
accessToMethod(s,boolean.class,"setSupportZoom",true);
accessToMethod(s,boolean.class,"setDisplayZoomControls",false);
accessToMethod(s,boolean.class,"setAllowFileAccess",true);
accessToMethod(s,boolean.class,"setDomStorageEnabled",true);
accessToMethod(s,boolean.class,"setDatabaseEnabled",true);
accessToMethod(s,String.class,"setDatabasePath",c.getCacheDir().toString().replace("cache","databases"));
accessToMethod(s,long.class,"setAppCacheMaxSize",1024*1024*8);
accessToMethod(s,String.class,"setAppCachePath",c.getCacheDir());
accessToMethod(s,boolean.class,"setAppCacheEnabled",true);
accessToMethod(s,boolean.class,"setUseWideViewPort",true);
return v;
}

public static void addContentView(Activity a, View v){
((FrameLayout) a.findViewById(android.R.id.content)).addView(v);
}

private static RelativeLayout getSplash(Activity a){
FrameLayout main = (FrameLayout) a.findViewById(android.R.id.content);
return main.findViewById(android.R.id.custom);
}

public static void showSplash(Activity a, boolean show){
RelativeLayout splash = getSplash(a);
if(show){
if(splash == null){
splash = new RelativeLayout(a);
splash.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
splash.setBackgroundColor(0xFF212121);
int s = (int) mp(45);
ImageView iv = new ImageView(a);
RelativeLayout.LayoutParams rp = new RelativeLayout.LayoutParams(s,s);
rp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
iv.setLayoutParams(rp);
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
iv.setImageResource(R.drawable.splash);
splash.addView(iv);
s = (int) mp(35);
iv = new ImageView(a);
rp = new RelativeLayout.LayoutParams(s,s);
rp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
rp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
iv.setLayoutParams(rp);
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
iv.setImageResource(R.mipmap.devotag);
splash.addView(iv);
splash.setId(android.R.id.custom);
addContentView(a, splash);
} else {
splash.setVisibility(View.VISIBLE);
}
} else if(splash != null){
splash.setVisibility(View.GONE);
((ViewGroup)splash.getParent()).removeView(splash);
}
}

public static float mp(float px){
DisplayMetrics dm = Resources.getSystem().getDisplayMetrics();
return ((dm.widthPixels > dm.heightPixels ? dm.heightPixels : dm.widthPixels) / 100.0f) * px;
}

public static ProgressBar createProgressBar(final Context c){
ProgressBar pb = new ProgressBar(c,null,android.R.attr.progressBarStyleHorizontal);
pb.setLayoutParams(new FrameLayout.LayoutParams(-1,(int)dp(4)));
pb.setMax(100);
pb.setProgressDrawable(c.getResources().getDrawable(R.drawable.pbar));
return pb;
}

public static float dp(float px){
return Resources.getSystem().getDisplayMetrics().density * px;
}

public static void accessToMethod(Object o, Class arg, String name, Object... v){
try {
Method m = null;
if(arg != null) m = o.getClass().getMethod(name, arg);
else m = o.getClass().getMethod(name);
m.setAccessible(true);
if(arg != null) m.invoke(o,v);
else m.invoke(o);
} catch(Exception | Error e){
Log.e(Helper.class.getName(),e.getMessage());
}
}

public static class WebViewClientHelper extends WebViewClient {

Context ctx;

public WebViewClientHelper(Context c){
ctx = c;
}

@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){
handler.proceed(); // Ignore SSL certificate errors
}

@Override
public void onReceivedError(WebView view, WebResourceRequest request,WebResourceError error){
//Toast.makeText(ctx,error.getErrorCode() + " " + error.getDescription(),1).show();
}

@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//Toast.makeText(ctx, errorCode + " " + description, Toast.LENGTH_LONG).show();
}
}
}
113 changes: 113 additions & 0 deletions app/src/main/java/org/fk/tdu/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package org.fk.tdu;

import android.app.*;
import android.content.*;
import android.graphics.*;
import android.net.*;
import android.net.http.*;
import android.os.*;
import android.view.*;
import android.webkit.*;
import android.widget.*;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
w = Helper.createWebView(this);
w.setLayoutParams(new FrameLayout.LayoutParams(-1,-1));
setContentView(w);
final ProgressBar pb = Helper.createProgressBar(this);
Helper.showSplash(this,true);
Helper.addContentView(this,pb);
w.setWebViewClient(new Helper.WebViewClientHelper(MainActivity.this){
@Override
public void onPageStarted(WebView v, String u,Bitmap i){
pb.setVisibility(View.VISIBLE);
}

@Override
public void onPageFinished(WebView v,String u){
pb.setVisibility(View.INVISIBLE);
pb.setProgress(0);
Helper.showSplash(MainActivity.this,false);
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request){
return shouldOverrideUrlLoading(view, request.getUrl().toString());
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
if(!url.contains("github.io")){
view.stopLoading();
Intent in = new Intent(Intent.ACTION_VIEW);
in.setData(Uri.parse(url));
startActivity(in);
return true;
}
return false;
}
});
w.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView v,int p){
pb.setProgress(p);
}
});

if(getIntent().getDataString() == null || getIntent().getDataString().length() < 10){
w.loadUrl("https://teamderuntergang.github.io");
} else {
w.loadUrl(getIntent().getDataString());
}
}

private ValueCallback<Uri> mUploadMessage = null;
private ValueCallback<Uri[]> mFilePathCallback = null;
private Uri[] results = null;
private Uri result = null;
private String dataString = null;
private final static int FILECHOOSER_RESULTCODE = 1;
private WebView w = null;

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent){
if(requestCode == FILECHOOSER_RESULTCODE){
if(Build.VERSION.SDK_INT < 21){
if (null == mUploadMessage) return;
result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
mUploadMessage.onReceiveValue(result);
} else {
if(requestCode != FILECHOOSER_RESULTCODE || mFilePathCallback == null){
super.onActivityResult(requestCode, resultCode, intent);
return;
}
if(resultCode == Activity.RESULT_OK){
dataString = intent.getDataString();
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
}
mFilePathCallback.onReceiveValue(results);
}
}
mUploadMessage = null;
mFilePathCallback = null;
results = null;
}

long time = 0;

@Override
public void onBackPressed(){
if(w.canGoBack()) w.goBack();
else {
if((time + 3000) < System.currentTimeMillis()){
Toast.makeText(this,"Çıkmak için geri tuşuna tekrar dokunun",Toast.LENGTH_LONG).show();
time = System.currentTimeMillis();
} else super.onBackPressed();
}
}
}
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/pbar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#22444444" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#BF0046" />
</shape>
</clip>
</item>
</layer-list>

Binary file added app/src/main/res/drawable/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap/devotag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap/ecem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TeamDerUntergang</string>
</resources>
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.+'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'

0 comments on commit b291ea2

Please sign in to comment.