Fix onTouchEvent delegation, with workaround for Android bug

This commit is contained in:
Dominik Schürmann 2014-06-20 15:39:27 +02:00
parent 4aec28c237
commit 717d66961b
2 changed files with 7 additions and 14 deletions

View File

@ -28,7 +28,6 @@ import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -88,8 +87,6 @@ public class ImportKeysActivity extends ActionBarActivity {
// view // view
private ImportKeysListFragment mListFragment; private ImportKeysListFragment mListFragment;
private String[] mNavigationStrings;
private Fragment mCurrentFragment;
private View mImportButton; private View mImportButton;
private ViewPager mViewPager; private ViewPager mViewPager;
private SlidingTabLayout mSlidingTabLayout; private SlidingTabLayout mSlidingTabLayout;
@ -121,8 +118,6 @@ public class ImportKeysActivity extends ActionBarActivity {
} }
}); });
mNavigationStrings = getResources().getStringArray(R.array.import_action_list);
// TODO: add actionbar button for this action? // TODO: add actionbar button for this action?
// if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { // if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) {
// } // }
@ -373,7 +368,13 @@ public class ImportKeysActivity extends ActionBarActivity {
boolean result = super.onTouchEvent(event); boolean result = super.onTouchEvent(event);
if (!result) { if (!result) {
mViewPager.onTouchEvent(event); try {
mViewPager.onTouchEvent(event);
} catch (IllegalArgumentException e) {
// workaround for Android bug?
// http://stackoverflow.com/q/16459196
Log.d(Constants.TAG, "Workaround: Catched IllegalArgumentException");
}
} }
return result; return result;

View File

@ -48,13 +48,5 @@
<item>@string/key_size_1024</item> <item>@string/key_size_1024</item>
<item>@string/key_size_custom</item> <item>@string/key_size_custom</item>
</string-array> </string-array>
<string-array name="import_action_list" translatable="false">
<item>@string/menu_import_from_key_server</item>
<item>@string/menu_import_from_file</item>
<item>@string/menu_import_from_qr_code</item>
<item>@string/import_from_clipboard</item>
<item>@string/menu_import_from_nfc</item>
<item>@string/menu_import_from_keybase</item>
</string-array>
</resources> </resources>