ViewStub for ReminderView, lazy create AttachmentTypeSelector

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-01-18 18:46:40 -08:00
parent 3d6cbdd775
commit 508a666e76
5 changed files with 32 additions and 12 deletions

View File

@ -23,10 +23,12 @@
android:clipToPadding="false"
android:clipChildren="false">
<org.thoughtcrime.securesms.components.reminder.ReminderView
android:id="@+id/reminder"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ViewStub
android:id="@+id/reminder_stub"
android:layout="@layout/conversation_activity_reminderview_stub"
android:inflatedId="@+id/reminder"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout android:id="@+id/fragment_content"
android:layout_width="match_parent"

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.components.reminder.ReminderView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reminder"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

View File

@ -55,6 +55,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.view.ViewStub;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.ImageButton;
@ -143,6 +144,7 @@ import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
import org.thoughtcrime.securesms.util.views.Stub;
import org.whispersystems.libsignal.InvalidMessageException;
import org.whispersystems.libsignal.util.guava.Optional;
@ -205,7 +207,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private Button makeDefaultSmsButton;
private InputAwareLayout container;
private View composePanel;
protected ReminderView reminderView;
protected Stub<ReminderView> reminderView;
private AttachmentTypeSelector attachmentTypeSelector;
private AttachmentManager attachmentManager;
@ -782,6 +784,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private void handleAddAttachment() {
if (this.isMmsEnabled || isSecureText) {
if (attachmentTypeSelector == null) {
attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener());
}
attachmentTypeSelector.show(this, attachButton);
} else {
handleManualMmsRequired();
@ -947,12 +952,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override
public void onClick(View v) {
handleInviteLink();
reminderView.requestDismiss();
reminderView.get().requestDismiss();
}
});
reminderView.showReminder(reminder);
} else {
reminderView.hide();
reminderView.get().showReminder(reminder);
} else if (reminderView.resolved()) {
reminderView.get().hide();
}
}
@ -987,7 +992,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
composePanel = ViewUtil.findById(this, R.id.bottom_panel);
container = ViewUtil.findById(this, R.id.layout_container);
reminderView = ViewUtil.findById(this, R.id.reminder);
reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer);
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
@ -1005,7 +1010,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
composeBubble.getBackground().setColorFilter(defaultColor, PorterDuff.Mode.MULTIPLY);
colors.recycle();
attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener());
attachmentTypeSelector = null;
attachmentManager = new AttachmentManager(this, this);
audioRecorder = new AudioRecorder(this, masterSecret);

View File

@ -122,6 +122,8 @@ public class ConversationPopupActivity extends ConversationActivity {
@Override
protected void updateInviteReminder(boolean seenInvite) {
reminderView.setVisibility(View.GONE);
if (reminderView.resolved()) {
reminderView.get().setVisibility(View.GONE);
}
}
}

View File

@ -42,6 +42,7 @@ import android.widget.TextView;
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
import org.thoughtcrime.securesms.util.views.Stub;
public class ViewUtil {
@SuppressWarnings("deprecation")
@ -121,6 +122,10 @@ public class ViewUtil {
return (T) parent.findViewById(resId);
}
public static <T extends View> Stub<T> findStubById(@NonNull Activity parent, @IdRes int resId) {
return new Stub<T>((ViewStub)parent.findViewById(resId));
}
private static Animation getAlphaAnimation(float from, float to, int duration) {
final Animation anim = new AlphaAnimation(from, to);
anim.setInterpolator(new FastOutSlowInInterpolator());