mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Migrate CrashReportActivity to XML layout
This commit is contained in:
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
9
briar-android/res/drawable/social_share.xml
Normal file
9
briar-android/res/drawable/social_share.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
|
||||||
|
</vector>
|
||||||
46
briar-android/res/layout/activity_crash.xml
Normal file
46
briar-android/res/layout/activity_crash.xml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/crash_status"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="@dimen/listitem_height_one_line_avatar"
|
||||||
|
android:paddingEnd="@dimen/margin_large"
|
||||||
|
android:paddingLeft="@dimen/margin_large"
|
||||||
|
android:paddingRight="@dimen/margin_large"
|
||||||
|
android:paddingStart="@dimen/margin_large"
|
||||||
|
android:paddingTop="@dimen/margin_large"/>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_wheel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="true"/>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/share_crash_report"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginBottom="@dimen/margin_large"
|
||||||
|
android:layout_marginEnd="@dimen/margin_large"
|
||||||
|
android:layout_marginRight="@dimen/margin_large"
|
||||||
|
android:background="@color/briar_accent"
|
||||||
|
android:src="@drawable/social_share"
|
||||||
|
android:tint="@color/action_bar_text"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
21
briar-android/res/layout/list_item_crash.xml
Normal file
21
briar-android/res/layout/list_item_crash.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/margin_small"
|
||||||
|
android:textSize="@dimen/text_size_large"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/margin_medium"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -3,9 +3,7 @@ package org.briarproject.android;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
@@ -18,16 +16,11 @@ import android.provider.Settings;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.util.AndroidUtils;
|
import org.briarproject.android.util.AndroidUtils;
|
||||||
import org.briarproject.android.util.HorizontalBorder;
|
|
||||||
import org.briarproject.android.util.LayoutUtils;
|
|
||||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
|
||||||
import org.briarproject.util.StringUtils;
|
import org.briarproject.util.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -52,16 +45,10 @@ import static android.content.Intent.EXTRA_TEXT;
|
|||||||
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
||||||
import static android.net.ConnectivityManager.TYPE_WIFI;
|
import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||||
import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED;
|
import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED;
|
||||||
import static android.view.Gravity.CENTER;
|
|
||||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static android.widget.LinearLayout.VERTICAL;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.android.TestingConstants.SHARE_CRASH_REPORTS;
|
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
|
||||||
|
|
||||||
public class CrashReportActivity extends AppCompatActivity
|
public class CrashReportActivity extends AppCompatActivity
|
||||||
implements OnClickListener {
|
implements OnClickListener {
|
||||||
@@ -69,9 +56,8 @@ public class CrashReportActivity extends AppCompatActivity
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(CrashReportActivity.class.getName());
|
Logger.getLogger(CrashReportActivity.class.getName());
|
||||||
|
|
||||||
private ScrollView scroll = null;
|
|
||||||
private ListLoadingProgressBar progress = null;
|
|
||||||
private LinearLayout status = null;
|
private LinearLayout status = null;
|
||||||
|
private View progress = null;
|
||||||
|
|
||||||
private volatile String stack = null;
|
private volatile String stack = null;
|
||||||
private volatile int pid = -1;
|
private volatile int pid = -1;
|
||||||
@@ -80,48 +66,17 @@ public class CrashReportActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
setContentView(R.layout.activity_crash);
|
||||||
|
|
||||||
|
status = (LinearLayout) findViewById(R.id.crash_status);
|
||||||
|
progress = findViewById(R.id.progress_wheel);
|
||||||
|
|
||||||
|
findViewById(R.id.share_crash_report).setOnClickListener(this);
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
stack = i.getStringExtra("briar.STACK_TRACE");
|
stack = i.getStringExtra("briar.STACK_TRACE");
|
||||||
pid = i.getIntExtra("briar.PID", -1);
|
pid = i.getIntExtra("briar.PID", -1);
|
||||||
bt = BluetoothAdapter.getDefaultAdapter();
|
bt = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
|
||||||
layout.setOrientation(VERTICAL);
|
|
||||||
layout.setGravity(CENTER_HORIZONTAL);
|
|
||||||
|
|
||||||
scroll = new ScrollView(this);
|
|
||||||
scroll.setLayoutParams(MATCH_WRAP_1);
|
|
||||||
status = new LinearLayout(this);
|
|
||||||
status.setOrientation(VERTICAL);
|
|
||||||
status.setGravity(CENTER_HORIZONTAL);
|
|
||||||
int pad = LayoutUtils.getPadding(this);
|
|
||||||
status.setPadding(pad, pad, pad, pad);
|
|
||||||
scroll.addView(status);
|
|
||||||
layout.addView(scroll);
|
|
||||||
|
|
||||||
progress = new ListLoadingProgressBar(this);
|
|
||||||
progress.setVisibility(GONE);
|
|
||||||
layout.addView(progress);
|
|
||||||
|
|
||||||
if (SHARE_CRASH_REPORTS) {
|
|
||||||
layout.addView(new HorizontalBorder(this));
|
|
||||||
LinearLayout footer = new LinearLayout(this);
|
|
||||||
footer.setLayoutParams(MATCH_WRAP);
|
|
||||||
footer.setGravity(CENTER);
|
|
||||||
Resources res = getResources();
|
|
||||||
int background = res.getColor(R.color.button_bar_background);
|
|
||||||
footer.setBackgroundColor(background);
|
|
||||||
ImageButton share = new ImageButton(this);
|
|
||||||
share.setBackgroundResource(0);
|
|
||||||
share.setImageResource(R.drawable.social_share);
|
|
||||||
share.setOnClickListener(this);
|
|
||||||
footer.addView(share);
|
|
||||||
layout.addView(footer);
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,9 +98,9 @@ public class CrashReportActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
status.removeAllViews();
|
status.setVisibility(INVISIBLE);
|
||||||
scroll.setVisibility(GONE);
|
|
||||||
progress.setVisibility(VISIBLE);
|
progress.setVisibility(VISIBLE);
|
||||||
|
status.removeAllViews();
|
||||||
new AsyncTask<Void, Void, Map<String, String>>() {
|
new AsyncTask<Void, Void, Map<String, String>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,19 +110,15 @@ public class CrashReportActivity extends AppCompatActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Map<String, String> result) {
|
protected void onPostExecute(Map<String, String> result) {
|
||||||
Context ctx = CrashReportActivity.this;
|
|
||||||
int pad = LayoutUtils.getPadding(ctx);
|
|
||||||
for (Entry<String, String> e : result.entrySet()) {
|
for (Entry<String, String> e : result.entrySet()) {
|
||||||
TextView title = new TextView(ctx);
|
View v = getLayoutInflater()
|
||||||
title.setTextSize(18);
|
.inflate(R.layout.list_item_crash, status, false);
|
||||||
title.setText(e.getKey());
|
((TextView) v.findViewById(R.id.title)).setText(e.getKey());
|
||||||
status.addView(title);
|
((TextView) v.findViewById(R.id.content))
|
||||||
TextView content = new TextView(ctx);
|
.setText(e.getValue());
|
||||||
content.setPadding(0, 0, 0, pad);
|
status.addView(v);
|
||||||
content.setText(e.getValue());
|
|
||||||
status.addView(content);
|
|
||||||
}
|
}
|
||||||
scroll.setVisibility(VISIBLE);
|
status.setVisibility(VISIBLE);
|
||||||
progress.setVisibility(GONE);
|
progress.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
|
|||||||
|
|
||||||
share = new ImageButton(this);
|
share = new ImageButton(this);
|
||||||
share.setBackgroundResource(0);
|
share.setBackgroundResource(0);
|
||||||
share.setImageResource(R.drawable.social_share);
|
share.setImageResource(R.drawable.social_share_old);
|
||||||
share.setOnClickListener(this);
|
share.setOnClickListener(this);
|
||||||
footer.addView(share);
|
footer.addView(share);
|
||||||
footer.addView(new ElasticHorizontalSpace(this));
|
footer.addView(new ElasticHorizontalSpace(this));
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
|||||||
|
|
||||||
shareButton = new ImageButton(this);
|
shareButton = new ImageButton(this);
|
||||||
shareButton.setBackgroundResource(0);
|
shareButton.setBackgroundResource(0);
|
||||||
shareButton.setImageResource(R.drawable.social_share);
|
shareButton.setImageResource(R.drawable.social_share_old);
|
||||||
shareButton.setOnClickListener(this);
|
shareButton.setOnClickListener(this);
|
||||||
footer.addView(shareButton);
|
footer.addView(shareButton);
|
||||||
footer.addView(new ElasticHorizontalSpace(this));
|
footer.addView(new ElasticHorizontalSpace(this));
|
||||||
|
|||||||
Reference in New Issue
Block a user