mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
removed fragment progress callback and fixed missing header
This commit is contained in:
30
briar-android/res/layout/activity_plain.xml
Normal file
30
briar-android/res/layout/activity_plain.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
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:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/BriarToolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/window_background"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -11,9 +11,11 @@
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/camera_overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:weightSum="2">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -64,4 +66,30 @@
|
||||
android:scaleType="fitCenter"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/container_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:visibility="invisible">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_progress_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/progress_bar"
|
||||
android:gravity="center"
|
||||
android:paddingTop="@dimen/margin_large"
|
||||
tools:text="progress bar title"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@@ -235,7 +235,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
super.signOut();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadingScreen(boolean isBlocking, int stringId) {
|
||||
if (isBlocking) {
|
||||
// Disable navigation drawer slide to open
|
||||
@@ -245,7 +244,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
progressViewGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLoadingScreen() {
|
||||
drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED);
|
||||
progressViewGroup.setVisibility(INVISIBLE);
|
||||
|
||||
@@ -13,9 +13,6 @@ import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
public class BlogActivity extends BriarActivity implements
|
||||
OnBlogPostClickListener, BaseFragmentListener {
|
||||
|
||||
@@ -72,16 +69,6 @@ public class BlogActivity extends BriarActivity implements
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadingScreen(boolean isBlocking, int stringId) {
|
||||
progressBar.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLoadingScreen() {
|
||||
progressBar.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentCreated(String tag) {
|
||||
}
|
||||
|
||||
@@ -64,16 +64,6 @@ public class ReblogActivity extends BriarActivity implements
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadingScreen(boolean isBlocking, int stringId) {
|
||||
// this is handled by the fragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLoadingScreen() {
|
||||
// this is handled by the fragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentCreated(String tag) {
|
||||
|
||||
|
||||
@@ -48,12 +48,6 @@ public abstract class BaseFragment extends Fragment {
|
||||
|
||||
public interface BaseFragmentListener extends DestroyableActivity {
|
||||
|
||||
@UiThread
|
||||
void showLoadingScreen(boolean isBlocking, int stringId);
|
||||
|
||||
@UiThread
|
||||
void hideLoadingScreen();
|
||||
|
||||
void runOnDbThread(Runnable runnable);
|
||||
|
||||
@UiThread
|
||||
|
||||
@@ -48,16 +48,6 @@ public class IntroductionActivity extends BriarActivity implements
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadingScreen(boolean isBlocking, int stringId) {
|
||||
// this is handled by the recycler view in ContactChooserFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLoadingScreen() {
|
||||
// this is handled by the recycler view in ContactChooserFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentCreated(String tag) {
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.briarproject.android.keyagreement;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
@@ -45,8 +43,6 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
|
||||
protected EventBus eventBus;
|
||||
|
||||
private Toolbar toolbar;
|
||||
private View progressContainer;
|
||||
private TextView progressTitle;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
@@ -63,11 +59,9 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.activity_with_loading);
|
||||
setContentView(R.layout.activity_plain);
|
||||
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
progressContainer = findViewById(R.id.container_progress);
|
||||
progressTitle = (TextView) findViewById(R.id.title_progress_bar);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@@ -120,17 +114,6 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadingScreen(boolean isBlocking, int stringId) {
|
||||
progressTitle.setText(stringId);
|
||||
progressContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLoadingScreen() {
|
||||
progressContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showNextScreen() {
|
||||
showStep(STEP_QR);
|
||||
@@ -148,7 +131,6 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showLoadingScreen(false, R.string.exchanging_contact_details);
|
||||
startContactExchange(result);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,14 +7,18 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Bitmap;
|
||||
import android.hardware.Camera;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -30,6 +34,7 @@ import org.briarproject.android.view.CameraView;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.KeyAgreementAbortedEvent;
|
||||
import org.briarproject.api.event.KeyAgreementFailedEvent;
|
||||
import org.briarproject.api.event.KeyAgreementFinishedEvent;
|
||||
import org.briarproject.api.event.KeyAgreementListeningEvent;
|
||||
import org.briarproject.api.event.KeyAgreementStartedEvent;
|
||||
import org.briarproject.api.event.KeyAgreementWaitingEvent;
|
||||
@@ -74,9 +79,13 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
||||
protected Executor ioExecutor;
|
||||
|
||||
private CameraView cameraView;
|
||||
private ViewGroup cameraOverlay;
|
||||
private View statusView;
|
||||
private TextView status;
|
||||
private ImageView qrCode;
|
||||
private ProgressBar mainProgressBar;
|
||||
private TextView mainProgressTitle;
|
||||
private ViewGroup mainProgressContainer;
|
||||
|
||||
private BluetoothStateReceiver receiver;
|
||||
private QrCodeDecoder decoder;
|
||||
@@ -117,9 +126,15 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
cameraView = (CameraView) view.findViewById(R.id.camera_view);
|
||||
cameraOverlay = (ViewGroup) view.findViewById(R.id.camera_overlay);
|
||||
statusView = view.findViewById(R.id.status_container);
|
||||
status = (TextView) view.findViewById(R.id.connect_status);
|
||||
qrCode = (ImageView) view.findViewById(R.id.qr_code);
|
||||
mainProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
|
||||
mainProgressTitle =
|
||||
(TextView) view.findViewById(R.id.title_progress_bar);
|
||||
mainProgressContainer =
|
||||
(ViewGroup) view.findViewById(R.id.container_progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,23 +277,54 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
||||
} else if (e instanceof KeyAgreementAbortedEvent) {
|
||||
KeyAgreementAbortedEvent event = (KeyAgreementAbortedEvent) e;
|
||||
keyAgreementAborted(event.didRemoteAbort());
|
||||
} else if (e instanceof KeyAgreementFinishedEvent) {
|
||||
listener.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mainProgressContainer.setVisibility(VISIBLE);
|
||||
mainProgressTitle.setText(R.string.exchanging_contact_details);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
private void generateBitmapQR(final Payload payload) {
|
||||
// Get narrowest screen dimension
|
||||
Context context = getContext();
|
||||
if (context == null) return;
|
||||
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
new AsyncTask<Void, Void, Bitmap>() {
|
||||
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... params) {
|
||||
String input =
|
||||
Base64.encodeToString(payloadEncoder.encode(payload),
|
||||
0);
|
||||
Bitmap bitmap =
|
||||
QrCodeUtils.createQrCode(dm, input);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
if (bitmap != null && !isDetached()) {
|
||||
qrCode.setImageBitmap(bitmap);
|
||||
// Simple fade-in animation
|
||||
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
|
||||
anim.setDuration(200);
|
||||
qrCode.startAnimation(anim);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void setQrCode(final Payload localPayload) {
|
||||
|
||||
listener.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String input = Base64.encodeToString(
|
||||
payloadEncoder.encode(localPayload), 0);
|
||||
Bitmap bitmap =
|
||||
QrCodeUtils.createQrCode((Context) listener, input);
|
||||
if (bitmap == null) return;
|
||||
qrCode.setImageBitmap(bitmap);
|
||||
// Simple fade-in animation
|
||||
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
|
||||
anim.setDuration(200);
|
||||
qrCode.startAnimation(anim);
|
||||
generateBitmapQR(localPayload);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -308,8 +354,8 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
||||
listener.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.showLoadingScreen(false,
|
||||
R.string.authenticating_with_device);
|
||||
mainProgressContainer.setVisibility(VISIBLE);
|
||||
mainProgressTitle.setText(R.string.authenticating_with_device);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -319,7 +365,8 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
||||
@Override
|
||||
public void run() {
|
||||
reset();
|
||||
listener.hideLoadingScreen();
|
||||
mainProgressContainer.setVisibility(INVISIBLE);
|
||||
mainProgressTitle.setText("");
|
||||
// TODO show abort somewhere persistent?
|
||||
Toast.makeText(getActivity(),
|
||||
remoteAborted ? R.string.connection_aborted_remote :
|
||||
|
||||
@@ -89,16 +89,6 @@ public abstract class ShareActivity extends BriarActivity implements
|
||||
return contacts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadingScreen(boolean isBlocking, int stringId) {
|
||||
// this is handled by the recycler view in ContactSelectorFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLoadingScreen() {
|
||||
// this is handled by the recycler view in ContactSelectorFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentCreated(String tag) {
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.android.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
@@ -24,9 +23,7 @@ public class QrCodeUtils {
|
||||
Logger.getLogger(QrCodeUtils.class.getName());
|
||||
|
||||
@Nullable
|
||||
public static Bitmap createQrCode(Context context, String input) {
|
||||
// Get narrowest screen dimension
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
public static Bitmap createQrCode(DisplayMetrics dm, String input) {
|
||||
int smallestDimen = Math.min(dm.widthPixels, dm.heightPixels);
|
||||
try {
|
||||
// Generate QR code
|
||||
|
||||
Reference in New Issue
Block a user