Skip to content

Commit

Permalink
ACRA cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Aug 12, 2024
1 parent 8e2c32f commit cc1b1e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 116 deletions.
50 changes: 8 additions & 42 deletions app/src/main/java/phone/vishnu/quotes/acra/ACRAErrorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.textfield.TextInputEditText;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Date;
import org.acra.ReportField;
import org.acra.data.CrashReportData;
import phone.vishnu.quotes.BuildConfig;
import phone.vishnu.quotes.R;
import phone.vishnu.quotes.activity.SplashActivity;
import phone.vishnu.quotes.helper.Constants;

public class ACRAErrorActivity extends AppCompatActivity {

private TextView stackTraceTV,
private TextView errorActivityTitleTV,
stackTraceTV,
packageNameTV,
versionNameTV,
versionCodeTV,
Expand All @@ -56,53 +54,17 @@ public class ACRAErrorActivity extends AppCompatActivity {
private Button telegramButton, githubButton;
private TextInputEditText userCommentTIE;

public static void openErrorActivity(
@NonNull Context context, @NonNull CrashReportData errorContent) {

Intent intent =
new Intent(context, ACRAErrorActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

intent.putExtra(
Constants.ACRA_STACK_TRACE,
checkNullity(errorContent.getString(ReportField.STACK_TRACE)));
intent.putExtra(
Constants.ACRA_ANDROID_VERSION,
checkNullity(errorContent.getString(ReportField.ANDROID_VERSION)));
intent.putExtra(
Constants.ACRA_APP_VERSION_CODE,
checkNullity(errorContent.getString(ReportField.APP_VERSION_CODE)));
intent.putExtra(
Constants.ACRA_APP_VERSION_NAME,
checkNullity(errorContent.getString(ReportField.APP_VERSION_NAME)));
intent.putExtra(
Constants.ACRA_PACKAGE_NAME,
checkNullity(errorContent.getString(ReportField.PACKAGE_NAME)));
intent.putExtra(
Constants.ACRA_USER_APP_START_DATE,
checkNullity(errorContent.getString(ReportField.USER_APP_START_DATE)));

context.startActivity(intent);
}

private static String checkNullity(String s) {
// TODO
return s == null ? "Property not found" : s;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (!checkIntent(getIntent())) moveToSplash();

setContentView(R.layout.activity_acra_error);
setTitle(
String.format(
"%s %s",
getString(R.string.quotes_status_creator), getString(R.string.crashed)));

if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true);

errorActivityTitleTV = findViewById(R.id.errorActivityTitleTV);
stackTraceTV = findViewById(R.id.errorActivityStackTraceTV);
packageNameTV = findViewById(R.id.errorActivityPackageNameTV);
versionNameTV = findViewById(R.id.errorActivityVersionNameTV);
Expand All @@ -129,6 +91,10 @@ protected void onCreate(Bundle savedInstanceState) {
e.printStackTrace();
}

errorActivityTitleTV.setText(
String.format(
"%s %s",
getString(R.string.quotes_status_creator), getString(R.string.crashed)));
packageNameTV.setText(
String.format(
"%s %s", getString(R.string.package_name), BuildConfig.APPLICATION_ID));
Expand Down
40 changes: 0 additions & 40 deletions app/src/main/java/phone/vishnu/quotes/acra/ACRAFactory.java

This file was deleted.

33 changes: 0 additions & 33 deletions app/src/main/java/phone/vishnu/quotes/acra/ACRASender.java

This file was deleted.

17 changes: 16 additions & 1 deletion app/src/main/res/layout/activity_acra_error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/errorActivityTitleTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:letterSpacing="0.1"
android:padding="8dp"
android:textColor="@color/accentTextColor"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="@id/favGuideLineOne"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/errorActivityPackageNameTV"
android:layout_width="match_parent"
Expand Down Expand Up @@ -145,4 +160,4 @@
android:textColor="@color/textColor" />

</LinearLayout>
</ScrollView>
</ScrollView>

0 comments on commit cc1b1e9

Please sign in to comment.