mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:33:39 +00:00
provisioning dialog rework
// FREEBIE
This commit is contained in:
parent
0c32001fe4
commit
2e253fb6a8
@ -95,6 +95,7 @@
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||
|
||||
<activity android:name=".DeviceProvisioningActivity"
|
||||
android:theme="@style/TextSecure.DialogActivity"
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
@ -5,7 +5,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||
classpath 'com.android.tools.build:gradle:1.0.1'
|
||||
classpath files('libs/gradle-witness.jar')
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@ repositories {
|
||||
maven {
|
||||
url "https://raw.github.com/whispersystems/maven/master/shortcutbadger/releases/"
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -40,6 +41,7 @@ dependencies {
|
||||
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
|
||||
compile 'com.github.chrisbanes.photoview:library:1.2.3'
|
||||
compile 'com.makeramen:roundedimageview:1.5.0'
|
||||
compile 'com.afollestad:material-dialogs:0.6.1.5'
|
||||
compile 'com.soundcloud.android:android-crop:0.9.10@aar'
|
||||
compile 'com.android.support:appcompat-v7:21.0.3'
|
||||
compile 'com.melnykov:floatingactionbutton:1.1.0'
|
||||
@ -73,6 +75,7 @@ dependencyVerification {
|
||||
'org.apache.httpcomponents:httpclient-android:6f56466a9bd0d42934b90bfbfe9977a8b654c058bf44a12bdc2877c4e1f033f1',
|
||||
'com.github.chrisbanes.photoview:library:8b5344e206f125e7ba9d684008f36c4992d03853c57e5814125f88496126e3cc',
|
||||
'com.makeramen:roundedimageview:7dda2e78c406760e5c356ccce59b0df46b5b171cf18abb891998594405021548',
|
||||
'com.afollestad:material-dialogs:ccb013e6572c86cfcca433855cf0dbfbff9b5e7bb9d1f504b761a6bc6f467b60',
|
||||
'com.soundcloud.android:android-crop:ffd4b973cf6e97f7d64118a0dc088df50e9066fd5634fe6911dd0c0c5d346177',
|
||||
'com.android.support:appcompat-v7:5dbeb5316d0a6027d646ae552804c3baa5e3bd53f7f33db50904d51505c8a0e5',
|
||||
'com.melnykov:floatingactionbutton:0679ad9f7d61eb7aeab91e8dc56358cdedd5b1c1b9c48464499ffa05c40d3985',
|
||||
|
BIN
res/drawable-hdpi/icon_dialog.png
Normal file
BIN
res/drawable-hdpi/icon_dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
res/drawable-mdpi/icon_dialog.png
Normal file
BIN
res/drawable-mdpi/icon_dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
res/drawable-xhdpi/icon_dialog.png
Normal file
BIN
res/drawable-xhdpi/icon_dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
res/drawable-xxhdpi/icon_dialog.png
Normal file
BIN
res/drawable-xxhdpi/icon_dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
@ -1,46 +0,0 @@
|
||||
<?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"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<LinearLayout android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<TextView android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:gravity="center"
|
||||
android:text="Add device?"
|
||||
android:id="@+id/textView"/>
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="left"
|
||||
android:text="The device you scanned will receive access to all incoming and outgoing messages."/>
|
||||
|
||||
<LinearLayout android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button android:id="@+id/cancel_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"/>
|
||||
|
||||
<Button android:id="@+id/continue_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Continue"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -239,6 +239,22 @@
|
||||
<string name="PassphraseChangeActivity_passphrases_dont_match_exclamation">Passphrases don\'t match!</string>
|
||||
<string name="PassphraseChangeActivity_incorrect_old_passphrase_exclamation">Incorrect old passphrase!</string>
|
||||
|
||||
<!-- DeviceProvisioningActivity -->
|
||||
<string name="DeviceProvisioning_cancel">CANCEL</string>
|
||||
<string name="DeviceProvisioning_continue">CONTINUE</string>
|
||||
<string name="DeviceProvisioning_title">Link this device?</string>
|
||||
<string name="DeviceProvisioning_content_intro">It will be able to</string>
|
||||
<string name="DeviceProvisioning_content_bullets">
|
||||
- Read all your messages
|
||||
\n- Send messages in your name
|
||||
</string>
|
||||
<string name="DeviceProvisioning_content_progress_title">Adding device...</string>
|
||||
<string name="DeviceProvisioning_content_progress_content">Adding new device...</string>
|
||||
<string name="DeviceProvisioning_content_progress_success">Device added!</string>
|
||||
<string name="DeviceProvisioning_content_progress_no_device">No device found.</string>
|
||||
<string name="DeviceProvisioning_content_progress_network_error">Network error.</string>
|
||||
<string name="DeviceProvisioning_content_progress_key_error">Invalid QR code.</string>
|
||||
|
||||
<!-- PassphrasePromptActivity -->
|
||||
<string name="PassphrasePromptActivity_enter_passphrase">Enter passphrase</string>
|
||||
<string name="PassphrasePromptActivity_watermark_content_description">TextSecure icon</string>
|
||||
|
@ -13,6 +13,15 @@
|
||||
<item name="android:windowAnimationStyle">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="TextSecure.DialogActivity" parent="Theme.AppCompat">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:backgroundDimEnabled">false</item>
|
||||
</style>
|
||||
|
||||
<!-- ActionBar styles -->
|
||||
<style name="TextSecure.DarkActionBar"
|
||||
parent="@style/Widget.AppCompat.ActionBar">
|
||||
|
@ -1,13 +1,21 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.view.Window;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.MaterialDialog.Builder;
|
||||
import com.afollestad.materialdialogs.MaterialDialog.ButtonCallback;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
|
||||
@ -22,21 +30,54 @@ import org.whispersystems.textsecure.api.push.exceptions.NotFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.thoughtcrime.securesms.util.SpanUtil.small;
|
||||
|
||||
public class DeviceProvisioningActivity extends PassphraseRequiredActionBarActivity {
|
||||
|
||||
private static final String TAG = DeviceProvisioningActivity.class.getSimpleName();
|
||||
|
||||
private Button continueButton;
|
||||
private Button cancelButton;
|
||||
private Uri uri;
|
||||
private MasterSecret masterSecret;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.device_provisioning_activity);
|
||||
|
||||
getSupportActionBar().hide();
|
||||
initializeResources();
|
||||
|
||||
SpannableStringBuilder content = new SpannableStringBuilder();
|
||||
content.append(getString(R.string.DeviceProvisioning_content_intro))
|
||||
.append("\n")
|
||||
.append(small(getString(R.string.DeviceProvisioning_content_bullets)));
|
||||
|
||||
new Builder(this).title("Link this device?")
|
||||
.iconRes(R.drawable.icon_dialog)
|
||||
.content(content)
|
||||
.positiveText(R.string.DeviceProvisioning_continue)
|
||||
.negativeText(R.string.DeviceProvisioning_cancel)
|
||||
.positiveColorRes(R.color.textsecure_primary)
|
||||
.negativeColorRes(R.color.gray50)
|
||||
.autoDismiss(false)
|
||||
.callback(new ButtonCallback() {
|
||||
@Override
|
||||
public void onPositive(MaterialDialog dialog) {
|
||||
handleProvisioning(dialog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegative(MaterialDialog dialog) {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.dismissListener(new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,27 +86,14 @@ public class DeviceProvisioningActivity extends PassphraseRequiredActionBarActiv
|
||||
}
|
||||
|
||||
private void initializeResources() {
|
||||
this.continueButton = (Button)findViewById(R.id.continue_button);
|
||||
this.cancelButton = (Button)findViewById(R.id.cancel_button);
|
||||
this.uri = getIntent().getData();
|
||||
|
||||
this.continueButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
handleProvisioning();
|
||||
}
|
||||
});
|
||||
|
||||
this.cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
this.uri = getIntent().getData();
|
||||
}
|
||||
|
||||
private void handleProvisioning() {
|
||||
new ProgressDialogAsyncTask<Void, Void, Integer>(this, "Adding device...", "Adding new device...") {
|
||||
private void handleProvisioning(final MaterialDialog dialog) {
|
||||
new ProgressDialogAsyncTask<Void, Void, Integer>(this,
|
||||
R.string.DeviceProvisioning_content_progress_title,
|
||||
R.string.DeviceProvisioning_content_progress_content)
|
||||
{
|
||||
private static final int SUCCESS = 0;
|
||||
private static final int NO_DEVICE = 1;
|
||||
private static final int NETWORK_ERROR = 2;
|
||||
@ -105,19 +133,19 @@ public class DeviceProvisioningActivity extends PassphraseRequiredActionBarActiv
|
||||
|
||||
switch (result) {
|
||||
case SUCCESS:
|
||||
Toast.makeText(context, "Device added!", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
Toast.makeText(context, R.string.DeviceProvisioning_content_progress_success, Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case NO_DEVICE:
|
||||
Toast.makeText(context, "No device found!", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, R.string.DeviceProvisioning_content_progress_no_device, Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case NETWORK_ERROR:
|
||||
Toast.makeText(context, "Network error!", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, R.string.DeviceProvisioning_content_progress_network_error, Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case KEY_ERROR:
|
||||
Toast.makeText(context, "Invalid QR code!", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, R.string.DeviceProvisioning_content_progress_key_error, Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
35
src/org/thoughtcrime/securesms/util/SpanUtil.java
Normal file
35
src/org/thoughtcrime/securesms/util/SpanUtil.java
Normal file
@ -0,0 +1,35 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
|
||||
public class SpanUtil {
|
||||
|
||||
public static CharSequence italic(CharSequence sequence) {
|
||||
SpannableString spannable = new SpannableString(sequence);
|
||||
spannable.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return spannable;
|
||||
}
|
||||
|
||||
public static CharSequence small(CharSequence sequence) {
|
||||
SpannableString spannable = new SpannableString(sequence);
|
||||
spannable.setSpan(new RelativeSizeSpan(0.9f), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return spannable;
|
||||
}
|
||||
|
||||
public static CharSequence bold(CharSequence sequence) {
|
||||
SpannableString spannable = new SpannableString(sequence);
|
||||
spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return spannable;
|
||||
}
|
||||
|
||||
public static CharSequence color(int color, CharSequence sequence) {
|
||||
SpannableString spannable = new SpannableString(sequence);
|
||||
spannable.setSpan(new ForegroundColorSpan(color), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return spannable;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user