Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option to share log file (#38) #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/pandroid/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@

<meta-data android:name="android.game_mode_config"
android:resource="@xml/game_mode_config" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.panda3ds.pandroid.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>

<activity
android:name=".app.MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
setItemClick("general", (item)-> PreferenceActivity.launch(requireContext(), GeneralPreferences.class));
setItemClick("advanced", (item)-> PreferenceActivity.launch(requireContext(), AdvancedPreferences.class));
}

private String getVersionName() {
try {
Context context = PandroidApplication.getAppContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,42 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Build;
import androidx.core.content.FileProvider;
import android.widget.Toast;
import android.content.Intent;
import android.net.Uri;

import androidx.annotation.Nullable;
import androidx.preference.SwitchPreferenceCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import com.panda3ds.pandroid.R;
import com.panda3ds.pandroid.app.PandroidApplication;
import com.panda3ds.pandroid.app.base.BasePreferenceFragment;
import com.panda3ds.pandroid.app.services.LoggerService;
import com.panda3ds.pandroid.data.config.GlobalConfig;
import java.io.File;

public class AdvancedPreferences extends BasePreferenceFragment {
@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
setPreferencesFromResource(R.xml.advanced_preferences, rootKey);
setActivityTitle(R.string.advanced_options);

setItemClick("shareLog", pref -> {
shareLogFile();
});
setItemClick("performanceMonitor", pref -> GlobalConfig.set(GlobalConfig.KEY_SHOW_PERFORMANCE_OVERLAY, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("shaderJit", pref -> GlobalConfig.set(GlobalConfig.KEY_SHADER_JIT, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("loggerService", pref -> {
boolean checked = ((SwitchPreferenceCompat) pref).isChecked();
Context ctx = PandroidApplication.getAppContext();
if (checked) {
findPreference("shareLog").setVisible(true);
ctx.startService(new Intent(ctx, LoggerService.class));
} else {
findPreference("shareLog").setVisible(false);
ctx.stopService(new Intent(ctx, LoggerService.class));
}
GlobalConfig.set(GlobalConfig.KEY_LOGGER_SERVICE, checked);
Expand All @@ -43,8 +55,31 @@ public void onResume() {
}

private void refresh() {
if (GlobalConfig.get(GlobalConfig.KEY_LOGGER_SERVICE)) {
findPreference("shareLog").setVisible(true);
} else {
findPreference("shareLog").setVisible(false);
}
((SwitchPreferenceCompat) findPreference("performanceMonitor")).setChecked(GlobalConfig.get(GlobalConfig.KEY_SHOW_PERFORMANCE_OVERLAY));
((SwitchPreferenceCompat) findPreference("loggerService")).setChecked(GlobalConfig.get(GlobalConfig.KEY_LOGGER_SERVICE));
((SwitchPreferenceCompat) findPreference("shaderJit")).setChecked(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT));
}

private void shareLogFile() {
String filePath = "/storage/emulated/0/Android/media/com.panda3ds.pandroid/logs/current.txt";
File file = new File(filePath);

// Check if the log file exists and then share
if (file.exists()) {
Uri uri = FileProvider.getUriForFile(requireContext(), "com.panda3ds.pandroid.fileprovider", file);

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(intent, "Share Log File"));
} else {
Toast.makeText(requireContext(), getString(R.string.no_log_file_found), Toast.LENGTH_SHORT).show();
}
}
}
11 changes: 11 additions & 0 deletions src/pandroid/app/src/main/res/drawable/ic_share.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?colorOnSurface">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
1 change: 0 additions & 1 deletion src/pandroid/app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,4 @@
<string name="region_taiwan">Taiwan</string>
<string name="behavior">Comportamento</string>
<string name="invalid_game">Jogo invalido</string>
<string name="tools">Ferramentas</string>
</resources>
80 changes: 42 additions & 38 deletions src/pandroid/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">pandroid</string>
<!-- Common -->
<string name="app_name">pandroid</string>
<string name="load_rom">Load ROM</string>
<string name="games">Games</string>
<string name="settings">Settings</string>
Expand All @@ -26,66 +26,54 @@
<string name="pref_screen_controllers_title">Screen gamepad layouts</string>
<string name="pref_default_controller_title">Default screen gamepad layout</string>
<string name="invalid_name">Invalid name</string>
<!-- Appearance Settings -->
<!-- General Settings -->
<string name="general">General</string>
<string name="theme">Theme</string>
<string name="pref_appearance_summary">Set application theme</string>
<string name="appearance">Appearance</string>
<string name="theme_device">Device</string>
<string name="light">Light</string>
<string name="dark">Dark</string>
<string name="black">Black</string>
<!-- Game Menu -->
<string name="actions">Actions</string>
<string name="exit">Exit</string>
<string name="resume">Resume</string>
<string name="hacks">Hacks</string>
<string name="lua_script">Lua script</string>
<string name="scripts">Scripts</string>
<string name="file_not_supported">File type isn\'t supported</string>
<string name="save_and_exit">Save and exit</string>
<string name="exit_without_saving">Exit without saving</string>
<string name="exit_without_saving_title_ff">Exit without saving \"%s\"?</string>
<string name="open_file">Open file</string>
<string name="create_new">Create new</string>
<string name="running_ff">Running \"%s\" ...</string>
<string name="rotate">Rotate</string>
<string name="pref_general_summary">General application configuration.</string>
<string name="dual_screen_layouts">Screen layouts</string>
<string name="dual_screen_layouts_summary">Change layout of console screens.</string>
<string name="click_to_change">Click to change</string>
<string name="pref_game_folders_summary">Folders for importing games</string>
<string name="pref_game_folders">Game folders</string>
<string name="import_folder">Import folder</string>
<string name="games_count_f">%d Games</string>
<string name="directory">Directory</string>
<string name="remove">Remove</string>
<string name="behavior">Behavior</string>
<string name="pref_picture_in_picture_title">Picture In Picture</string>
<string name="pref_picture_in_picture_summary">Minimize window when placed in the background.</string>
<!-- Screen layout editor -->
<string name="fix_aspect">Maintain aspect ratio</string>
<string name="bottom_display">Bottom Display</string>
<string name="top_display">Top Display</string>
<!-- Advanced Settings -->
<string name="advanced_options">Advanced options</string>
<string name="pref_advanced_summary">Logger, performance statistics, etc.</string>
<string name="display">Display</string>
<string name="pref_performance_monitor_title">Performance monitor</string>
<string name="pref_performance_monitor_summary">Show overlay with fps, memory, etc.</string>
<string name="pref_picture_in_picture_title">Picture In Picture</string>
<string name="pref_picture_in_picture_summary">Minimize window when placed in the background.</string>
<string name="graphics">Graphics</string>
<string name="pref_shader_jit_title">Shader JIT</string>
<string name="pref_shader_jit_summary">Use shader recompiler.</string>
<string name="tools">Tools</string>
<string name="debug">Debug</string>
<string name="pref_logger_service_title">Logger</string>
<string name="pref_logger_service_summary">Store application logs to file.</string>
<string name="pref_share_log_title">Share Log</string>
<string name="pref_share_log_summary">Share Pandroid\'s log to check issues.</string>
<string name="no_log_file_found">No log file found</string>
<string name="loading">Loading</string>
<string name="apply">Apply</string>
<string name="pref_theme_summary">Set application theme</string>
<string name="pref_theme_title">Application theme</string>
<string name="failed_load_rom">Failed to load ROM</string>
<string name="dialog_message_invalid_rom">Make sure it\'s a valid 3DS ROM and that storage permissions are configured properly.</string>
<string name="system">System</string>
<string name="general">General</string>
<string name="pref_general_summary">General application configuration.</string>
<string name="dual_screen_layouts">Screen layouts</string>
<string name="dual_screen_layouts_summary">Change layout of console screens.</string>
<string name="click_to_change">Click to change</string>
<string name="swap_screen">Swap screen</string>
<string name="pref_game_folders_summary">Folders for importing games</string>
<string name="pref_game_folders">Game folders</string>
<string name="import_folder">Import folder</string>
<string name="games_count_f">%d Games</string>
<string name="directory">Directory</string>
<string name="remove">Remove</string>
<string name="play">Play</string>
<!-- Screen layout editor -->
<string name="fix_aspect">Maintain aspect ratio</string>
<string name="bottom_display">Bottom Display</string>
<string name="top_display">Top Display</string>
<!-- Game about -->
<string name="region">Region</string>
<string name="region_north_armerican">North American</string>
Expand All @@ -94,6 +82,22 @@
<string name="region_australia">Australia</string>
<string name="region_korean">Korean</string>
<string name="region_taiwan">Taiwan</string>
<string name="behavior">Behavior</string>
<string name="invalid_game">Invalid game</string>
<string name="play">Play</string>
<!-- Game Menu -->
<string name="actions">Actions</string>
<string name="resume">Resume</string>
<string name="swap_screen">Swap screen</string>
<string name="exit">Exit</string>
<string name="hacks">Hacks</string>
<string name="lua_script">Lua script</string>
<string name="scripts">Scripts</string>
<string name="file_not_supported">File type isn\'t supported</string>
<string name="save_and_exit">Save and exit</string>
<string name="exit_without_saving">Exit without saving</string>
<string name="exit_without_saving_title_ff">Exit without saving \"%s\"?</string>
<string name="open_file">Open file</string>
<string name="create_new">Create new</string>
<string name="running_ff">Running \"%s\" ...</string>
<string name="rotate">Rotate</string>
</resources>
29 changes: 21 additions & 8 deletions src/pandroid/app/src/main/res/xml/advanced_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<PreferenceCategory
app:title="@string/tools"
app:title="@string/display"
app:iconSpaceReserved="false">

<SwitchPreferenceCompat
android:key="performanceMonitor"
app:title="@string/pref_performance_monitor_title"
app:summary="@string/pref_performance_monitor_summary"
app:iconSpaceReserved="false"/>

<SwitchPreferenceCompat
android:key="loggerService"
app:iconSpaceReserved="false"
app:title="@string/pref_logger_service_title"
android:summary="@string/pref_logger_service_summary"/>

</PreferenceCategory>

<PreferenceCategory
Expand All @@ -28,5 +24,22 @@
app:summary="@string/pref_shader_jit_summary"
app:iconSpaceReserved="false"/>

<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/debug">

<SwitchPreferenceCompat
android:key="loggerService"
app:iconSpaceReserved="false"
app:title="@string/pref_logger_service_title"
android:summary="@string/pref_logger_service_summary"/>

<Preference
android:key="shareLog"
app:iconSpaceReserved="false"
app:title="@string/pref_share_log_title"
android:summary="@string/pref_share_log_summary"/>

</PreferenceCategory>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>
4 changes: 4 additions & 0 deletions src/pandroid/app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
2 changes: 1 addition & 1 deletion src/pandroid/app/src/main/res/xml/start_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
app:summary="@string/pref_advanced_summary"
app:layout="@layout/preference_start_item"/>

</PreferenceScreen>
</PreferenceScreen>
4 changes: 2 additions & 2 deletions src/pandroid/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.2" apply false
}
}
Loading