linked: ditch create dns fragment (for now)

This commit is contained in:
Vincent Breitmoser
2015-09-10 12:17:25 +02:00
parent 8a1a62692b
commit c6f1f505bb
5 changed files with 0 additions and 601 deletions

View File

@@ -1,129 +0,0 @@
/*
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.ui.linked;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.EditText;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.linked.resources.DnsResource;
public class LinkedIdCreateDnsStep1Fragment extends Fragment {
LinkedIdWizard mLinkedIdWizard;
EditText mEditDns;
/**
* Creates new instance of this fragment
*/
public static LinkedIdCreateDnsStep1Fragment newInstance() {
LinkedIdCreateDnsStep1Fragment frag = new LinkedIdCreateDnsStep1Fragment();
Bundle args = new Bundle();
frag.setArguments(args);
return frag;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mLinkedIdWizard = (LinkedIdWizard) getActivity();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.linked_create_dns_fragment_step1, container, false);
view.findViewById(R.id.next_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String uri = mEditDns.getText().toString();
if (!checkUri(uri)) {
mEditDns.setError("Please enter a valid domain name!");
return;
}
String proofText = DnsResource.generateText(
mLinkedIdWizard.mFingerprint);
LinkedIdCreateDnsStep2Fragment frag =
LinkedIdCreateDnsStep2Fragment.newInstance(uri, proofText);
mLinkedIdWizard.loadFragment(null, frag, LinkedIdWizard.FRAG_ACTION_TO_RIGHT);
}
});
view.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLinkedIdWizard.loadFragment(null, null, LinkedIdWizard.FRAG_ACTION_TO_LEFT);
}
});
mEditDns = (EditText) view.findViewById(R.id.linked_create_dns_domain);
mEditDns.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
String uri = editable.toString();
if (uri.length() > 0) {
if (checkUri(uri)) {
mEditDns.setCompoundDrawablesWithIntrinsicBounds(0, 0,
R.drawable.ic_stat_retyped_ok, 0);
} else {
mEditDns.setCompoundDrawablesWithIntrinsicBounds(0, 0,
R.drawable.ic_stat_retyped_bad, 0);
}
} else {
// remove drawable if email is empty
mEditDns.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
}
});
return view;
}
private static boolean checkUri(String uri) {
return Patterns.DOMAIN_NAME.matcher(uri).matches();
}
}

View File

@@ -1,172 +0,0 @@
/*
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.ui.linked;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.linked.LinkedTokenResource;
import org.sufficientlysecure.keychain.linked.resources.DnsResource;
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
public class LinkedIdCreateDnsStep2Fragment extends LinkedIdCreateFinalFragment {
private static final int REQUEST_CODE_OUTPUT = 0x00007007;
public static final String DOMAIN = "domain", TEXT = "text";
TextView mTextView;
String mResourceDomain;
String mResourceString;
public static LinkedIdCreateDnsStep2Fragment newInstance
(String uri, String proofText) {
LinkedIdCreateDnsStep2Fragment frag = new LinkedIdCreateDnsStep2Fragment();
Bundle args = new Bundle();
args.putString(DOMAIN, uri);
args.putString(TEXT, proofText);
frag.setArguments(args);
return frag;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mResourceDomain = getArguments().getString(DOMAIN);
mResourceString = getArguments().getString(TEXT);
}
@Override
protected View newView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.linked_create_dns_fragment_step2, container, false);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) {
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
proofSend();
}
});
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
proofToClipboard();
}
});
mTextView = (TextView) view.findViewById(R.id.linked_create_dns_text);
mTextView.setText(mResourceString);
}
return view;
}
@Override
LinkedTokenResource getResource(OperationLog log) {
return DnsResource.createNew(mResourceDomain);
}
private void proofSend () {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, mResourceString);
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
private void proofToClipboard() {
Activity activity = getActivity();
if (activity == null) {
return;
}
ClipboardManager clipMan = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipMan == null) {
Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR).show();
return;
}
ClipData clip = ClipData.newPlainText(Constants.CLIPBOARD_LABEL, mResourceString);
clipMan.setPrimaryClip(clip);
Notify.create(getActivity(), R.string.linked_text_clipboard, Notify.Style.OK).show();
}
private void saveFile(Uri uri) {
try {
PrintWriter out =
new PrintWriter(getActivity().getContentResolver().openOutputStream(uri));
out.print(mResourceString);
if (out.checkError()) {
Notify.create(getActivity(), "Error writing file!", Style.ERROR).show();
}
} catch (FileNotFoundException e) {
Notify.create(getActivity(), "File could not be opened for writing!", Style.ERROR).show();
e.printStackTrace();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
// For saving a file
case REQUEST_CODE_OUTPUT:
if (data == null) {
return;
}
Uri uri = data.getData();
saveFile(uri);
break;
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
}

View File

@@ -1,126 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="false"
android:layout_above="@+id/create_key_button_divider">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:drawableLeft="@drawable/linked_dns"
android:drawablePadding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_1_1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_1_2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_1_3" />
<EditText
android:id="@+id/linked_create_dns_domain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:ems="10"
android:inputType="textUri"
android:layout_gravity="center_horizontal"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_1_4" />
</LinearLayout>
</ScrollView>
<View
android:id="@+id/create_key_button_divider"
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="?android:attr/listDivider"
android:layout_alignTop="@+id/create_key_buttons"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:id="@+id/create_key_buttons">
<TextView
android:id="@+id/back_button"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_back"
android:clickable="true"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAllCaps="true"
style="?android:attr/borderlessButtonStyle"
android:drawableLeft="@drawable/ic_chevron_left_grey_24dp"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/next_button"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_next"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAllCaps="true"
android:drawableRight="@drawable/ic_chevron_right_grey_24dp"
android:drawablePadding="8dp"
android:gravity="center_vertical|right"
android:clickable="true"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="center_vertical" />
</LinearLayout>
</RelativeLayout>

View File

@@ -1,164 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="false"
android:layout_above="@+id/create_key_button_divider">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_2_1" />
<TextView
android:id="@+id/linked_create_dns_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal"
android:textIsSelectable="true"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_2_2" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
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"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_2_3" />
<include layout="@layout/linked_create_verify" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_dns_2_4" />
</LinearLayout>
</ScrollView>
<View
android:id="@+id/create_key_button_divider"
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="?android:attr/listDivider"
android:layout_alignTop="@+id/create_key_buttons"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:id="@+id/create_key_buttons">
<TextView
android:id="@+id/back_button"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_back"
android:minHeight="?android:attr/listPreferredItemHeight"
android:clickable="true"
android:textAllCaps="true"
style="?android:attr/borderlessButtonStyle"
android:drawableLeft="@drawable/ic_chevron_left_grey_24dp"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/next_button"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_finish"
android:minHeight="?android:attr/listPreferredItemHeight"
android:drawableRight="@drawable/ic_person_add_grey_24dp"
android:drawablePadding="8dp"
android:textAllCaps="true"
style="?android:attr/borderlessButtonStyle"
android:gravity="center_vertical|right"
android:clickable="true"
android:layout_gravity="center_vertical" />
</LinearLayout>
</RelativeLayout>

View File

@@ -1565,16 +1565,6 @@
<string name="linked_create_twitter_2_3">"Once your Tweet is published as &lt;b&gt;@%s&lt;/b&gt;, 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>
<!-- An Identity of this type is especially appropriate if your email address is at the same domain. -->
<string name="linked_create_dns_1_3">"Please enter a fully qualified domain name to proceed."</string>
<string name="linked_create_dns_1_4">"Example: subdomain.example.com"</string>
<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">"After successful verification, press the Finish button to add the Linked Identity to your keyring and finish the process."</string>
<string name="linked_create_verify">"Verify"</string>
<string name="linked_text_clipboard">Text has been copied to clipboard</string>
<string name="linked_verified_https">"The link between this Website and key was securely verified. <b>If you believe the Website is genuine</b>, confirm this verification with your key."</string>