View crash reports in Settings -> About -> Crash Reports.

This commit is contained in:
Alex Ning 2020-07-08 12:32:49 +08:00
parent 406d82ef52
commit 318b11da01
9 changed files with 134 additions and 4 deletions

View File

@ -328,6 +328,16 @@
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="com.crazylegend.crashyreporter.initializer.CrashyInitializer"
android:value="androidx.startup" />
</provider>
<service <service
android:name=".Service.SubmitPostService" android:name=".Service.SubmitPostService"
android:enabled="true" android:enabled="true"

View File

@ -1,7 +1,5 @@
package ml.docilealligator.infinityforreddit.Message; package ml.docilealligator.infinityforreddit.Message;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.HashMap; import java.util.HashMap;
@ -41,7 +39,6 @@ public class ComposeMessage {
composeMessageListener.composeMessageFailed(errorMessage); composeMessageListener.composeMessageFailed(errorMessage);
} }
}); });
Log.i("asfsdaf", "s " + response.body());
} else { } else {
composeMessageListener.composeMessageFailed(response.message()); composeMessageListener.composeMessageFailed(response.message());
} }

View File

@ -0,0 +1,54 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.crazylegend.crashyreporter.CrashyReporter;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
public class CrashReportsFragment extends Fragment {
@BindView(R.id.recycler_view_crash_reports_fragment)
RecyclerView recyclerView;
private Activity activity;
private CrashReportsRecyclerViewAdapter adapter;
private LinearLayoutManager linearLayoutManager;
public CrashReportsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_crash_reports, container, false);
ButterKnife.bind(this, rootView);
adapter = new CrashReportsRecyclerViewAdapter(CrashyReporter.INSTANCE.getLogsAsStrings());
linearLayoutManager = new LinearLayoutManager(activity);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(adapter);
return rootView;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.activity = (Activity) context;
}
}

View File

@ -0,0 +1,46 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import ml.docilealligator.infinityforreddit.R;
class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<CrashReportsRecyclerViewAdapter.CrashReportViewHolder> {
private List<String> crashReports;
public CrashReportsRecyclerViewAdapter(List<String> crashReports) {
this.crashReports = crashReports;
}
@NonNull
@Override
public CrashReportViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new CrashReportViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_crash_report, parent, false));
}
@Override
public void onBindViewHolder(@NonNull CrashReportViewHolder holder, int position) {
holder.crashReportTextView.setText(crashReports.get(holder.getAdapterPosition()));
}
@Override
public int getItemCount() {
return crashReports == null ? 0 : crashReports.size();
}
class CrashReportViewHolder extends RecyclerView.ViewHolder {
TextView crashReportTextView;
public CrashReportViewHolder(@NonNull View itemView) {
super(itemView);
crashReportTextView = (TextView) itemView;
}
}
}

View File

@ -3,4 +3,4 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/recycler_view_acknowledgement_fragment" android:id="@+id/recycler_view_acknowledgement_fragment"
tools:context="ml.docilealligator.infinityforreddit.Settings.AcknowledgementFragment"/> tools:context="ml.docilealligator.infinityforreddit.Settings.AcknowledgementFragment" />

View File

@ -0,0 +1,6 @@
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_view_crash_reports_fragment"
tools:context="ml.docilealligator.infinityforreddit.Settings.CrashReportsFragment" />

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family" />

View File

@ -425,6 +425,8 @@
<string name="settings_share_title">Share</string> <string name="settings_share_title">Share</string>
<string name="settings_share_summary">Share this app to other people if you enjoy it</string> <string name="settings_share_summary">Share this app to other people if you enjoy it</string>
<string name="settings_version_title">Infinity For Reddit</string> <string name="settings_version_title">Infinity For Reddit</string>
<string name="settings_crash_reports_title">Crash Reports</string>
<string name="settings_crash_reports_summary">See the error logs and send them to me when you report bugs</string>
<string name="settings_version_summary">Version %s</string> <string name="settings_version_summary">Version %s</string>
<string name="settings_category_customization_title">Customization</string> <string name="settings_category_customization_title">Customization</string>
<string name="settings_customize_light_theme_title">Light Theme</string> <string name="settings_customize_light_theme_title">Light Theme</string>
@ -828,5 +830,7 @@
<string name="load_video_in_redgifs">Try loading the video on Redgifs</string> <string name="load_video_in_redgifs">Try loading the video on Redgifs</string>
<string name="top_score">%1$s pts</string> <string name="top_score">%1$s pts</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>

View File

@ -45,6 +45,11 @@
app:title="@string/settings_share_title" app:title="@string/settings_share_title"
app:summary="@string/settings_share_summary" /> app:summary="@string/settings_share_summary" />
<Preference
app:title="@string/settings_crash_reports_title"
app:summary="@string/settings_crash_reports_summary"
app:fragment="ml.docilealligator.infinityforreddit.Settings.CrashReportsFragment" />
<Preference <Preference
android:key="version" android:key="version"
app:title="@string/settings_version_title" app:title="@string/settings_version_title"