calculator wiki activity

This commit is contained in:
Sergey Solovyev 2013-06-16 18:53:26 +04:00
parent 766cd0c226
commit 9083e944c8
7 changed files with 89 additions and 20 deletions

View File

@ -51,6 +51,7 @@
<activity android:label="@string/c_operators" android:name=".math.edit.CalculatorOperatorsActivity"/>
<activity android:label="@string/c_vars_and_constants" android:name=".math.edit.CalculatorVarsActivity"/>
<activity android:name=".CalculatorWikiActivity"/>
<activity android:label="@string/c_plot_graph" android:name=".plot.CalculatorPlotActivity"/>
<activity android:label="@string/cpp_plot_functions" android:launchMode="singleTop" android:name=".plot.CalculatorPlotFunctionsActivity" android:theme="@style/cpp_gray_dialog_theme"/>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical"
a:layout_width="match_parent"
a:layout_height="match_parent">
<WebView a:id="@+id/cpp_wiki_webview"
a:layout_width="match_parent"
a:layout_height="match_parent"/>
</LinearLayout>

View File

@ -11,18 +11,33 @@
a:layout_width="match_parent"
style="?cpp_fragment_list_view_item_style"
a:paddingBottom="@dimen/cpp_pane_padding"
a:orientation="horizontal">
<LinearLayout
a:layout_height="wrap_content"
a:layout_width="0dp"
a:layout_weight="1"
a:orientation="vertical">
<TextView
a:id="@+id/math_entity_text"
a:layout_height="wrap_content"
a:layout_width="match_parent"
style="@style/math_entity_text"></TextView>
style="@style/math_entity_text" />
<TextView
a:id="@+id/math_entity_description"
a:id="@+id/math_entity_short_description"
a:layout_height="wrap_content"
a:layout_width="match_parent"
style="@style/math_entity_description"></TextView>
style="@style/math_entity_description" />
</LinearLayout>
<ImageView
a:id="@+id/math_entity_description_imageview"
a:src="@drawable/wikipedia_icon"
a:scaleType="centerInside"
a:visibility="gone"
a:layout_height="match_parent"
a:layout_width="wrap_content" />
</LinearLayout>

View File

@ -12,8 +12,6 @@ import android.view.View;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import jscl.math.Generic;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.solovyev.android.Android;
import org.solovyev.android.App;
import org.solovyev.android.calculator.about.CalculatorAboutActivity;
@ -29,6 +27,8 @@ import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
/**
@ -246,6 +246,16 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
});
}
break;
case show_wiki_description:
App.getUiThreadExecutor().execute(new Runnable() {
@Override
public void run() {
final Intent intent = new Intent(context, CalculatorWikiActivity.class);
Android.addIntentFlags(intent, false, context);
context.startActivity(intent);
}
});
break;
case show_message_dialog:
final DialogData dialogData = (DialogData) data;
if (dialogData != null) {

View File

@ -0,0 +1,22 @@
package org.solovyev.android.calculator;
import android.os.Bundle;
import android.webkit.WebView;
/**
* User: serso
* Date: 6/16/13
* Time: 6:26 PM
*/
public final class CalculatorWikiActivity extends CalculatorFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cpp_wiki_page);
final WebView webView = (WebView) findViewById(R.id.cpp_wiki_webview);
//webView.loadUrl("file:///android_asset/wiki/functions/sin/index.html");
}
}

View File

@ -16,8 +16,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.actionbarsherlock.app.SherlockListFragment;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.solovyev.android.calculator.*;
import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.ContextMenuBuilder;
@ -29,10 +27,14 @@ import org.solovyev.common.filter.Filter;
import org.solovyev.common.math.MathEntity;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import static org.solovyev.android.calculator.CalculatorEventType.show_wiki_description;
/**
* User: serso
* Date: 12/21/11
@ -158,7 +160,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
this.fragmentHelper.onResume(this);
adapter = new MathEntityArrayAdapter<T>(getDescriptionGetter(), this.getActivity(), R.layout.math_entity, R.id.math_entity_text, getMathEntitiesByCategory());
adapter = new MathEntityArrayAdapter<T>(getDescriptionGetter(), this.getActivity(), getMathEntitiesByCategory());
setListAdapter(adapter);
sort();
@ -212,11 +214,8 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
private MathEntityArrayAdapter(@Nonnull MathEntityDescriptionGetter descriptionGetter,
@Nonnull Context context,
int resource,
int textViewResourceId,
@Nonnull List<T> objects) {
super(context, resource, textViewResourceId, objects);
super(context, R.layout.math_entity, R.id.math_entity_text, objects);
this.descriptionGetter = descriptionGetter;
}
@ -244,13 +243,21 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
final String mathEntityDescription = descriptionGetter.getDescription(getContext(), mathEntity.getName());
final TextView description = (TextView) result.findViewById(R.id.math_entity_description);
final TextView description = (TextView) result.findViewById(R.id.math_entity_short_description);
if (!Strings.isEmpty(mathEntityDescription)) {
description.setVisibility(View.VISIBLE);
description.setText(mathEntityDescription);
} else {
description.setVisibility(View.GONE);
}
final View descriptionButton = result.findViewById(R.id.math_entity_description_imageview);
descriptionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Locator.getInstance().getCalculator().fireCalculatorEvent(show_wiki_description, null);
}
});
}
}

View File

@ -164,6 +164,8 @@ public enum CalculatorEventType {
*/
show_message_dialog,
show_wiki_description,
plot_graph,
/**