Browse Source

add default, material padding, cleanup code

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 5 years ago
parent
commit
051821c419

+ 12 - 14
src/main/java/com/owncloud/android/ui/errorhandling/ErrorShowActivity.java

@@ -1,4 +1,4 @@
-/**
+/*
  *   ownCloud Android client application
  *   ownCloud Android client application
  *
  *
  *   @author LukeOwncloud
  *   @author LukeOwncloud
@@ -15,7 +15,6 @@
  *
  *
  *   You should have received a copy of the GNU General Public License
  *   You should have received a copy of the GNU General Public License
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
  */
  */
 package com.owncloud.android.ui.errorhandling;
 package com.owncloud.android.ui.errorhandling;
 
 
@@ -27,18 +26,17 @@ import android.widget.TextView;
 import com.owncloud.android.R;
 import com.owncloud.android.R;
 
 
 public class ErrorShowActivity extends Activity {
 public class ErrorShowActivity extends Activity {
+    private static final String TAG = ErrorShowActivity.class.getSimpleName();
+    public static final String EXTRA_ERROR_TEXT = "error";
 
 
-	private static final String TAG = ErrorShowActivity.class.getSimpleName();
-
-	TextView mError;
-
-	@Override
-	protected void onCreate(Bundle savedInstanceState) {
-		super.onCreate(savedInstanceState);
-		Log.e(TAG, "ErrorShowActivity was called. See above for StackTrace.");
-		setContentView(R.layout.errorhandling_showerror);
-		mError = (TextView) findViewById(R.id.errorTextView);
-		mError.setText(getIntent().getStringExtra("error"));
+    TextView error;
 
 
-	}
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Log.e(TAG, "ErrorShowActivity was called. See above for StackTrace.");
+        setContentView(R.layout.errorhandling_showerror);
+        error = findViewById(R.id.errorTextView);
+        error.setText(getIntent().getStringExtra(EXTRA_ERROR_TEXT));
+    }
 }
 }

+ 28 - 18
src/main/java/com/owncloud/android/ui/errorhandling/ExceptionHandler.java

@@ -24,27 +24,45 @@ import android.content.Intent;
 import android.os.Build;
 import android.os.Build;
 import android.util.Log;
 import android.util.Log;
 
 
+import org.jetbrains.annotations.NotNull;
+
 import java.io.PrintWriter;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.StringWriter;
 
 
 public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
 public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
-    private final Activity mContext;
-
     private static final String TAG = ExceptionHandler.class.getSimpleName();
     private static final String TAG = ExceptionHandler.class.getSimpleName();
+    private static final String LINE_SEPARATOR = "\n";
+
+    private final Activity context;
 
 
     public ExceptionHandler(Activity context) {
     public ExceptionHandler(Activity context) {
-        mContext = context;
+        this.context = context;
     }
     }
 
 
     public void uncaughtException(Thread thread, Throwable exception) {
     public void uncaughtException(Thread thread, Throwable exception) {
         Log.e(TAG, "ExceptionHandler caught UncaughtException", exception);
         Log.e(TAG, "ExceptionHandler caught UncaughtException", exception);
         StringWriter stackTrace = new StringWriter();
         StringWriter stackTrace = new StringWriter();
         exception.printStackTrace(new PrintWriter(stackTrace));
         exception.printStackTrace(new PrintWriter(stackTrace));
-        final String LINE_SEPARATOR = "\n";
 
 
-        String errorReport = "************ CAUSE OF ERROR ************\n\n" +
-            stackTrace.toString() +
-            "\n************ DEVICE INFORMATION ***********\nBrand: " +
+        String errorReport = generateErrorReport(stackTrace.toString());
+
+        Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception);
+
+        Intent intent = new Intent(context, ErrorShowActivity.class);
+        intent.putExtra(ErrorShowActivity.EXTRA_ERROR_TEXT, errorReport);
+        context.startActivity(intent);
+
+        android.os.Process.killProcess(android.os.Process.myPid());
+        System.exit(1000);
+    }
+
+    @NotNull
+    private String generateErrorReport(String stackTrace) {
+        return "************ CAUSE OF ERROR ************\n\n" +
+            stackTrace +
+            "\n************ DEVICE INFORMATION ***********" +
+            LINE_SEPARATOR +
+            "Brand: " +
             Build.BRAND +
             Build.BRAND +
             LINE_SEPARATOR +
             LINE_SEPARATOR +
             "Device: " +
             "Device: " +
@@ -59,7 +77,9 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
             "Product: " +
             "Product: " +
             Build.PRODUCT +
             Build.PRODUCT +
             LINE_SEPARATOR +
             LINE_SEPARATOR +
-            "\n************ FIRMWARE ************\nSDK: " +
+            "\n************ FIRMWARE ************" +
+            LINE_SEPARATOR +
+            "SDK: " +
             Build.VERSION.SDK_INT +
             Build.VERSION.SDK_INT +
             LINE_SEPARATOR +
             LINE_SEPARATOR +
             "Release: " +
             "Release: " +
@@ -68,15 +88,5 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
             "Incremental: " +
             "Incremental: " +
             Build.VERSION.INCREMENTAL +
             Build.VERSION.INCREMENTAL +
             LINE_SEPARATOR;
             LINE_SEPARATOR;
-
-        Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception);
-
-        Intent intent = new Intent(mContext, ErrorShowActivity.class);
-        intent.putExtra("error", errorReport);
-        mContext.startActivity(intent);
-
-        android.os.Process.killProcess(android.os.Process.myPid());
-        System.exit(1000);
     }
     }
-
 }
 }

+ 4 - 4
src/main/res/layout/errorhandling_showerror.xml

@@ -1,11 +1,11 @@
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
-    android:layout_height="match_parent" >
+    android:layout_height="match_parent">
 
 
     <TextView
     <TextView
         android:id="@+id/errorTextView"
         android:id="@+id/errorTextView"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
+        android:layout_height="wrap_content"
+        android:padding="@dimen/standard_padding" />
 
 
-</ScrollView>
+</ScrollView>