text viewer

This commit is contained in:
Page Asgardius 2022-09-07 11:05:26 -07:00
parent 4bdc78a229
commit 2347474a11
6 changed files with 69 additions and 2 deletions

View file

@ -10,6 +10,7 @@
<entry key="app/src/main/res/layout/activity_list_item.xml" value="0.19610507246376813" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_object_select.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_text_viewer.xml" value="0.19610507246376813" />
<entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_web_view.xml" value="0.17119565217391305" />
<entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" />

View file

@ -15,6 +15,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31">
<activity
android:name=".TextViewer"
android:exported="false" />
<activity
android:name=".WebBrowser"
android:exported="false" />

View file

@ -23,6 +23,7 @@ public class MainActivity extends AppCompatActivity {
static boolean DEFAULT_PATH_STYLE_ACCESS = true;
String alias, username, password, endpoint;
RecyclerView recyclerView;
SQLiteDatabase db;
ArrayList Name;
ArrayList Img;
@ -38,7 +39,7 @@ public class MainActivity extends AppCompatActivity {
recyclerView.setLayoutManager(linearLayoutManager);
MyDbHelper dbHelper = new MyDbHelper(this);
SQLiteDatabase db = dbHelper.getWritableDatabase();
db = dbHelper.getWritableDatabase();
if (db != null) {
// Database Queries
System.out.println("Database OK");
@ -50,6 +51,7 @@ public class MainActivity extends AppCompatActivity {
Name.add(cursor.getString(0));
Img.add(R.drawable.account);
}
db.close();
} else {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
}
@ -96,6 +98,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onClick(View view, int position) {
//System.out.println("Click on "+Name.get(position).toString());
db = dbHelper.getWritableDatabase();
if (db != null) {
// Database Queries
System.out.println("Database OK");
@ -107,6 +110,7 @@ public class MainActivity extends AppCompatActivity {
endpoint = cursor.getString(0);
username = cursor.getString(1);
password = cursor.getString(2);
db.close();
explorer();
}
} catch (Exception e) {

View file

@ -0,0 +1,39 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class TextViewer extends AppCompatActivity {
EditText filecontent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_viewer);
filecontent = (EditText)findViewById(R.id.textShow);
try {
// Create a URL for the desired page
URL url = new URL("yoursite.com/thefile.txt");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str = in.readLine();
in.close();
filecontent.setText(str);
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_conn_fail), Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_conn_fail), Toast.LENGTH_SHORT).show();
}
}
}

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".TextViewer">
<EditText
android:id="@+id/textShow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:ems="10"
android:gravity="start|top"
android:inputType="textMultiLine"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="79dp"
tools:layout_editor_absoluteY="25dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -24,7 +24,7 @@
<string name="explorer_test_button">File Explorer Test</string>
<string name="unsupported_file">Unsupported file type</string>
<string name="video_test_button">Video Test</string>
<string name="media_conn_fail">Cannot retrieve media file</string>
<string name="media_conn_fail">Cannot retrieve remote file</string>
<string name="media_wrong_type">Invalid media file</string>
<string name="media_list_fail">Cannot connect to server</string>
<string name="dummy_button">Dummy Button</string>