Loading res/layout/activity_calculator_main.xml +3 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/activity_calculator" /> <include android:id="@+id/main_calculator" layout="@layout/activity_calculator" /> <FrameLayout android:id="@+id/history_frame" Loading src/com/android/calculator2/Calculator.java +20 −4 Original line number Diff line number Diff line Loading @@ -277,6 +277,7 @@ public class Calculator extends Activity private View mDeleteButton; private View mClearButton; private View mEqualButton; private View mMainCalculator; private TextView mInverseToggle; private TextView mModeToggle; Loading Loading @@ -390,6 +391,7 @@ public class Calculator extends Activity } }); mMainCalculator = findViewById(R.id.main_calculator); mDisplayView = (CalculatorDisplay) findViewById(R.id.display); mModeView = (TextView) findViewById(R.id.mode); mFormulaText = (CalculatorFormula) findViewById(R.id.formula); Loading Loading @@ -463,6 +465,14 @@ public class Calculator extends Activity if (mDisplayView.isToolbarVisible()) { showAndMaybeHideToolbar(); } // If HistoryFragment is showing, hide the main Calculator elements from accessibility. // This is because Talkback does not use visibility as a cue for RelativeLayout elements, // and RelativeLayout is the base class of DragLayout. // If we did not do this, it would be possible to traverse to main Calculator elements from // HistoryFragment. mMainCalculator.setImportantForAccessibility( mDragLayout.isOpen() ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); } @Override Loading Loading @@ -734,13 +744,15 @@ public class Calculator extends Activity private void removeHistoryFragment() { final FragmentManager manager = getFragmentManager(); if (manager == null || manager.isDestroyed()) { return; } if (manager != null && !manager.isDestroyed()) { manager.popBackStackImmediate(HistoryFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); } // When HistoryFragment is hidden, the main Calculator is important for accessibility again. mMainCalculator.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); } /** * Switch to INPUT from RESULT state in response to input of the specified button_id. * View.NO_ID is treated as an incomplete function id. Loading Loading @@ -1334,6 +1346,10 @@ public class Calculator extends Activity .addToBackStack(HistoryFragment.TAG) .commit(); manager.executePendingTransactions(); // When HistoryFragment is visible, hide all descendants of the main Calculator view. mMainCalculator.setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); } // TODO: pass current scroll position of result } Loading src/com/android/calculator2/HistoryFragment.java +0 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.Toolbar; Loading Loading @@ -130,7 +129,6 @@ public class HistoryFragment extends Fragment { getActivity().onBackPressed(); } }); return view; } Loading Loading
res/layout/activity_calculator_main.xml +3 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/activity_calculator" /> <include android:id="@+id/main_calculator" layout="@layout/activity_calculator" /> <FrameLayout android:id="@+id/history_frame" Loading
src/com/android/calculator2/Calculator.java +20 −4 Original line number Diff line number Diff line Loading @@ -277,6 +277,7 @@ public class Calculator extends Activity private View mDeleteButton; private View mClearButton; private View mEqualButton; private View mMainCalculator; private TextView mInverseToggle; private TextView mModeToggle; Loading Loading @@ -390,6 +391,7 @@ public class Calculator extends Activity } }); mMainCalculator = findViewById(R.id.main_calculator); mDisplayView = (CalculatorDisplay) findViewById(R.id.display); mModeView = (TextView) findViewById(R.id.mode); mFormulaText = (CalculatorFormula) findViewById(R.id.formula); Loading Loading @@ -463,6 +465,14 @@ public class Calculator extends Activity if (mDisplayView.isToolbarVisible()) { showAndMaybeHideToolbar(); } // If HistoryFragment is showing, hide the main Calculator elements from accessibility. // This is because Talkback does not use visibility as a cue for RelativeLayout elements, // and RelativeLayout is the base class of DragLayout. // If we did not do this, it would be possible to traverse to main Calculator elements from // HistoryFragment. mMainCalculator.setImportantForAccessibility( mDragLayout.isOpen() ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); } @Override Loading Loading @@ -734,13 +744,15 @@ public class Calculator extends Activity private void removeHistoryFragment() { final FragmentManager manager = getFragmentManager(); if (manager == null || manager.isDestroyed()) { return; } if (manager != null && !manager.isDestroyed()) { manager.popBackStackImmediate(HistoryFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); } // When HistoryFragment is hidden, the main Calculator is important for accessibility again. mMainCalculator.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); } /** * Switch to INPUT from RESULT state in response to input of the specified button_id. * View.NO_ID is treated as an incomplete function id. Loading Loading @@ -1334,6 +1346,10 @@ public class Calculator extends Activity .addToBackStack(HistoryFragment.TAG) .commit(); manager.executePendingTransactions(); // When HistoryFragment is visible, hide all descendants of the main Calculator view. mMainCalculator.setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); } // TODO: pass current scroll position of result } Loading
src/com/android/calculator2/HistoryFragment.java +0 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.Toolbar; Loading Loading @@ -130,7 +129,6 @@ public class HistoryFragment extends Fragment { getActivity().onBackPressed(); } }); return view; } Loading