Feat: Share logs via a simple button

This commit is contained in:
Mathias-Boulay 2022-12-21 22:33:59 +01:00
parent 4671d6b7a3
commit eb3300699e
4 changed files with 41 additions and 1 deletions

View File

@ -1,7 +1,9 @@
package net.kdt.pojavlaunch.fragments;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.DocumentsContract;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
@ -19,6 +21,8 @@ import net.kdt.pojavlaunch.extra.ExtraConstants;
import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.progresskeeper.ProgressKeeper;
import java.io.File;
public class MainMenuFragment extends Fragment {
public static final String TAG = "MainMenuFragment";
@ -31,6 +35,7 @@ public class MainMenuFragment extends Fragment {
Button mNewsButton = view.findViewById(R.id.news_button);
Button mCustomControlButton = view.findViewById(R.id.custom_control_button);
Button mInstallJarButton = view.findViewById(R.id.install_jar_button);
Button mShareLogsButton = view.findViewById(R.id.share_logs_button);
ImageButton mEditProfileButton = view.findViewById(R.id.edit_profile_button);
Button mPlayButton = view.findViewById(R.id.play_button);
@ -46,6 +51,19 @@ public class MainMenuFragment extends Fragment {
mPlayButton.setOnClickListener(v -> ExtraCore.setValue(ExtraConstants.LAUNCH_GAME, true));
mShareLogsButton.setOnClickListener((v) -> {
Uri contentUri = DocumentsContract.buildDocumentUri(getString(R.string.storageProviderAuthorities), Tools.DIR_GAME_HOME + "/latestlog.txt");
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("text/plain");
Intent sendIntent = Intent.createChooser(shareIntent, "latestlog.txt");
startActivity(sendIntent);
});
}
private void runInstallerWithConfirmation(boolean isCustomArgs) {
if (ProgressKeeper.getTaskCount() == 0)

View File

@ -44,6 +44,17 @@
app:layout_constraintTop_toBottomOf="@id/custom_control_button"
/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/share_logs_button"
android:layout_width="match_parent"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="@string/main_share_logs"
app:layout_constraintTop_toBottomOf="@id/install_jar_button"
/>
<com.kdt.mcgui.mcVersionSpinner
android:id="@+id/mc_version_spinner"

View File

@ -44,6 +44,17 @@
app:layout_constraintTop_toBottomOf="@id/custom_control_button"
/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/share_logs_button"
android:layout_width="match_parent"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="@string/main_share_logs"
app:layout_constraintTop_toBottomOf="@id/install_jar_button"
/>
<com.kdt.mcgui.mcVersionSpinner
android:id="@+id/mc_version_spinner"

View File

@ -208,7 +208,7 @@
<string name="customctrl_selectdefault">Select default Control json</string>
<string name="customctrl_export">Export control</string>
<string name="main_share_logs">Share log file</string>
<string name="main_install_jar_file">Install .jar</string>
<string name="main_options">Options</string>
<string name="main_play">Play</string>