This commit is contained in:
Page Asgardius 2022-12-26 08:13:13 -07:00
parent 8343a54595
commit b2de50b544
7 changed files with 50 additions and 49 deletions

View file

@ -22,6 +22,7 @@
tools:targetApi="31"> tools:targetApi="31">
<activity <activity
android:name=".CorsConfig" android:name=".CorsConfig"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
android:exported="false"> android:exported="false">
<meta-data <meta-data
android:name="android.app.lib_name" android:name="android.app.lib_name"

View file

@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -34,6 +35,7 @@ public class CorsConfig extends AppCompatActivity {
boolean style; boolean style;
boolean allorigins, pdfcompatible, found = false; boolean allorigins, pdfcompatible, found = false;
TextView origins; TextView origins;
Button allowall, allowpdf, deletecors;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -46,6 +48,9 @@ public class CorsConfig extends AppCompatActivity {
bucket = getIntent().getStringExtra("bucket"); bucket = getIntent().getStringExtra("bucket");
style = getIntent().getBooleanExtra("style", false); style = getIntent().getBooleanExtra("style", false);
location = getIntent().getStringExtra("region"); location = getIntent().getStringExtra("region");
allowall = (Button)findViewById(R.id.allow_all);
allowpdf = (Button)findViewById(R.id.allow_pdf);
deletecors = (Button)findViewById(R.id.delete_cors);
try { try {
pdfendpoint = new URI(getIntent().getStringExtra("pdfendpoint")); pdfendpoint = new URI(getIntent().getStringExtra("pdfendpoint"));
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
@ -80,7 +85,7 @@ public class CorsConfig extends AppCompatActivity {
System.out.println("AllowedMethod: "+rule.getAllowedMethods()); System.out.println("AllowedMethod: "+rule.getAllowedMethods());
if (rule.getAllowedOrigins().toString().equals("[*]")) { if (rule.getAllowedOrigins().toString().equals("[*]")) {
allorigins = true; allorigins = true;
} else if (rule.getAllowedOrigins().toString().equals("[https://"+pdfendpoint.getHost()+"]")) { } else if (rule.getAllowedOrigins().toString().contains("https://"+pdfendpoint.getHost())) {
pdfcompatible = true; pdfcompatible = true;
} }
} }
@ -93,12 +98,19 @@ public class CorsConfig extends AppCompatActivity {
public void run() { public void run() {
if (allorigins) { if (allorigins) {
origins.setText(getResources().getString(R.string.cors_all)); origins.setText(getResources().getString(R.string.cors_all));
deletecors.setVisibility(View.VISIBLE);
} else if (pdfcompatible) { } else if (pdfcompatible) {
origins.setText(getResources().getString(R.string.cors_pdf)); origins.setText(getResources().getString(R.string.cors_pdf));
deletecors.setVisibility(View.VISIBLE);
allowall.setVisibility(View.VISIBLE);
} else if (found) { } else if (found) {
origins.setText(getResources().getString(R.string.cors_npdf)); origins.setText(getResources().getString(R.string.cors_npdf));
deletecors.setVisibility(View.VISIBLE);
allowall.setVisibility(View.VISIBLE);
} else { } else {
origins.setText(getResources().getString(R.string.cors_none)); origins.setText(getResources().getString(R.string.cors_none));
allowall.setVisibility(View.VISIBLE);
allowpdf.setVisibility(View.VISIBLE);
} }
} }
}); });

View file

@ -22,6 +22,7 @@ public class Settings extends AppCompatActivity {
SQLiteDatabase db; SQLiteDatabase db;
String videocache, videotime, buffersize; String videocache, videotime, buffersize;
EditText vcachepick, vtimepick, bsizepick; EditText vcachepick, vtimepick, bsizepick;
Button saveprefs, about;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -84,7 +85,7 @@ public class Settings extends AppCompatActivity {
getprefs.start(); getprefs.start();
//This is to add new user account //This is to add new user account
Button saveprefs = (Button)findViewById(R.id.saveprefs); saveprefs = (Button)findViewById(R.id.saveprefs);
saveprefs.setOnClickListener(new View.OnClickListener(){ saveprefs.setOnClickListener(new View.OnClickListener(){
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -119,7 +120,7 @@ public class Settings extends AppCompatActivity {
}); });
//This is to view app credits //This is to view app credits
Button about = (Button)findViewById(R.id.settings_button); about = (Button)findViewById(R.id.settings_button);
about.setOnClickListener(new View.OnClickListener(){ about.setOnClickListener(new View.OnClickListener(){
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View file

@ -14,4 +14,31 @@
android:textAlignment="center" android:textAlignment="center"
android:textSize="25sp" /> android:textSize="25sp" />
<Button
android:id="@+id/allow_all"
android:layout_width="match_parent"
android:layout_height="70dp"
android:text="@string/allow_all"
android:textColor="?android:attr/colorBackground"
android:textSize="24sp"
android:visibility="gone" />
<Button
android:id="@+id/allow_pdf"
android:layout_width="match_parent"
android:layout_height="70dp"
android:text="@string/allow_pdf"
android:textColor="?android:attr/colorBackground"
android:textSize="24sp"
android:visibility="gone" />
<Button
android:id="@+id/delete_cors"
android:layout_width="match_parent"
android:layout_height="70dp"
android:text="@string/delete_cors"
android:textColor="?android:attr/colorBackground"
android:textSize="24sp"
android:visibility="gone" />
</LinearLayout> </LinearLayout>

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".Settings"
tools:showIn="@layout/activity_settings">
<LinearLayout
android:id="@+id/linearLayoutSubmit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/expiration_date"
android:textAlignment="center"
android:textSize="25sp" />
<Button
android:id="@+id/saveprefs"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/accountadd_button"
tools:ignore="MissingConstraints"
style="?android:attr/buttonStyle" />
<Button
android:id="@+id/settings_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/about_button"
tools:ignore="MissingConstraints"
style="?android:attr/buttonStyle" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -101,4 +101,7 @@
<string name="cors_pdf">Uso de endpoint PDF permitido</string> <string name="cors_pdf">Uso de endpoint PDF permitido</string>
<string name="cors_npdf">Uso de endpoint PDF no permitido</string> <string name="cors_npdf">Uso de endpoint PDF no permitido</string>
<string name="cors_none">Política CORS no encontrada</string> <string name="cors_none">Política CORS no encontrada</string>
<string name="allow_all">Permitir todo</string>
<string name="allow_pdf">Permitir pdf</string>
<string name="delete_cors">Eliminar CORS</string>
</resources> </resources>

View file

@ -104,4 +104,7 @@
<string name="cors_pdf">PDF Endpoint allowed</string> <string name="cors_pdf">PDF Endpoint allowed</string>
<string name="cors_npdf">PDF Endpoint not allowed</string> <string name="cors_npdf">PDF Endpoint not allowed</string>
<string name="cors_none">CORS policy not found</string> <string name="cors_none">CORS policy not found</string>
<string name="allow_all">Allow all</string>
<string name="allow_pdf">Allow pdf</string>
<string name="delete_cors">Delete CORS</string>
</resources> </resources>