work on second step of identity creation

This commit is contained in:
Vincent Breitmoser
2015-03-13 16:30:49 +01:00
parent 9e3125c15e
commit 3f844cc70b
8 changed files with 190 additions and 231 deletions

View File

@@ -30,6 +30,7 @@ import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
import org.sufficientlysecure.keychain.pgp.linked.resources.DnsResource;
import org.sufficientlysecure.keychain.ui.util.Notify;
@@ -92,7 +93,7 @@ public class LinkedIdCreateDnsStep2Fragment extends LinkedIdCreateFinalFragment
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
proofSave();
proofToClipboard();
}
});
@@ -115,22 +116,9 @@ public class LinkedIdCreateDnsStep2Fragment extends LinkedIdCreateFinalFragment
startActivity(sendIntent);
}
private void proofSave () {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
Notify.showNotify(getActivity(), "External storage not available!", Style.ERROR);
return;
}
String targetName = "pgpkey.txt";
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
File targetFile = new File(Constants.Path.APP_DIR, targetName);
FileHelper.saveFile(this, getString(R.string.title_decrypt_to_file),
getString(R.string.specify_file_to_decrypt_to), targetFile, REQUEST_CODE_OUTPUT);
} else {
FileHelper.saveDocument(this, "text/plain", targetName, REQUEST_CODE_OUTPUT);
}
private void proofToClipboard() {
ClipboardReflection.copyToClipboard(getActivity(), mResourceString);
Notify.showNotify(getActivity(), R.string.linked_text_clipboard, Notify.Style.OK);
}
private void saveFile(Uri uri) {

View File

@@ -41,6 +41,7 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
// This is a resource, set AFTER it has been verified
LinkedCookieResource mVerifiedResource = null;
private ViewAnimator mVerifyButtonAnimator;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -69,9 +70,10 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
}
});
mVerifyImage = (ImageView) view.findViewById(R.id.verify_image);
mVerifyAnimator = (ViewAnimator) view.findViewById(R.id.verify_progress);
mVerifyImage = (ImageView) view.findViewById(R.id.verify_image);
mVerifyStatus = (TextView) view.findViewById(R.id.verify_status);
mVerifyButtonAnimator = (ViewAnimator) view.findViewById(R.id.verify_buttons);
view.findViewById(R.id.button_verify).setOnClickListener(new OnClickListener() {
@Override
@@ -80,6 +82,13 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
}
});
view.findViewById(R.id.button_retry).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
proofVerify();
}
});
setVerifyProgress(false, null);
mVerifyStatus.setText(R.string.linked_verify_pending);
@@ -91,20 +100,30 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
private void setVerifyProgress(boolean on, Boolean success) {
if (success == null) {
mVerifyStatus.setText(R.string.linked_verifying);
displayButton(on ? 2 : 0);
} else if (success) {
mVerifyStatus.setText(R.string.linked_verify_success);
mVerifyImage.setImageResource(R.drawable.status_signature_verified_cutout_24dp);
mVerifyImage.setColorFilter(getResources().getColor(R.color.android_green_dark),
PorterDuff.Mode.SRC_IN);
displayButton(2);
} else {
mVerifyStatus.setText(R.string.linked_verify_error);
mVerifyImage.setImageResource(R.drawable.status_signature_unknown_cutout_24dp);
mVerifyImage.setColorFilter(getResources().getColor(R.color.android_red_dark),
PorterDuff.Mode.SRC_IN);
displayButton(1);
}
mVerifyAnimator.setDisplayedChild(on ? 1 : 0);
}
public void displayButton(int button) {
if (mVerifyButtonAnimator.getDisplayedChild() == button) {
return;
}
mVerifyButtonAnimator.setDisplayedChild(button);
}
protected void proofVerify() {
setVerifyProgress(true, null);

View File

@@ -34,8 +34,6 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
public static final String ARG_HANDLE = "handle";
EditText mEditTweetPreview;
String mResourceHandle;
String mResourceString;
@@ -66,9 +64,6 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
mEditTweetPreview = (EditText) view.findViewById(R.id.linked_create_twitter_preview);
mEditTweetPreview.setText(mResourceString);
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

View File

@@ -10,7 +10,7 @@
android:layout_above="@+id/create_key_button_divider">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
@@ -29,7 +29,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal"
android:textIsSelectable="true" />
android:textIsSelectable="true"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="wrap_content"
@@ -39,24 +41,38 @@
android:text="@string/linked_create_dns_2_2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
style="?android:buttonBarStyle"
android:showDividers="middle">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
style="?android:buttonBarButtonStyle"
android:drawableLeft="@drawable/ic_content_copy_grey_24dp"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="Copy"
android:id="@+id/button_save"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
style="?android:buttonBarButtonStyle"
android:drawableLeft="@android:drawable/ic_menu_share"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="Share"
android:id="@+id/button_send"
android:layout_marginRight="8dip"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:id="@+id/button_save"
android:layout_marginLeft="8dip"/>
/>
</LinearLayout>
@@ -67,57 +83,7 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_2_3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<ViewAnimator
android:id="@+id/verify_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_gravity="center_vertical"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
>
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:id="@+id/verify_image"
android:src="@drawable/status_signature_unverified_cutout_24dp"
/>
<ProgressBar
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminateOnly="true"/>
</ViewAnimator>
<TextView
android:id="@+id/verify_status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_verify_pending"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Verify"
android:id="@+id/button_verify"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dip"
/>
</LinearLayout>
<include layout="@layout/linked_create_verify" />
<TextView
android:layout_width="wrap_content"
@@ -185,7 +151,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_link_identity"
android:text="@string/btn_finish"
android:minHeight="?android:attr/listPreferredItemHeight"
android:drawableRight="@drawable/ic_person_add_grey_24dp"
android:drawablePadding="8dp"

View File

@@ -43,24 +43,38 @@
android:text="@string/linked_create_https_2_2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Share"
android:id="@+id/button_send"
android:layout_marginRight="8dip"/>
android:layout_gravity="center_horizontal"
style="?android:buttonBarStyle"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
style="?android:buttonBarButtonStyle"
android:drawableLeft="@android:drawable/ic_menu_save"
android:drawableStart="@android:drawable/ic_menu_save"
android:text="Save"
android:id="@+id/button_save"
android:layout_marginLeft="8dip"/>
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
style="?android:buttonBarButtonStyle"
android:drawableLeft="@android:drawable/ic_menu_share"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="Share"
android:id="@+id/button_send"
/>
</LinearLayout>
@@ -71,57 +85,7 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_https_2_3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<ViewAnimator
android:id="@+id/verify_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_gravity="center_vertical"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
>
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:id="@+id/verify_image"
android:src="@drawable/status_signature_unverified_cutout_24dp"
/>
<ProgressBar
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminateOnly="true"/>
</ViewAnimator>
<TextView
android:id="@+id/verify_status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_verify_pending"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Verify"
android:id="@+id/button_verify"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dip"
/>
</LinearLayout>
<include layout="@layout/linked_create_verify" />
<TextView
android:layout_width="wrap_content"
@@ -189,7 +153,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_link_identity"
android:text="@string/btn_finish"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAllCaps="true"
android:drawableRight="@drawable/ic_person_add_grey_24dp"

View File

@@ -23,18 +23,6 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_twitter_2_1" />
<EditText
android:id="@+id/linked_create_twitter_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:layout_marginTop="8dp"
android:ems="10"
android:layout_gravity="center_horizontal"
android:inputType="textMultiLine"
android:enabled="false"
android:textSize="@dimen/abc_text_size_small_material"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -43,28 +31,37 @@
android:text="@string/linked_create_twitter_2_2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
style="?android:buttonBarStyle">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
style="?android:buttonBarButtonStyle"
android:drawableLeft="@android:drawable/ic_menu_send"
android:drawableStart="@android:drawable/ic_menu_send"
android:text="Tweet"
android:id="@+id/button_send"
android:layout_marginRight="8dip" />
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
style="?android:buttonBarButtonStyle"
android:drawableLeft="@android:drawable/ic_menu_share"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="Share"
android:id="@+id/button_share"
android:layout_marginLeft="8dip" />
/>
</LinearLayout>
@@ -75,57 +72,7 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_twitter_2_3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<ViewAnimator
android:id="@+id/verify_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_gravity="center_vertical"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
>
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:id="@+id/verify_image"
android:src="@drawable/status_signature_unverified_cutout_24dp"
/>
<ProgressBar
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminateOnly="true"/>
</ViewAnimator>
<TextView
android:id="@+id/verify_status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_verify_pending"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/linked_create_verify"
android:id="@+id/button_verify"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dip"
/>
</LinearLayout>
<include layout="@layout/linked_create_verify" />
<TextView
android:layout_width="wrap_content"
@@ -193,7 +140,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_link_identity"
android:text="@string/btn_finish"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAllCaps="true"
android:drawableRight="@drawable/ic_person_add_grey_24dp"

View File

@@ -0,0 +1,79 @@
<?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="wrap_content"
android:layout_marginTop="8dp"
tools:showIn="@layout/linked_create_https_fragment_step2">
<ViewAnimator
android:id="@+id/verify_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_gravity="center_vertical"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
>
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:id="@+id/verify_image"
android:src="@drawable/status_signature_unverified_cutout_24dp"
/>
<ProgressBar
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminateOnly="true" />
</ViewAnimator>
<TextView
android:id="@+id/verify_status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_verify_pending"
android:layout_marginLeft="16dip"
android:layout_marginStart="16dip"
android:layout_weight="1"
/>
<ViewAnimator
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dip"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out"
android:id="@+id/verify_buttons"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:buttonBarButtonStyle"
android:text="Verify"
android:id="@+id/button_verify"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:buttonBarButtonStyle"
android:text="Retry"
android:id="@+id/button_retry"
/>
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ViewAnimator>
</LinearLayout>

View File

@@ -1280,16 +1280,16 @@
<string name="linked_create_https_2_1">"A proof file for this URI has been created:"</string>
<string name="linked_create_https_2_2">"For the next step, you should save and upload this file."</string>
<string name="linked_create_https_2_3">"Make sure the file is reachable at the correct URI, then verify your setup."</string>
<string name="linked_create_https_2_4">"After verification is successful, hit next to add the linked identity to your keyring and finish the process."</string>
<string name="linked_create_https_2_4">"After successful verification, press the Finish button to add the Linked Identity to your keyring and finish the process."</string>
<string name="linked_create_twitter_1_1">"By creating a Linked Identity of this type, you can link your key to a Twitter account you control."</string>
<string name="linked_create_twitter_1_2">"To do this, you publish a specific Tweet on your timeline, then create a Linked Identity which links to this tweet."</string>
<string name="linked_create_twitter_1_3">"Please enter your Twitter screen name to proceed."</string>
<string name="linked_create_twitter_handle">Twitter Handle</string>
<string name="linked_create_twitter_2_1">"This is the text for your Tweet:"</string>
<string name="linked_create_twitter_2_2">"You may add more text to the Tweet, so long as the text inside the brackets is unmodified. Tweet this message using either method."</string>
<string name="linked_create_twitter_2_3">"Once your Tweet is published, click the button below to scan your timeline for it."</string>
<string name="linked_create_twitter_2_4">"Next"</string>
<string name="linked_create_twitter_2_1">"Click either button to tweet the message!"</string>
<string name="linked_create_twitter_2_2">"You can edit the Tweet before posting it, so long as the text inside the brackets is unmodified."</string>
<string name="linked_create_twitter_2_3">"Once your Tweet is published, click the Verify button to scan your timeline for it."</string>
<string name="linked_create_twitter_2_4">"After successful verification, press the Finish button to add the Linked Identity to your keyring and finish the process."</string>
<string name="linked_create_dns_1_1">"By creating a Linked Identity of this type, you can link your key to a domain name you control."</string>
<string name="linked_create_dns_1_2">"To do this, you create a specific TXT record for the domain, then create a Linked Identity which links to this record."</string>
@@ -1299,20 +1299,21 @@
<string name="linked_create_dns_2_1">"Your proof text:"</string>
<string name="linked_create_dns_2_2">"For the next step, bla bla"</string>
<string name="linked_create_dns_2_3">"More bla:"</string>
<string name="linked_create_dns_2_4">"bla bla"</string>
<string name="linked_create_dns_2_4">"After successful verification, press the Finish button to add the Linked Identity to your keyring and finish the process."</string>
<string name="linked_select_1">"A \'linked identity\' connects your pgp key to a resource on the web."</string>
<string name="linked_select_2">Please select a type:</string>
<string name="linked_select_2">"Please select a type:"</string>
<string name="linked_id_generic_text">"This file claims ownership of the OpenPGP key with long id %2$s.\n\nCookie for proof:\n%1$s"</string>
<string name="linked_verifying">Verifying…</string>
<string name="linked_verify_success">Verified!</string>
<string name="linked_verify_error">Verification error!</string>
<string name="linked_verify_pending">Not yet verified</string>
<string name="linked_verifying">"Verifying…"</string>
<string name="linked_verify_success">"Verified!"</string>
<string name="linked_verify_error">"Verification error!"</string>
<string name="linked_verify_pending">"Not yet verified"</string>
<string name="linked_need_verify">The resource needs to be verified before you can proceed!</string>
<string name="menu_linked_add_identity">"Add Linked Identity"</string>
<string name="section_linked_identities">Linked Identities</string>
<string name="btn_link_identity">Link Identity</string>
<string name="linked_create_verify">Verify</string>
<string name="section_linked_identities">"Linked Identities"</string>
<string name="btn_finish">"Finish"</string>
<string name="linked_create_verify">"Verify"</string>
<string name="linked_text_clipboard">Text has been copied to clipboard</string>
<plurals name="linked_id_expand">
<item quantity="one">"There is one more unknown identity type"</item>
<item quantity="other">"There are %d more unknown identity types"</item>