diff --git a/app/build.gradle b/app/build.gradle old mode 100644 new mode 100755 index 4dc48b9..579d1c9 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,44 +1,54 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' -} +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' android { - compileSdk 31 - + compileSdkVersion 33 + buildToolsVersion '28.0.3' defaultConfig { applicationId "com.cromstudio.redlinuxclick" - minSdk 21 - targetSdk 31 - versionCode 4 - versionName "1.0.4" - + minSdkVersion 21 + targetSdkVersion 33 + versionCode 6 + versionName "1.0.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + defaultConfig { + vectorDrawables.useSupportLibrary = true + aaptOptions.cruncherEnabled = false + aaptOptions.useNewCruncher = false + compileOptions.encoding = 'ISO-8859-1' + multiDexEnabled true + + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } } dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + testImplementation 'junit:junit:4.12' + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { + exclude group: 'com.android.support', module: 'support-annotations' + }) - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'com.google.android.material:material:1.5.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.3' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - implementation 'com.google.android.gms:play-services-ads:20.6.0' -} \ No newline at end of file + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + //implementation 'com.google.android.gms:play-services-ads:18.1.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} +repositories { + mavenCentral() +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro old mode 100644 new mode 100755 index 481bb43..9d9e291 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,10 +1,14 @@ # Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# By default, the flags in this file are appended to flags specified +# in D:\AndroidStudio\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: @@ -18,4 +22,4 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile diff --git a/app/src/debug/ic_launcher-playstore.png b/app/src/debug/ic_launcher-playstore.png new file mode 100644 index 0000000..93d9ee9 Binary files /dev/null and b/app/src/debug/ic_launcher-playstore.png differ diff --git a/app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher.png b/app/src/debug/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..30e62ae Binary files /dev/null and b/app/src/debug/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..62720d0 Binary files /dev/null and b/app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..ea470d9 Binary files /dev/null and b/app/src/debug/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher.png b/app/src/debug/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..cac09cf Binary files /dev/null and b/app/src/debug/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..502cfc0 Binary files /dev/null and b/app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..691974c Binary files /dev/null and b/app/src/debug/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..c725109 Binary files /dev/null and b/app/src/debug/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..b6183a3 Binary files /dev/null and b/app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..fdd5ca0 Binary files /dev/null and b/app/src/debug/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b3c3e13 Binary files /dev/null and b/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..c1d5f4e Binary files /dev/null and b/app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..472cbba Binary files /dev/null and b/app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..c165cea Binary files /dev/null and b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4cb981e Binary files /dev/null and b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..0a8df81 Binary files /dev/null and b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/debug/res/values/ic_launcher_background.xml b/app/src/debug/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/app/src/debug/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml old mode 100644 new mode 100755 index 9c71347..c36b4cd --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,30 +1,19 @@ - - - - + - - + - - - - - - - + @@ -32,6 +21,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100755 index 0000000..0f2fb09 Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/cromstudio/redlinuxclick/MainActivity.kt b/app/src/main/java/com/cromstudio/redlinuxclick/MainActivity.kt old mode 100644 new mode 100755 index a28c8d5..1cdf17d --- a/app/src/main/java/com/cromstudio/redlinuxclick/MainActivity.kt +++ b/app/src/main/java/com/cromstudio/redlinuxclick/MainActivity.kt @@ -1,58 +1,495 @@ package com.cromstudio.redlinuxclick import android.annotation.SuppressLint -import androidx.appcompat.app.AppCompatActivity +import android.app.Activity +import android.content.Context +import android.content.Intent +import android.graphics.Bitmap +import android.net.ConnectivityManager +import android.net.NetworkInfo +import android.net.Uri +import android.os.Build import android.os.Bundle -import android.webkit.WebView -import android.webkit.WebViewClient; -import android.webkit.WebResourceRequest; -import android.webkit.WebSettings -import com.google.android.gms.ads.AdRequest -import com.google.android.gms.ads.AdView -import com.google.android.gms.ads.MobileAds - -class MainActivity : AppCompatActivity() { - @SuppressLint("SetJavaScriptEnabled") - lateinit var mAdView : AdView +import android.os.Environment +import android.os.Handler +import android.provider.MediaStore +import android.util.Log +import android.view.KeyEvent +import android.view.View +import android.webkit.* +import android.webkit.WebSettings.RenderPriority +import android.widget.Button +import android.widget.ProgressBar +import android.widget.RelativeLayout +import android.widget.Toast +import androidx.annotation.RequiresApi +import androidx.appcompat.app.AppCompatDelegate +import java.io.File +import java.io.IOException +import java.io.UnsupportedEncodingException +import java.security.InvalidAlgorithmParameterException +import java.security.InvalidKeyException +import java.security.NoSuchAlgorithmException +import java.security.SecureRandom +import java.security.spec.InvalidKeySpecException +import java.security.spec.InvalidParameterSpecException +import java.text.SimpleDateFormat +import java.util.* +import javax.crypto.* +import javax.crypto.spec.SecretKeySpec + +class MainActivity : Activity() { + private lateinit var mContext: Context + internal var mLoaded = false + + // url red linuxclick + internal var URL = "https://redlinuxclick.ml" + + //for attach files + private var mCameraPhotoPath: String? = null + private var mFilePathCallback: ValueCallback>? = null + internal var doubleBackToExitPressedOnce = false + + + //AdView adView; + private lateinit var btnTryAgain: Button + private lateinit var mWebView: WebView + private lateinit var prgs: ProgressBar + private var viewSplash: View? = null + private lateinit var layoutSplash: RelativeLayout + private lateinit var layoutWebview: RelativeLayout + private lateinit var layoutNoInternet: RelativeLayout + + @SuppressLint("SetJavaScriptEnabled") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - MobileAds.initialize(this) {} + AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) + + mContext = this + mWebView = findViewById(R.id.webview) as WebView + prgs = findViewById(R.id.progressBar) as ProgressBar + btnTryAgain = findViewById(R.id.btn_try_again) as Button + viewSplash = findViewById(R.id.view_splash) as View + layoutWebview = findViewById(R.id.layout_webview) as RelativeLayout + layoutNoInternet = findViewById(R.id.layout_no_internet) as RelativeLayout + /** Layout of Splash screen View */ + layoutSplash = findViewById(R.id.layout_splash) as RelativeLayout + + + //request for show website + requestForWebview() + + btnTryAgain.setOnClickListener { + mWebView.visibility = View.GONE + prgs.visibility = View.VISIBLE + layoutSplash.visibility = View.VISIBLE + layoutNoInternet.visibility = View.GONE + requestForWebview() + } + + /** If you want to show adMob */ + //showAdMob(); + + /*var secret: SecretKey? = null + val toEncrypt = URL + try { + secret = generateKey() + val toDecrypt = encryptMsg(toEncrypt, secret) + + Log.d(TAG, toDecrypt.toString()) + + Log.d(TAG, decryptMsg(toDecrypt, secret)) + } catch (e: Exception) { + Log.e(TAG, "" + e.message) + }*/ + + } + + + private fun requestForWebview() { - mAdView = findViewById(R.id.adView) - val adRequest = AdRequest.Builder().build() - mAdView.loadAd(adRequest) + if (!mLoaded) { + requestWebView() + Handler().postDelayed({ + prgs.visibility = View.VISIBLE + //viewSplash.getBackground().setAlpha(145); + mWebView.visibility = View.VISIBLE + }, 3000) - val myWebView = findViewById(R.id.myWebView) - myWebView.webViewClient = object : WebViewClient() { - override fun shouldOverrideUrlLoading( - view: WebView?, - request: WebResourceRequest?): Boolean { - return false + } else { + mWebView.visibility = View.VISIBLE + prgs.visibility = View.GONE + layoutSplash.visibility = View.GONE + layoutNoInternet.visibility = View.GONE + } + + } + + @SuppressLint("SetJavaScriptEnabled") + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + private fun requestWebView() { + /** Layout of webview screen View */ + if (internetCheck(mContext)) { + mWebView.visibility = View.VISIBLE + layoutNoInternet.visibility = View.GONE + mWebView.loadUrl(URL) + } else { + prgs.visibility = View.GONE + mWebView.visibility = View.GONE + layoutSplash.visibility = View.GONE + layoutNoInternet.visibility = View.VISIBLE + + return + } + mWebView.isFocusable = true + mWebView.isFocusableInTouchMode = true + mWebView.settings.javaScriptEnabled = true + mWebView.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY + mWebView.settings.setRenderPriority(RenderPriority.HIGH) + mWebView.settings.cacheMode = WebSettings.LOAD_DEFAULT + mWebView.settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW + + mWebView.settings.domStorageEnabled = true + mWebView.settings.setAppCacheEnabled(true) + mWebView.settings.databaseEnabled = true + //mWebView.getSettings().setDatabasePath( + // this.getFilesDir().getPath() + this.getPackageName() + "/databases/"); + + // this force use chromeWebClient + mWebView.settings.setSupportMultipleWindows(false) + mWebView.webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean { + + Log.d(TAG, "URL: " + url!!) + if (internetCheck(mContext)) { + // If you wnat to open url inside then use + view.loadUrl(url); + + // if you wanna open outside of app + /*if (url.contains(URL)) { + view.loadUrl(url) + return false + }else { + // Otherwise, give the default behavior (open in browser) + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(intent) + return true + }*/ + } else { + prgs.visibility = View.GONE + mWebView.visibility = View.GONE + layoutSplash.visibility = View.GONE + layoutNoInternet.visibility = View.VISIBLE + } + + return true + } + + /* @Override + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { + if(internetCheck(mContext)) { + mWebView.setVisibility(View.VISIBLE); + layoutNoInternet.setVisibility(View.GONE); + //view.loadUrl(url); + }else{ + prgs.setVisibility(View.GONE); + mWebView.setVisibility(View.GONE); + layoutSplash.setVisibility(View.GONE); + layoutNoInternet.setVisibility(View.VISIBLE); + } + return false; + }*/ + + override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { + super.onPageStarted(view, url, favicon) + if (prgs.visibility == View.GONE) { + prgs.visibility = View.VISIBLE + } + } + + override fun onLoadResource(view: WebView, url: String) { + super.onLoadResource(view, url) + } + + override fun onPageFinished(view: WebView, url: String) { + super.onPageFinished(view, url) + mLoaded = true + if (prgs.visibility == View.VISIBLE) + prgs.visibility = View.GONE + + // check if layoutSplash is still there, get it away! + Handler().postDelayed({ + layoutSplash.visibility = View.GONE + //viewSplash.getBackground().setAlpha(255); + }, 2000) } } - myWebView.settings.allowFileAccess = true - myWebView.settings.domStorageEnabled = true - myWebView.settings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK - myWebView.settings.loadsImagesAutomatically = true - myWebView.settings.javaScriptEnabled = true - myWebView.settings.javaScriptCanOpenWindowsAutomatically=true + //file attach request + mWebView.webChromeClient = object : WebChromeClient() { + override fun onShowFileChooser( + webView: WebView, filePathCallback: ValueCallback>, + fileChooserParams: WebChromeClient.FileChooserParams): Boolean { + if (mFilePathCallback != null) { + mFilePathCallback!!.onReceiveValue(null) + } + mFilePathCallback = filePathCallback - myWebView.loadUrl("https://redlinuxclick.ml") + var takePictureIntent: Intent? = Intent(MediaStore.ACTION_IMAGE_CAPTURE) + if (takePictureIntent!!.resolveActivity(this@MainActivity.packageManager) != null) { + // Create the File where the photo should go + var photoFile: File? = null + try { + photoFile = createImageFile() + takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath) + } catch (ex: IOException) { + // Error occurred while creating the File + Log.e(TAG, "Unable to create Image File", ex) + } + // Continue only if the File was successfully created + if (photoFile != null) { + mCameraPhotoPath = "file:" + photoFile.absolutePath + takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, + Uri.fromFile(photoFile)) + } else { + takePictureIntent = null + } + } + val contentSelectionIntent = Intent(Intent.ACTION_GET_CONTENT) + contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE) + contentSelectionIntent.type = "image/*" + val intentArray: Array + if (takePictureIntent != null) { + intentArray = arrayOf(takePictureIntent) + } else { + intentArray = arrayOfNulls(0) + } + val chooserIntent = Intent(Intent.ACTION_CHOOSER) + chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent) + chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser") + chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray) + startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE) + + return true + } + } } + @Throws(IOException::class) + private fun createImageFile(): File { + // Create an image file name + val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date()) + val imageFileName = "JPEG_" + timeStamp + "_" + val storageDir = Environment.getExternalStoragePublicDirectory( + Environment.DIRECTORY_PICTURES) + return File.createTempFile( + imageFileName, /* prefix */ + ".jpg", /* suffix */ + storageDir /* directory */ + ) } + /** + * Convenience method to set some generic defaults for a + * given WebView + */ + /*@TargetApi(Build.VERSION_CODES.HONEYCOMB) + private void setUpWebViewDefaults(WebView webView) { + WebSettings settings = webView.getSettings(); + + // Enable Javascript + settings.setJavaScriptEnabled(true); + + // Use WideViewport and Zoom out if there is no viewport defined + settings.setUseWideViewPort(true); + settings.setLoadWithOverviewMode(true); + + // Enable pinch to zoom without the zoom buttons + settings.setBuiltInZoomControls(true); + + if(Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { + // Hide the zoom controls for HONEYCOMB+ + settings.setDisplayZoomControls(false); + } + + // Enable remote debugging via chrome://inspect + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + WebView.setWebContentsDebuggingEnabled(true); + } + + // We set the WebViewClient to ensure links are consumed by the WebView rather + // than passed to a browser if it can + mWebView.setWebViewClient(new WebViewClient()); + }*/ + + public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) { + super.onActivityResult(requestCode, resultCode, data) + return + } + + var results: Array? = null + + // Check that the response is a good one + if (resultCode == Activity.RESULT_OK) { + if (data == null) { + // If there is not data, then we may have taken a photo + if (mCameraPhotoPath != null) { + results = arrayOf(Uri.parse(mCameraPhotoPath)) + } + } else { + val dataString = data.dataString + if (dataString != null) { + results = arrayOf(Uri.parse(dataString)) + } + } + } + + mFilePathCallback!!.onReceiveValue(results) + mFilePathCallback = null + return + } + + private fun showAdMob() { + /** Layout of AdMob screen View */ + /*layoutFooter = (LinearLayout) findViewById(R.id.layout_footer); + adView = (AdView) findViewById(R.id.adMob); + try { + if(internetCheck(mContext)){ + //initializeAdMob(); + }else{ + Log.d("---------","--no internet-"); + } + }catch (Exception ex){ + Log.d("-----------", ""+ex); + }*/ + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { + if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) { + mWebView.goBack() + return true + } + + if (doubleBackToExitPressedOnce) { + return super.onKeyDown(keyCode, event) + } + + this.doubleBackToExitPressedOnce = true + Toast.makeText(this, "Vuelve a presionar para salir", Toast.LENGTH_SHORT).show() + + Handler().postDelayed({ doubleBackToExitPressedOnce = false }, 2000) + return true + } + + companion object { + internal var TAG = "---MainActivity" + val INPUT_FILE_REQUEST_CODE = 1 + val EXTRA_FROM_NOTIFICATION = "EXTRA_FROM_NOTIFICATION" + + + //for security + @Throws(NoSuchAlgorithmException::class, InvalidKeySpecException::class) + fun generateKey(): SecretKey { + val random = SecureRandom() + val key = byteArrayOf(1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0) + //random.nextBytes(key); + return SecretKeySpec(key, "AES") + } + + /*@Throws(NoSuchAlgorithmException::class, NoSuchPaddingException::class, InvalidKeyException::class, InvalidParameterSpecException::class, IllegalBlockSizeException::class, BadPaddingException::class, UnsupportedEncodingException::class) + fun encryptMsg(message: String, secret: SecretKey): ByteArray { + var cipher: Cipher? = null + cipher = Cipher.getInstance("AES/ECB/PKCS5Padding") + cipher!!.init(Cipher.ENCRYPT_MODE, secret) + return cipher.doFinal(message.toByteArray(charset("UTF-8"))) + } + + @Throws(NoSuchPaddingException::class, NoSuchAlgorithmException::class, InvalidParameterSpecException::class, InvalidAlgorithmParameterException::class, InvalidKeyException::class, BadPaddingException::class, IllegalBlockSizeException::class, UnsupportedEncodingException::class) + fun decryptMsg(cipherText: ByteArray, secret: SecretKey): String { + var cipher: Cipher? = null + cipher = Cipher.getInstance("AES/ECB/PKCS5Padding") + cipher!!.init(Cipher.DECRYPT_MODE, secret) + return String(cipher.doFinal(cipherText), charset("UTF-8")) + }*/ + + + /**** Initial AdMob */ + /** + * private void initializeAdMob() { + * Log.d("----","Initial Call"); + * adView.setVisibility(View.GONE); + * AdRequest adRequest = new AdRequest.Builder() + * .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators + * //.addTestDevice("F901B815E265F8281206A2CC49D4E432") + * .build(); + * adView.setAdListener(new AdListener() { + * @Override + * public void onAdLoaded() { + * super.onAdLoaded(); + * runOnUiThread(new Runnable() { + * @Override + * public void run() { + * adView.setVisibility(View.VISIBLE); + * Log.d("----","Visible"); + * } + * }); + * } + * }); + * adView.loadAd(adRequest); + * } + */ + /** + * public static void showAlertDialog(Context mContext, String mTitle, String mBody, int mImage){ + * android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(mContext); + * builder.setCancelable(true); + * builder.setIcon(mImage); + * if(mTitle.length()>0) + * builder.setTitle(mTitle); + * if(mBody.length()>0) + * builder.setTitle(mBody); + * + * builder.setPositiveButton("OK",new DialogInterface.OnClickListener() { + * @Override + * public void onClick(DialogInterface dialog, int which) { + * dialog.dismiss(); + * } + * }); + * + * builder.create().show(); + * } */ + + fun internetCheck(context: Context): Boolean { + var available = false + val connectivity = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + + if (connectivity != null) { + val networkInfo = connectivity.allNetworkInfo + if (networkInfo != null) { + for (i in networkInfo.indices) { + if (networkInfo[i].state == NetworkInfo.State.CONNECTED) { + available = true + break + } + } + } + } + return available + } + } +} +private fun WebSettings.setAppCacheEnabled(b: Boolean) { +} diff --git a/app/src/main/res/drawable/bg_main.xml b/app/src/main/res/drawable/bg_main.xml new file mode 100755 index 0000000..8419d7b --- /dev/null +++ b/app/src/main/res/drawable/bg_main.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/cs_custom_progressbar.xml b/app/src/main/res/drawable/cs_custom_progressbar.xml new file mode 100755 index 0000000..e8fd68a --- /dev/null +++ b/app/src/main/res/drawable/cs_custom_progressbar.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_logo.png b/app/src/main/res/drawable/ic_logo.png new file mode 100644 index 0000000..d7fe7db Binary files /dev/null and b/app/src/main/res/drawable/ic_logo.png differ diff --git a/app/src/main/res/drawable/ic_love.xml b/app/src/main/res/drawable/ic_love.xml new file mode 100755 index 0000000..90e4cae --- /dev/null +++ b/app/src/main/res/drawable/ic_love.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_no_internet.xml b/app/src/main/res/drawable/ic_no_internet.xml new file mode 100755 index 0000000..e0f5c2f --- /dev/null +++ b/app/src/main/res/drawable/ic_no_internet.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_warning.xml b/app/src/main/res/drawable/ic_warning.xml new file mode 100755 index 0000000..edddf79 --- /dev/null +++ b/app/src/main/res/drawable/ic_warning.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml old mode 100644 new mode 100755 index 61c7aec..e1dbb5d --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,35 +1,142 @@ - - - + + + + + + + + + + + + + + + + + + +