Matrix support
This commit is contained in:
parent
08af58b18a
commit
de52ca4512
@ -37,6 +37,9 @@
|
||||
|
||||
<activity android:label="@string/c_plot_graph" android:name=".plot.CalculatorPlotActivity"/>
|
||||
|
||||
<!-- todo serso: strings-->
|
||||
<activity android:label="@string/c_plot_graph" android:name=".matrix.CalculatorMatrixActivity"/>
|
||||
|
||||
<!-- settings must use action bar icon-->
|
||||
<activity android:icon="@drawable/icon_action_bar" android:label="@string/c_settings" android:name=".plot.CalculatorPlotPreferenceActivity"/>
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
a:id="@+id/varsButton"
|
||||
c:directionTextScale="0.5"
|
||||
c:textUp="+π"
|
||||
c:textDown="+m"
|
||||
a:text="π,…"
|
||||
a:textStyle="italic"
|
||||
a:onClick="varsButtonClickHandler"
|
||||
|
35
calculatorpp/res/layout/matrix_edit_fragment.xml
Normal file
35
calculatorpp/res/layout/matrix_edit_fragment.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/main_fragment_layout"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_width="match_parent"
|
||||
style="?fragmentLayoutStyle">
|
||||
|
||||
<LinearLayout a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:gravity="center">
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"
|
||||
a:text="Rows"/>
|
||||
|
||||
<org.solovyev.android.view.Picker a:id="@+id/matrix_rows_count_picker"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"/>
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"
|
||||
a:text="Columns"/>
|
||||
|
||||
<org.solovyev.android.view.Picker a:id="@+id/matrix_cols_count_picker"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TableLayout a:id="@+id/matrix_layout"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_width="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
12
calculatorpp/res/layout/matrix_edit_fragment_item.xml
Normal file
12
calculatorpp/res/layout/matrix_edit_fragment_item.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_width="match_parent">
|
||||
|
||||
<EditText a:id="@+id/matrix_element_edittext"
|
||||
a:layout_height="match_parent"
|
||||
a:layout_width="match_parent"
|
||||
a:text="test"/>
|
||||
|
||||
</LinearLayout>
|
@ -2,6 +2,7 @@ package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -15,6 +16,7 @@ import jscl.NumeralBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.calculator.matrix.CalculatorMatrixActivity;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
||||
@ -136,6 +138,9 @@ public final class CalculatorButtons {
|
||||
if (dragDirection == DragDirection.up) {
|
||||
CalculatorActivityLauncher.createVar(context, CalculatorLocatorImpl.getInstance().getDisplay());
|
||||
result = true;
|
||||
} else if ( dragDirection == DragDirection.down ) {
|
||||
context.startActivity(new Intent(context, CalculatorMatrixActivity.class));
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -12,6 +12,7 @@ import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
|
||||
import org.solovyev.android.calculator.matrix.CalculatorMatrixEditFragment;
|
||||
import org.solovyev.android.calculator.plot.CalculatorPlotFragment;
|
||||
|
||||
/**
|
||||
@ -34,6 +35,9 @@ public enum CalculatorFragmentType {
|
||||
faq(CalculatorHelpFaqFragment.class, R.layout.help_faq_fragment, R.string.c_faq),
|
||||
hints(CalculatorHelpHintsFragment.class, R.layout.help_hints_fragment, R.string.c_hints),
|
||||
screens(CalculatorHelpScreensFragment.class, R.layout.help_screens_fragment, R.string.c_screens),
|
||||
|
||||
// todo serso: strings
|
||||
matrix_edit(CalculatorMatrixEditFragment.class, R.layout.matrix_edit_fragment, R.string.c_screens),
|
||||
release_notes(CalculatorReleaseNotesFragment.class, R.layout.release_notes_fragment, R.string.c_release_notes);
|
||||
|
||||
@NotNull
|
||||
|
@ -0,0 +1,23 @@
|
||||
package org.solovyev.android.calculator.matrix;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.os.Bundle;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentActivity;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.about.CalculatorFragmentType;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
* Date: 12.10.12
|
||||
* Time: 10:56
|
||||
*/
|
||||
public class CalculatorMatrixActivity extends CalculatorFragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
getActivityHelper().setFragment(this, CalculatorFragmentType.matrix_edit, null, R.id.main_layout);
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package org.solovyev.android.calculator.matrix;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TableLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.solovyev.android.calculator.CalculatorFragment;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.about.CalculatorFragmentType;
|
||||
import org.solovyev.android.view.IntegerRange;
|
||||
import org.solovyev.android.view.Picker;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
* Date: 12.10.12
|
||||
* Time: 10:41
|
||||
*/
|
||||
public class CalculatorMatrixEditFragment extends CalculatorFragment implements Picker.OnChangedListener<Integer> {
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* CONSTANTS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
private static final int MAX_COUNT = 10;
|
||||
private static final int MIN_COUNT = 2;
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* CONSTRUCTORS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
public CalculatorMatrixEditFragment() {
|
||||
super(CalculatorFragmentType.matrix_edit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
final Picker<Integer> matrixRowsCountPicker = (Picker<Integer>) root.findViewById(R.id.matrix_rows_count_picker);
|
||||
initPicker(matrixRowsCountPicker);
|
||||
final Picker<Integer> matrixColsCountPicker = (Picker<Integer>) root.findViewById(R.id.matrix_cols_count_picker);
|
||||
initPicker(matrixColsCountPicker);
|
||||
|
||||
getMatrixTable(root);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TableLayout getMatrixTable(@NotNull View root) {
|
||||
return (TableLayout) root.findViewById(R.id.matrix_layout);
|
||||
}
|
||||
|
||||
private void initPicker(@NotNull Picker<Integer> picker) {
|
||||
picker.setRange(new IntegerRange(MIN_COUNT, MAX_COUNT, 1, 2, null));
|
||||
picker.setOnChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChanged(@NotNull Picker picker, @NotNull Integer value) {
|
||||
switch (picker.getId()) {
|
||||
case R.id.matrix_rows_count_picker:
|
||||
onRowsCountChange(value);
|
||||
break;
|
||||
case R.id.matrix_cols_count_picker:
|
||||
onColsCountChange(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void onColsCountChange(@NotNull Integer cols) {
|
||||
final TableLayout matrixTable = getMatrixTable(getView());
|
||||
}
|
||||
|
||||
private void onRowsCountChange(@NotNull Integer rows) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user