Fragments
This commit is contained in:
parent
c1e6389024
commit
009f536772
@ -20,8 +20,6 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<service android:name=".CalculationServiceImpl"/>
|
||||
|
||||
<!--NOTE: a:configChanges="orientation|keyboardHidden" is needed to correct work of dialog windows (not to close them on orientation change) -->
|
||||
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_app_settings" android:name=".CalculatorPreferencesActivity"/>
|
||||
|
||||
|
53
calculatorpp/res/layout-land/calc_keyboard.xml
Normal file
53
calculatorpp/res/layout-land/calc_keyboard.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:orientation="vertical">
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_vars_button"/>
|
||||
<include layout="@layout/calc_copy_button"/>
|
||||
<include layout="@layout/calc_seven_digit_button"/>
|
||||
<include layout="@layout/calc_eight_digit_button"/>
|
||||
<include layout="@layout/calc_nine_digit_button"/>
|
||||
<include layout="@layout/calc_multiplication_button"/>
|
||||
<include layout="@layout/calc_division_button"/>
|
||||
<include layout="@layout/calc_equals_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_functions_button"/>
|
||||
<include layout="@layout/calc_paste_button"/>
|
||||
<include layout="@layout/calc_four_digit_button"/>
|
||||
<include layout="@layout/calc_five_digit_button"/>
|
||||
<include layout="@layout/calc_six_digit_button"/>
|
||||
<include layout="@layout/calc_plus_button"/>
|
||||
<include layout="@layout/calc_subtraction_button"/>
|
||||
<include layout="@layout/calc_round_brackets_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_operators_button"/>
|
||||
<include layout="@layout/calc_donate_button"/>
|
||||
<include layout="@layout/calc_one_digit_button"/>
|
||||
<include layout="@layout/calc_two_digit_button"/>
|
||||
<include layout="@layout/calc_three_digit_button"/>
|
||||
<include layout="@layout/calc_zero_digit_button"/>
|
||||
<include layout="@layout/calc_dot_button"/>
|
||||
<include layout="@layout/calc_history_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -8,16 +8,21 @@
|
||||
<LinearLayout
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:layout_width="fill_parent"
|
||||
a:id="@+id/ad_parent_view"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_gravity="center"
|
||||
a:background="#ff000000">
|
||||
a:background="@color/default_background">
|
||||
|
||||
<include layout="@layout/calc_editor"/>
|
||||
<LinearLayout a:id="@+id/editorContainer"
|
||||
a:layout_weight="2"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp"/>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<org.solovyev.android.view.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
@ -28,7 +33,7 @@
|
||||
style="?controlButtonStyle"
|
||||
a:onClick="moveLeftButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
|
||||
@ -39,14 +44,13 @@
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="eraseButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
|
||||
<include layout="@layout/calc_display"
|
||||
<LinearLayout a:id="@+id/displayContainer"
|
||||
a:layout_weight="4"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="4"/>
|
||||
a:layout_height="match_parent"/>
|
||||
|
||||
<org.solovyev.android.calculator.view.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
@ -59,7 +63,7 @@
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="clearButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
<org.solovyev.android.view.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
@ -71,48 +75,15 @@
|
||||
style="?controlButtonStyle"
|
||||
a:onClick="moveRightButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
<LinearLayout a:id="@+id/keyboardContainer"
|
||||
a:layout_weight="4"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp"/>
|
||||
|
||||
<include layout="@layout/calc_vars_button"/>
|
||||
<include layout="@layout/calc_copy_button"/>
|
||||
<include layout="@layout/calc_seven_digit_button"/>
|
||||
<include layout="@layout/calc_eight_digit_button"/>
|
||||
<include layout="@layout/calc_nine_digit_button"/>
|
||||
<include layout="@layout/calc_multiplication_button"/>
|
||||
<include layout="@layout/calc_division_button"/>
|
||||
<include layout="@layout/calc_equals_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_functions_button"/>
|
||||
<include layout="@layout/calc_paste_button"/>
|
||||
<include layout="@layout/calc_four_digit_button"/>
|
||||
<include layout="@layout/calc_five_digit_button"/>
|
||||
<include layout="@layout/calc_six_digit_button"/>
|
||||
<include layout="@layout/calc_plus_button"/>
|
||||
<include layout="@layout/calc_subtraction_button"/>
|
||||
<include layout="@layout/calc_round_brackets_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_operators_button"/>
|
||||
<include layout="@layout/calc_donate_button"/>
|
||||
<include layout="@layout/calc_one_digit_button"/>
|
||||
<include layout="@layout/calc_two_digit_button"/>
|
||||
<include layout="@layout/calc_three_digit_button"/>
|
||||
<include layout="@layout/calc_zero_digit_button"/>
|
||||
<include layout="@layout/calc_dot_button"/>
|
||||
<include layout="@layout/calc_history_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -13,7 +13,7 @@
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_gravity="center"
|
||||
a:background="#ff000000">
|
||||
a:background="@color/default_background">
|
||||
|
||||
<LinearLayout a:id="@+id/editorContainer"
|
||||
a:layout_weight="2"
|
@ -14,6 +14,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
@ -80,17 +81,17 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
final CalculatorEditorFragment editorFragment = new CalculatorEditorFragment();
|
||||
fragmentTransaction.add(R.id.editorContainer, editorFragment);
|
||||
fragmentTransaction.add(R.id.editorContainer, editorFragment, "editor");
|
||||
fragmentTransaction.commit();
|
||||
|
||||
fragmentTransaction = fragmentManager.beginTransaction();
|
||||
final CalculatorDisplayFragment displayFragment = new CalculatorDisplayFragment();
|
||||
fragmentTransaction.add(R.id.displayContainer, displayFragment);
|
||||
fragmentTransaction.add(R.id.displayContainer, displayFragment, "display");
|
||||
fragmentTransaction.commit();
|
||||
|
||||
fragmentTransaction = fragmentManager.beginTransaction();
|
||||
final CalculatorKeyboardFragment keyboardFragment = new CalculatorKeyboardFragment();
|
||||
fragmentTransaction.add(R.id.keyboardContainer, keyboardFragment);
|
||||
fragmentTransaction.add(R.id.keyboardContainer, keyboardFragment, "keyboard");
|
||||
fragmentTransaction.commit();
|
||||
|
||||
if (customTitleSupported) {
|
||||
|
@ -90,9 +90,14 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
||||
setOnDragListeners(root, dragPreferences, preferences);
|
||||
|
||||
final OnDragListener historyOnDragListener = new OnDragListenerVibrator(newOnDragListener(new HistoryDragProcessor<CalculatorHistoryState>(getCalculator()), dragPreferences), vibrator, preferences);
|
||||
((DragButton) root.findViewById(R.id.historyButton)).setOnDragListener(historyOnDragListener);
|
||||
final DragButton historyButton = getButton(root, R.id.historyButton);
|
||||
if (historyButton != null) {
|
||||
historyButton.setOnDragListener(historyOnDragListener);
|
||||
}
|
||||
|
||||
((DragButton) root.findViewById(R.id.subtractionButton)).setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
|
||||
final DragButton subtractionButton = getButton(root, R.id.subtractionButton);
|
||||
if (subtractionButton != null) {
|
||||
subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||
if (dragDirection == DragDirection.down) {
|
||||
@ -102,33 +107,42 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
||||
return false;
|
||||
}
|
||||
}, dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
|
||||
final OnDragListener toPositionOnDragListener = new OnDragListenerVibrator(new SimpleOnDragListener(new CursorDragProcessor(), dragPreferences), vibrator, preferences);
|
||||
((DragButton) root.findViewById(R.id.rightButton)).setOnDragListener(toPositionOnDragListener);
|
||||
((DragButton) root.findViewById(R.id.leftButton)).setOnDragListener(toPositionOnDragListener);
|
||||
|
||||
final DragButton equalsButton = (DragButton) root.findViewById(R.id.equalsButton);
|
||||
final DragButton rightButton = getButton(root, R.id.rightButton);
|
||||
if (rightButton != null) {
|
||||
rightButton.setOnDragListener(toPositionOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton leftButton = getButton(root, R.id.leftButton);
|
||||
if (leftButton != null) {
|
||||
leftButton.setOnDragListener(toPositionOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton equalsButton = getButton(root, R.id.equalsButton);
|
||||
if (equalsButton != null) {
|
||||
equalsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new EvalDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) root.findViewById(R.id.sixDigitButton);
|
||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) getButton(root, R.id.sixDigitButton);
|
||||
if (angleUnitsButton != null) {
|
||||
angleUnitsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new AngleUnitsChanger(this.getActivity()), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final NumeralBasesButton clearButton = (NumeralBasesButton) root.findViewById(R.id.clearButton);
|
||||
final NumeralBasesButton clearButton = (NumeralBasesButton) getButton(root, R.id.clearButton);
|
||||
if (clearButton != null) {
|
||||
clearButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new NumeralBasesChanger(this.getActivity()), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final DragButton varsButton = (DragButton) root.findViewById(R.id.varsButton);
|
||||
final DragButton varsButton = getButton(root, R.id.varsButton);
|
||||
if (varsButton != null) {
|
||||
varsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new VarsDragProcessor(this.getActivity()), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final DragButton roundBracketsButton = (DragButton) root.findViewById(R.id.roundBracketsButton);
|
||||
final DragButton roundBracketsButton = getButton(root, R.id.roundBracketsButton);
|
||||
if (roundBracketsButton != null) {
|
||||
roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new RoundBracketsDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
@ -162,6 +176,11 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
||||
initMultiplicationButton();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T extends DragButton> T getButton(@NotNull View root, int buttonId) {
|
||||
return (T) root.findViewById(buttonId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@ -240,7 +259,10 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
||||
}
|
||||
|
||||
for (Integer dragButtonId : dragButtonIds) {
|
||||
((DragButton) root.findViewById(dragButtonId)).setOnDragListener(onDragListener);
|
||||
final DragButton button = getButton(root, dragButtonId);
|
||||
if (button != null) {
|
||||
button.setOnDragListener(onDragListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +295,7 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
|
||||
}
|
||||
|
||||
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
||||
final View v = root.findViewById(id);
|
||||
final View v = getButton(root, id);
|
||||
if (v instanceof DirectionDragButton ) {
|
||||
final DirectionDragButton button = (DirectionDragButton)v;
|
||||
for (DragDirection dragDirection : dragDirections) {
|
||||
|
Loading…
Reference in New Issue
Block a user