FAB for variables and functions view
This commit is contained in:
parent
c151b6573d
commit
77e1570088
@ -26,25 +26,21 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.text.ClipboardManager;
|
||||
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import android.text.ClipboardManager;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import jscl.math.function.Function;
|
||||
import jscl.math.function.IFunction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
|
||||
import org.solovyev.android.menu.AMenuItem;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -70,7 +66,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
|
||||
if (bundle != null) {
|
||||
final Parcelable parcelable = bundle.getParcelable(CREATE_FUNCTION_EXTRA);
|
||||
if (parcelable instanceof FunctionEditDialogFragment.Input) {
|
||||
FunctionEditDialogFragment.showDialog((FunctionEditDialogFragment.Input) parcelable, this.getActivity().getSupportFragmentManager());
|
||||
FunctionEditDialogFragment.showDialog((FunctionEditDialogFragment.Input) parcelable, getFragmentManager());
|
||||
|
||||
// in order to stop intent for other tabs
|
||||
bundle.remove(CREATE_FUNCTION_EXTRA);
|
||||
@ -81,6 +77,22 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
final ListView lv = getListView();
|
||||
final FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
fab.attachToListView(lv);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newInstance(), getFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AMenuItem<Function> getOnClickAction() {
|
||||
return LongClickMenuItem.use;
|
||||
@ -201,36 +213,6 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* MENU
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.functions_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean result;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_functions_add_function:
|
||||
FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newInstance(), this.getActivity().getSupportFragmentManager());
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
result = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
|
@ -24,11 +24,10 @@ package org.solovyev.android.calculator.math.edit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import jscl.math.function.IConstant;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
@ -65,7 +64,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
if (bundle != null) {
|
||||
final String varValue = bundle.getString(CREATE_VAR_EXTRA_STRING);
|
||||
if (!Strings.isEmpty(varValue)) {
|
||||
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromValue(varValue), this.getActivity().getSupportFragmentManager());
|
||||
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromValue(varValue), getFragmentManager());
|
||||
|
||||
// in order to stop intent for other tabs
|
||||
bundle.remove(CREATE_VAR_EXTRA_STRING);
|
||||
@ -75,6 +74,22 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
final ListView lv = getListView();
|
||||
final FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
fab.attachToListView(lv);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newInstance(), getFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AMenuItem<IConstant> getOnClickAction() {
|
||||
return LongClickMenuItem.use;
|
||||
@ -144,35 +159,6 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* MENU
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.vars_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean result;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_vars_add_var:
|
||||
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newInstance(), this.getActivity().getSupportFragmentManager());
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
result = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
||||
super.onCalculatorEvent(calculatorEventData, calculatorEventType, data);
|
||||
|
BIN
android-app/src/main/res/drawable-hdpi/ic_add_white_36dp.png
Normal file
BIN
android-app/src/main/res/drawable-hdpi/ic_add_white_36dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 250 B |
BIN
android-app/src/main/res/drawable-mdpi/ic_add_white_36dp.png
Normal file
BIN
android-app/src/main/res/drawable-mdpi/ic_add_white_36dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 223 B |
BIN
android-app/src/main/res/drawable-xhdpi/ic_add_white_36dp.png
Normal file
BIN
android-app/src/main/res/drawable-xhdpi/ic_add_white_36dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 222 B |
BIN
android-app/src/main/res/drawable-xxhdpi/ic_add_white_36dp.png
Normal file
BIN
android-app/src/main/res/drawable-xxhdpi/ic_add_white_36dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
@ -22,18 +22,18 @@
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||
<LinearLayout
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?cpp_fragment_layout_style"
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
a:id="@+id/fragment_title"
|
||||
a:layout_height="wrap_content"
|
||||
style="?cpp_fragment_title_style"
|
||||
a:layout_width="match_parent"
|
||||
style="?cpp_fragment_title_style" />
|
||||
a:layout_height="wrap_content" />
|
||||
|
||||
<include layout="@layout/ad" />
|
||||
|
||||
@ -45,13 +45,7 @@
|
||||
|
||||
<com.melnykov.fab.FloatingActionButton
|
||||
a:id="@+id/fab"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_gravity="bottom|right"
|
||||
a:layout_margin="16dp"
|
||||
a:src="@drawable/ic_delete_white_36dp"
|
||||
fab:fab_colorNormal="@color/cpp_metro_button"
|
||||
fab:fab_colorPressed="@color/cpp_metro_button"
|
||||
fab:fab_colorRipple="?attr/colorControlHighlight" />
|
||||
style="@style/Fab"
|
||||
a:src="@drawable/ic_delete_white_36dp" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
@ -22,20 +22,31 @@
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?cpp_fragment_layout_style"
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
a:id="@+id/fragment_title"
|
||||
a:layout_height="wrap_content"
|
||||
style="?cpp_fragment_title_style"
|
||||
a:layout_width="match_parent"
|
||||
style="?cpp_fragment_title_style"/>
|
||||
a:layout_height="wrap_content" />
|
||||
|
||||
<include layout="@layout/ad" />
|
||||
|
||||
<FrameLayout
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<ListView style="@style/ListView" />
|
||||
|
||||
<com.melnykov.fab.FloatingActionButton
|
||||
a:id="@+id/fab"
|
||||
style="@style/Fab"
|
||||
a:src="@drawable/ic_add_white_36dp"
|
||||
a:visibility="gone" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
@ -22,20 +22,31 @@
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="?cpp_fragment_layout_style"
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
a:id="@+id/fragment_title"
|
||||
a:layout_height="wrap_content"
|
||||
style="?cpp_fragment_title_style"
|
||||
a:layout_width="match_parent"
|
||||
style="?cpp_fragment_title_style"/>
|
||||
a:layout_height="wrap_content" />
|
||||
|
||||
<include layout="@layout/ad" />
|
||||
|
||||
<FrameLayout
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent">
|
||||
|
||||
<ListView style="@style/ListView" />
|
||||
|
||||
<com.melnykov.fab.FloatingActionButton
|
||||
a:id="@+id/fab"
|
||||
style="@style/Fab"
|
||||
a:src="@drawable/ic_add_white_36dp" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2013 serso aka se.solovyev
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Contact details
|
||||
~
|
||||
~ Email: se.solovyev@gmail.com
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<menu xmlns:a="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
a:id="@+id/menu_functions_add_function"
|
||||
a:title="@string/c_add"
|
||||
a:icon="@drawable/ab_plus"
|
||||
a:showAsAction="always"/>
|
||||
</menu>
|
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2013 serso aka se.solovyev
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Contact details
|
||||
~
|
||||
~ Email: se.solovyev@gmail.com
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<menu xmlns:a="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
a:id="@+id/menu_vars_add_var"
|
||||
a:title="@string/c_add"
|
||||
a:icon="@drawable/ab_plus"
|
||||
a:showAsAction="always"/>
|
||||
</menu>
|
@ -58,6 +58,16 @@
|
||||
<item name="android:gravity">center_vertical|left</item>
|
||||
</style>
|
||||
|
||||
<style name="Fab">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_gravity">bottom|end</item>
|
||||
<item name="android:layout_margin">16dp</item>
|
||||
<item name="fab_colorNormal">@color/cpp_metro_button</item>
|
||||
<item name="fab_colorPressed">@color/cpp_metro_button</item>
|
||||
<item name="fab_colorRipple">?attr/colorControlHighlight</item>
|
||||
</style>
|
||||
|
||||
<style name="ListView">
|
||||
<item name="android:id">@android:id/list</item>
|
||||
<item name="android:dividerHeight">1px</item>
|
||||
|
Loading…
Reference in New Issue
Block a user