mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-23 11:33:42 -05:00
1.1.3 updated
This commit is contained in:
1 parent
01d42ee5e2
commit
2e89f154cf
42 files changed
+2912
-4352
No files matched your search
@@ -0,0 +1,202 @@
|
||||
package com.example.weathermaster;
|
||||
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class Terms_Conditions extends AppCompatActivity {
|
||||
|
||||
private WebView webview;
|
||||
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
|
||||
|
||||
// Webview stuff
|
||||
webview = findViewById(R.id.webView);
|
||||
WebSettings webSettings = webview.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setAllowFileAccessFromFileURLs(true);
|
||||
webSettings.setAllowUniversalAccessFromFileURLs(true);
|
||||
webSettings.setAllowContentAccess(true);
|
||||
webview.setVerticalScrollBarEnabled(true);
|
||||
webview.setHorizontalScrollBarEnabled(false);
|
||||
webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
|
||||
webview.setWebViewClient(new WebViewClientDemo());
|
||||
AndroidInterface androidInterface = new AndroidInterface(this);
|
||||
webview.addJavascriptInterface(androidInterface, "AndroidInterface");
|
||||
webview.setBackgroundColor(getResources().getColor(R.color.mainBG));
|
||||
|
||||
webview.loadUrl("file:///android_asset/pages/aboutPages/TermsConditions.html");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class AndroidInterface {
|
||||
private Terms_Conditions tActivity;
|
||||
|
||||
AndroidInterface(Terms_Conditions activity) {
|
||||
tActivity = activity;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void updateStatusBarColor(final String color) {
|
||||
tActivity.runOnUiThread(new Runnable() {
|
||||
@SuppressLint("ResourceType")
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void run() {
|
||||
int statusBarColor;
|
||||
int navigationBarColor;
|
||||
int systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
|
||||
|
||||
if(color.equals("Scrolled")){
|
||||
statusBarColor = 0xFF1e2024;
|
||||
navigationBarColor = 0xFF121317;
|
||||
systemUiVisibilityFlags = 0;
|
||||
|
||||
} else if (color.equals("ScrollFalse")) {
|
||||
statusBarColor = 0xFF121317;
|
||||
navigationBarColor = 0xFF121317;
|
||||
systemUiVisibilityFlags = 0;
|
||||
|
||||
} else if (color.equals("GoBack")){
|
||||
back();
|
||||
return;
|
||||
|
||||
} else if (color.equals("bluesetDef")) {
|
||||
|
||||
return;
|
||||
} else if (color.equals("keepiton")) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
return;
|
||||
} else if (color.equals("keepitoff")) {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
return;
|
||||
} else if (color.equals("itsOn")) {
|
||||
Toast.makeText(tActivity, "Your device will stay awake", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else if (color.equals("ItsOff")) {
|
||||
Toast.makeText(tActivity, "Your device will go to sleep at the default time", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
|
||||
|
||||
} else {
|
||||
Toast.makeText(tActivity, "not found", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int currentStatusBarColor = tActivity.getWindow().getStatusBarColor();
|
||||
int currentNavigationBarColor = tActivity.getWindow().getNavigationBarColor();
|
||||
|
||||
ObjectAnimator statusBarAnimator = ObjectAnimator.ofObject(
|
||||
tActivity.getWindow(),
|
||||
"statusBarColor",
|
||||
new ArgbEvaluator(),
|
||||
currentStatusBarColor,
|
||||
statusBarColor
|
||||
);
|
||||
|
||||
statusBarAnimator.setDuration(200);
|
||||
statusBarAnimator.start();
|
||||
|
||||
ObjectAnimator navBarAnimator = ObjectAnimator.ofObject(
|
||||
tActivity.getWindow(),
|
||||
"navigationBarColor",
|
||||
new ArgbEvaluator(),
|
||||
currentNavigationBarColor,
|
||||
navigationBarColor
|
||||
);
|
||||
|
||||
navBarAnimator.setDuration(200);
|
||||
navBarAnimator.start();
|
||||
|
||||
tActivity.getWindow().setNavigationBarColor(navigationBarColor);
|
||||
|
||||
View decorView = tActivity.getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(systemUiVisibilityFlags);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void back() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class WebViewClientDemo extends WebViewClient {
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
if (shouldOpenInBrowser(url)) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
view.getContext().startActivity(intent);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldOpenInBrowser(String url) {
|
||||
return url.startsWith("https://fonts.google.com/specimen/Outfit?query=outfit") ||
|
||||
url.startsWith("https://openweathermap.org/") ||
|
||||
url.startsWith("https://fonts.google.com/specimen/Poppins?query=poppins") ||
|
||||
url.startsWith("https://github.com/material-components/material-web") ||
|
||||
url.startsWith("https://app-privacy-policy-generator.nisrulz.com/") ||
|
||||
url.startsWith("https://github.com/PranshulGG/WeatherMaster") ||
|
||||
url.startsWith("mailto:pranshul.devmain@gmail.com")||
|
||||
url.startsWith("https://github.com/PranshulGG/WeatherMaster/releases");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user