mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
Merge pull request #772 from mar-v-in/issue-729
Remove NoSwipeWrapContentViewPager
This commit is contained in:
commit
56fb822034
@ -73,16 +73,13 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryption_key_ids";
|
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryption_key_ids";
|
||||||
|
|
||||||
// view
|
// view
|
||||||
ViewPager mViewPagerMode;
|
private int mCurrentMode = PAGER_MODE_ASYMMETRIC;
|
||||||
//PagerTabStrip mPagerTabStripMode;
|
private ViewPager mViewPagerContent;
|
||||||
PagerTabStripAdapter mTabsAdapterMode;
|
private PagerTabStrip mPagerTabStripContent;
|
||||||
ViewPager mViewPagerContent;
|
private PagerTabStripAdapter mTabsAdapterContent;
|
||||||
PagerTabStrip mPagerTabStripContent;
|
|
||||||
PagerTabStripAdapter mTabsAdapterContent;
|
|
||||||
|
|
||||||
// tabs
|
// tabs
|
||||||
int mSwitchToMode = PAGER_MODE_ASYMMETRIC;
|
private int mSwitchToContent = PAGER_CONTENT_MESSAGE;
|
||||||
int mSwitchToContent = PAGER_CONTENT_MESSAGE;
|
|
||||||
|
|
||||||
private static final int PAGER_MODE_ASYMMETRIC = 0;
|
private static final int PAGER_MODE_ASYMMETRIC = 0;
|
||||||
private static final int PAGER_MODE_SYMMETRIC = 1;
|
private static final int PAGER_MODE_SYMMETRIC = 1;
|
||||||
@ -102,7 +99,7 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
private String mMessage = "";
|
private String mMessage = "";
|
||||||
|
|
||||||
public boolean isModeSymmetric() {
|
public boolean isModeSymmetric() {
|
||||||
return PAGER_MODE_SYMMETRIC == mViewPagerMode.getCurrentItem();
|
return PAGER_MODE_SYMMETRIC == mCurrentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isContentMessage() {
|
public boolean isContentMessage() {
|
||||||
@ -474,13 +471,9 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
mViewPagerMode = (ViewPager) findViewById(R.id.encrypt_pager_mode);
|
|
||||||
//mPagerTabStripMode = (PagerTabStrip) findViewById(R.id.encrypt_pager_tab_strip_mode);
|
|
||||||
mViewPagerContent = (ViewPager) findViewById(R.id.encrypt_pager_content);
|
mViewPagerContent = (ViewPager) findViewById(R.id.encrypt_pager_content);
|
||||||
mPagerTabStripContent = (PagerTabStrip) findViewById(R.id.encrypt_pager_tab_strip_content);
|
mPagerTabStripContent = (PagerTabStrip) findViewById(R.id.encrypt_pager_tab_strip_content);
|
||||||
|
|
||||||
mTabsAdapterMode = new PagerTabStripAdapter(this);
|
|
||||||
mViewPagerMode.setAdapter(mTabsAdapterMode);
|
|
||||||
mTabsAdapterContent = new PagerTabStripAdapter(this);
|
mTabsAdapterContent = new PagerTabStripAdapter(this);
|
||||||
mViewPagerContent.setAdapter(mTabsAdapterContent);
|
mViewPagerContent.setAdapter(mTabsAdapterContent);
|
||||||
}
|
}
|
||||||
@ -502,10 +495,7 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
|
|
||||||
// Handle intent actions
|
// Handle intent actions
|
||||||
handleActions(getIntent());
|
handleActions(getIntent());
|
||||||
|
updateModeFragment();
|
||||||
mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, null, getString(R.string.label_asymmetric));
|
|
||||||
mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, null, getString(R.string.label_symmetric));
|
|
||||||
mViewPagerMode.setCurrentItem(mSwitchToMode);
|
|
||||||
|
|
||||||
mTabsAdapterContent.addTab(EncryptMessageFragment.class, null, getString(R.string.label_message));
|
mTabsAdapterContent.addTab(EncryptMessageFragment.class, null, getString(R.string.label_message));
|
||||||
mTabsAdapterContent.addTab(EncryptFileFragment.class, null, getString(R.string.label_files));
|
mTabsAdapterContent.addTab(EncryptFileFragment.class, null, getString(R.string.label_files));
|
||||||
@ -521,6 +511,16 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateModeFragment() {
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.encrypt_pager_mode,
|
||||||
|
mCurrentMode == PAGER_MODE_SYMMETRIC
|
||||||
|
? new EncryptSymmetricFragment()
|
||||||
|
: new EncryptAsymmetricFragment())
|
||||||
|
.commitAllowingStateLoss();
|
||||||
|
getSupportFragmentManager().executePendingTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.isCheckable()) {
|
if (item.isCheckable()) {
|
||||||
@ -528,9 +528,8 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
}
|
}
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.check_use_symmetric:
|
case R.id.check_use_symmetric:
|
||||||
mSwitchToMode = item.isChecked() ? PAGER_MODE_SYMMETRIC : PAGER_MODE_ASYMMETRIC;
|
mCurrentMode = item.isChecked() ? PAGER_MODE_SYMMETRIC : PAGER_MODE_ASYMMETRIC;
|
||||||
|
updateModeFragment();
|
||||||
mViewPagerMode.setCurrentItem(mSwitchToMode);
|
|
||||||
notifyUpdate();
|
notifyUpdate();
|
||||||
break;
|
break;
|
||||||
case R.id.check_use_armor:
|
case R.id.check_use_armor:
|
||||||
@ -604,7 +603,7 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
|
|||||||
mEncryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
mEncryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
|
||||||
|
|
||||||
// preselect keys given by intent
|
// preselect keys given by intent
|
||||||
mSwitchToMode = PAGER_MODE_ASYMMETRIC;
|
mCurrentMode = PAGER_MODE_ASYMMETRIC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Actions
|
* Main Actions
|
||||||
|
@ -18,30 +18,16 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.LoaderManager;
|
|
||||||
import android.support.v4.content.CursorLoader;
|
|
||||||
import android.support.v4.content.Loader;
|
|
||||||
import android.support.v4.widget.CursorAdapter;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.SpinnerAdapter;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.tokenautocomplete.TokenCompleteTextView;
|
import com.tokenautocomplete.TokenCompleteTextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
@ -169,6 +155,8 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
|
|||||||
Log.e(Constants.TAG, "key not found!", e);
|
Log.e(Constants.TAG, "key not found!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// This is to work-around a rendering bug in TokenCompleteTextView
|
||||||
|
mEncryptKeyView.requestFocus();
|
||||||
updateEncryptionKeys();
|
updateEncryptionKeys();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,62 +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.widget;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
public class NoSwipeWrapContentViewPager extends android.support.v4.view.ViewPager {
|
|
||||||
public NoSwipeWrapContentViewPager(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NoSwipeWrapContentViewPager(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
|
|
||||||
int height;
|
|
||||||
View child = getChildAt(getCurrentItem());
|
|
||||||
if (child != null) {
|
|
||||||
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
|
||||||
height = child.getMeasuredHeight();
|
|
||||||
} else {
|
|
||||||
height = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
|
|
||||||
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onInterceptTouchEvent(MotionEvent arg0) {
|
|
||||||
// Never allow swiping to switch between pages
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
|
||||||
// Never allow swiping to switch between pages
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,13 +9,11 @@
|
|||||||
|
|
||||||
<include layout="@layout/notify_area"/>
|
<include layout="@layout/notify_area"/>
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.NoSwipeWrapContentViewPager
|
<FrameLayout
|
||||||
android:id="@+id/encrypt_pager_mode"
|
android:id="@+id/encrypt_pager_mode"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical" />
|
||||||
|
|
||||||
</org.sufficientlysecure.keychain.ui.widget.NoSwipeWrapContentViewPager>
|
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
android:id="@+id/encrypt_pager_content"
|
android:id="@+id/encrypt_pager_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user