diff options
Diffstat (limited to 'OpenKeychain')
3 files changed, 18 insertions, 174 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep1Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep1Fragment.java index 86579a132..06ca32e2e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep1Fragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep1Fragment.java @@ -94,10 +94,8 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment { return; } - int proofNonce = RawLinkedIdentity.generateNonce(); - - LinkedIdCreateTwitterStep2Fragment frag = - LinkedIdCreateTwitterStep2Fragment.newInstance(handle, proofNonce); + LinkedIdCreateTwitterStep3Fragment frag = + LinkedIdCreateTwitterStep3Fragment.newInstance(handle); mLinkedIdWizard.loadFragment(null, frag, LinkedIdWizard.FRAG_ACTION_TO_RIGHT); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java deleted file mode 100644 index e2fa6d5f6..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java +++ /dev/null @@ -1,155 +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.InputFilter; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.TextView; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.linked.resources.TwitterResource; - -public class LinkedIdCreateTwitterStep2Fragment extends Fragment { - - public static final String HANDLE = "uri", NONCE = "nonce", TEXT = "text"; - - LinkedIdWizard mLinkedIdWizard; - - EditText mEditTweetCustom, mEditTweetPreview; - ImageView mVerifyImage; - View mVerifyProgress; - TextView mVerifyStatus, mEditTweetTextLen; - - String mResourceHandle; - int mResourceNonce; - String mResourceString; - String mCookiePreview; - - /** - * Creates new instance of this fragment - */ - public static LinkedIdCreateTwitterStep2Fragment newInstance - (String handle, int proofNonce) { - - LinkedIdCreateTwitterStep2Fragment frag = new LinkedIdCreateTwitterStep2Fragment(); - - Bundle args = new Bundle(); - args.putString(HANDLE, handle); - args.putInt(NONCE, proofNonce); - frag.setArguments(args); - - return frag; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mLinkedIdWizard = (LinkedIdWizard) getActivity(); - - mResourceHandle = getArguments().getString(HANDLE); - mResourceNonce = getArguments().getInt(NONCE); - - mResourceString = TwitterResource.generateText(getActivity(), - mLinkedIdWizard.mFingerprint, mResourceNonce); - - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View view = inflater.inflate(R.layout.linked_create_twitter_fragment_step2, container, false); - - mCookiePreview = TwitterResource.generatePreview(); - - view.findViewById(R.id.next_button).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - - LinkedIdCreateTwitterStep3Fragment frag = - LinkedIdCreateTwitterStep3Fragment.newInstance(mResourceHandle, - mResourceNonce, mResourceString, - mEditTweetCustom.getText().toString()); - - 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); - } - }); - - mVerifyImage = (ImageView) view.findViewById(R.id.verify_image); - mVerifyProgress = view.findViewById(R.id.verify_progress); - mVerifyStatus = (TextView) view.findViewById(R.id.verify_status); - - mEditTweetPreview = (EditText) view.findViewById(R.id.linked_create_twitter_preview); - mEditTweetPreview.setText(mCookiePreview); - - mEditTweetCustom = (EditText) view.findViewById(R.id.linked_create_twitter_custom); - mEditTweetCustom.setFilters(new InputFilter[] { - new InputFilter.LengthFilter(139 - mResourceString.length()) - }); - - mEditTweetTextLen = (TextView) view.findViewById(R.id.linked_create_twitter_textlen); - mEditTweetTextLen.setText(mResourceString.length() + "/140"); - - mEditTweetCustom.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) { - if (editable != null && editable.length() > 0) { - String str = editable + " " + mCookiePreview; - mEditTweetPreview.setText(str); - - mEditTweetTextLen.setText( - (editable.length() + mResourceString.length() + 1) + "/140"); - mEditTweetTextLen.setTextColor(getResources().getColor(str.length() == 140 - ? R.color.android_red_dark - : R.color.primary_dark_material_light)); - - - } else { - mEditTweetPreview.setText(mCookiePreview); - mEditTweetTextLen.setText(mResourceString.length() + "/140"); - } - } - }); - - return view; - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep3Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep3Fragment.java index cfa8d8d23..ce0526efc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep3Fragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep3Fragment.java @@ -33,6 +33,9 @@ import android.widget.TextView; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource; +import org.sufficientlysecure.keychain.pgp.linked.LinkedIdentity; +import org.sufficientlysecure.keychain.pgp.linked.LinkedResource; +import org.sufficientlysecure.keychain.pgp.linked.RawLinkedIdentity; import org.sufficientlysecure.keychain.pgp.linked.resources.TwitterResource; import org.sufficientlysecure.keychain.ui.util.Notify; @@ -40,24 +43,24 @@ import java.util.List; public class LinkedIdCreateTwitterStep3Fragment extends LinkedIdCreateFinalFragment { - public static final String ARG_HANDLE = "uri", ARG_TEXT = "text", ARG_CUSTOM = "custom"; + public static final String ARG_HANDLE = "handle"; EditText mEditTweetPreview; - String mResourceHandle, mCustom, mFullString; + String mResourceHandle; String mResourceString; private int mNonce; public static LinkedIdCreateTwitterStep3Fragment newInstance - (String handle, int proofNonce, String proofText, String customText) { + (String handle) { LinkedIdCreateTwitterStep3Fragment frag = new LinkedIdCreateTwitterStep3Fragment(); + int proofNonce = RawLinkedIdentity.generateNonce(); + Bundle args = new Bundle(); args.putString(ARG_HANDLE, handle); args.putInt(ARG_NONCE, proofNonce); - args.putString(ARG_TEXT, proofText); - args.putString(ARG_CUSTOM, customText); frag.setArguments(args); return frag; @@ -67,13 +70,11 @@ public class LinkedIdCreateTwitterStep3Fragment extends LinkedIdCreateFinalFragm public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Bundle args = getArguments(); - mResourceHandle = args.getString(ARG_HANDLE); - mResourceString = args.getString(ARG_TEXT); - mCustom = args.getString(ARG_CUSTOM); - mNonce = args.getInt(ARG_NONCE); + mNonce = LinkedIdentity.generateNonce(); + mResourceString = + TwitterResource.generate(getActivity(), mLinkedIdWizard.mFingerprint, mNonce); - mFullString = mCustom.isEmpty() ? mResourceString : (mCustom + " " + mResourceString); + mResourceHandle = getArguments().getString(ARG_HANDLE); } @@ -82,7 +83,7 @@ public class LinkedIdCreateTwitterStep3Fragment extends LinkedIdCreateFinalFragm View view = super.onCreateView(inflater, container, savedInstanceState); mEditTweetPreview = (EditText) view.findViewById(R.id.linked_create_twitter_preview); - mEditTweetPreview.setText(mFullString); + mEditTweetPreview.setText(mResourceString); view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() { @Override @@ -103,7 +104,7 @@ public class LinkedIdCreateTwitterStep3Fragment extends LinkedIdCreateFinalFragm @Override LinkedCookieResource getResource() { - return TwitterResource.searchInTwitterStream(mResourceHandle, mFullString); + return TwitterResource.searchInTwitterStream(mResourceHandle, mResourceString); } @Override @@ -114,7 +115,7 @@ public class LinkedIdCreateTwitterStep3Fragment extends LinkedIdCreateFinalFragm private void proofShare() { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); - sendIntent.putExtra(Intent.EXTRA_TEXT, mFullString); + sendIntent.putExtra(Intent.EXTRA_TEXT, mResourceString); sendIntent.setType("text/plain"); startActivity(sendIntent); } @@ -122,7 +123,7 @@ public class LinkedIdCreateTwitterStep3Fragment extends LinkedIdCreateFinalFragm private void proofSend() { Intent tweetIntent = new Intent(Intent.ACTION_SEND); - tweetIntent.putExtra(Intent.EXTRA_TEXT, mFullString); + tweetIntent.putExtra(Intent.EXTRA_TEXT, mResourceString); tweetIntent.setType("text/plain"); PackageManager packManager = getActivity().getPackageManager(); |