[app] Add send in crash activity (#1100)

This commit is contained in:
tehcneko 2021-09-11 15:15:32 +08:00 committed by GitHub
parent 67529c839b
commit 37aaa8513b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 120 additions and 60 deletions

View File

@ -25,16 +25,16 @@ import android.content.ClipboardManager;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.snackbar.Snackbar;
import org.lsposed.manager.BuildConfig;
import org.lsposed.manager.R;
import org.lsposed.manager.databinding.ActivityCrashReportBinding;
import org.lsposed.manager.util.NavUtil;
import java.time.LocalDateTime;
@ -46,14 +46,22 @@ public class CrashReportActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
binding = ActivityCrashReportBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.copyLogs.setOnClickListener(v -> {
binding.sendLogs.setOnClickListener(view -> {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, getAllErrorDetailsFromIntent(getIntent()));
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, null));
});
binding.reportIssue.setOnClickListener(view -> {
var clipboard = getSystemService(ClipboardManager.class);
//Are there any devices without clipboard...?
if (clipboard != null) {
ClipData clip = ClipData.newPlainText("LSPManagerCrashInfo", getAllErrorDetailsFromIntent(getIntent()));
clipboard.setPrimaryClip(clip);
Snackbar.make(binding.snackbar, R.string.copy_toast_msg, Snackbar.LENGTH_SHORT).show();
Toast.makeText(this, R.string.crash_info_copied, Toast.LENGTH_LONG).show();
}
NavUtil.startURL(this, "https://github.com/LSPosed/LSPosed/issues");
});
}

View File

@ -20,7 +20,6 @@
package org.lsposed.manager.ui.activity.base;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
@ -31,7 +30,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import org.lsposed.manager.App;
import org.lsposed.manager.BuildConfig;
import org.lsposed.manager.ConfigManager;
import org.lsposed.manager.R;
@ -43,12 +41,6 @@ import rikka.material.app.MaterialActivity;
public class BaseActivity extends MaterialActivity {
protected static SharedPreferences preferences;
static {
preferences = App.getPreferences();
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@ -0,0 +1,30 @@
<!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ LSPosed is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2021 LSPosed Contributors
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M3.4,20.4l17.45,-7.48c0.81,-0.35 0.81,-1.49 0,-1.84L3.4,3.6c-0.66,-0.29 -1.39,0.2 -1.39,0.91L2,9.12c0,0.5 0.37,0.93 0.87,0.99L17,12 2.87,13.88c-0.5,0.07 -0.87,0.5 -0.87,1l0.01,4.61c0,0.71 0.73,1.2 1.39,0.91z" />
</vector>

View File

@ -18,67 +18,96 @@
~ Copyright (C) 2021 LSPosed Contributors
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout 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:id="@+id/snackbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
<LinearLayout
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="center"
android:orientation="vertical">
android:minHeight="148dp"
android:outlineAmbientShadowColor="@color/home_secondary_outline_ambient_shadow_color"
android:outlineSpotShadowColor="@color/home_secondary_outline_spot_shadow_color"
app:cardCornerRadius="8dp"
app:cardElevation="@dimen/home_secondary_elevation">
<com.google.android.material.card.MaterialCardView
android:id="@+id/warning_crash"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="horizontal"
app:cardBackgroundColor="@color/material_amber_500">
android:orientation="vertical">
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_marginEnd="8dp"
android:paddingTop="8dp"
android:orientation="vertical">
<TextView
style="?attr/textAppearanceHeadline5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/manager_crashed" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/manager_crashed_info" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginStart="8dp"
android:background="@android:color/transparent"
android:tint="@color/material_amber_500"
app:srcCompat="@drawable/ic_round_warning_24" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="UseCompoundDrawables">
android:padding="8dp"
android:orientation="vertical">
<ImageView
android:id="@+id/warning"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_centerHorizontal="true"
android:layout_margin="8dp"
app:srcCompat="@drawable/ic_round_warning_24"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="match_parent"
<com.google.android.material.button.MaterialButton
style="?attr/borderlessButtonStyle"
android:id="@+id/send_logs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/warning"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:text="@string/manager_crashed"
android:textAlignment="center"
android:textAllCaps="true"
android:textSize="36sp"
android:textStyle="bold" />
android:layout_marginEnd="8dp"
android:minWidth="0dp"
android:text="@string/send_crash_info"
app:icon="@drawable/ic_round_send_24" />
</RelativeLayout>
<com.google.android.material.button.MaterialButton
style="?attr/borderlessButtonStyle"
android:id="@+id/report_issue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:minWidth="0dp"
android:text="@string/report_issue"
app:icon="@drawable/ic_round_bug_report_24" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/copyLogs"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
android:text="@string/copy_crash_info"
android:theme="@style/Widget.AppCompat.Button.Colored" />
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>

View File

@ -190,6 +190,7 @@
<string name="outdated_core">LSPosed app is newer than framework. Please update LSPosed framework.</string>
<string name="outdated_manager">LSPosed framework is newer than app. Please update the app from /data/adb/lspd/manager.apk manually.</string>
<string name="manager_crashed">Manager crashed</string>
<string name="copy_crash_info">Copy crash info</string>
<string name="copy_toast_msg">Copied</string>
<string name="manager_crashed_info">report this to </string>
<string name="send_crash_info">Send crash info</string>
<string name="crash_info_copied">Crash info copied to clipboard</string>
</resources>