Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
New document view, short description for each documents
Browse files Browse the repository at this point in the history
  • Loading branch information
tranleduy2000 committed Jun 30, 2019
1 parent 68ef77e commit 6998521
Show file tree
Hide file tree
Showing 56 changed files with 820 additions and 637 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android {
versionName "3.4.2-beta"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

buildTypes {
Expand Down Expand Up @@ -107,6 +108,7 @@ dependencies {
implementation 'com.github.mukeshsolanki:MarkdownView-Android:1.0.4'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.18'
implementation group: 'commons-io', name: 'commons-io', version: '2.3'


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.duy.calculator.BaseTestCase;
import com.duy.calculator.R;
import com.duy.ncalc.document.model.FunctionDocumentItem;

import org.junit.Test;

Expand All @@ -20,47 +21,47 @@
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.core.AllOf.allOf;

public class MarkdownActivityTest extends BaseTestCase {
public class MarkdownDocumentActivityTest extends BaseTestCase {

@Test
public void testOpenOpenDocument() {
onView(withContentDescription(R.string.navigation_drawer_open)).perform(click());

onView(withText("All functions")).perform(click());
onView(withText("AbsArg")).perform(click());
onView(withText("Combinatorial")).perform(click());

onView(withText("AbsArg")).check(matches(isDisplayed()));
onView(withText("Combinatorial")).check(matches(isDisplayed()));
}

@Test
public void testSearch() {
onView(withContentDescription(R.string.navigation_drawer_open)).perform(click());

onView(withText("All functions")).perform(click());
onView(withId(R.id.action_search)).perform(click());
onView(withId(R.id.searchTextView)).perform(typeText("ArcSin"));
onView(withId(R.id.edit_search_view)).perform(typeText("ArcSin"));

onView(withId(R.id.recycler_view)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
onView(withText("ArcSin")).check(matches(isDisplayed()));

pressBack();

onView(withText("Document")).check(matches(isDisplayed()));
onView(withText("Documentation")).check(matches(isDisplayed()));
}

@Test
public void testOpenDocumentationFromIDEActivity() {
onView(withContentDescription(R.string.navigation_drawer_open)).perform(click());

onView(withText("IDE mode")).perform(click());
onView(withId(R.id.btn_help)).perform(click());
onView(withId(R.id.fab_help)).perform(click());

onView(withText("Document")).check(matches(isDisplayed()));
onView(withText("Documentation")).check(matches(isDisplayed()));

pressBack();

onView(withText("IDE mode")).check(matches(isDisplayed()));
onView(allOf(isDisplayed(), withText("IDE mode"))).check(matches(isDisplayed()));
}

@Test
Expand All @@ -70,7 +71,7 @@ public void testOpenDocumentationSuggestionPopupActivity() {
onView(withText("IDE mode")).perform(click());
onView(withId(R.id.edit_input)).perform(clearText(), typeText("ArcS"));

onData(instanceOf(String.class)).inRoot(isPlatformPopup()).atPosition(0).perform(click()); //ArcSec
onData(instanceOf(FunctionDocumentItem.class)).inRoot(isPlatformPopup()).atPosition(0).perform(click()); //ArcSec
onView(withId(R.id.edit_input)).check(matches(withText("ArcSec")));

}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
android:label="@string/primitive"

android:launchMode="singleTask" />
<activity android:name="com.duy.ncalc.document.InfoActivity" />
<activity android:name="com.duy.ncalc.document.info.InfoActivity" />
<activity
android:name=".symja.activities.FactorPrimeActivity"
android:launchMode="singleTask" />
Expand All @@ -155,11 +155,11 @@
android:name=".symja.activities.NumberActivity"
android:launchMode="singleTask" />
<activity android:name=".symja.activities.PiActivity" />
<activity android:name="com.duy.ncalc.document.ListDocumentActivity" />
<activity android:name="com.duy.ncalc.document.MarkdownActivity" />
<activity android:name="com.duy.ncalc.document.MarkdownDocumentActivity" />
<activity
android:name=".symja.activities.IdeActivity"
android:label="@string/ide_mode" />
<activity android:name="com.duy.ncalc.document.MarkdownListDocumentActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -77,6 +78,28 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setFullScreen();
}

@Override
protected void onStart() {
super.onStart();
if (mCalculatorSetting != null) {
mCalculatorSetting.registerOnSharedPreferenceChangeListener(this);
}
if (!DLog.UI_TESTING_MODE) {
// Monitor launch times and interval from installation
RateThisApp.onStart(this);
// If the criteria is satisfied, "Rate this app" dialog will be shown
RateThisApp.showRateDialogIfNeeded(this);
}
}

@Override
protected void onDestroy() {
if (mCalculatorSetting != null) {
mCalculatorSetting.unregisterOnSharedPreferenceChangeListener(this);
}
super.onDestroy();
}

private void setFullScreen() {
if (mSetting.useFullScreen()) {
hideStatusBar();
Expand Down Expand Up @@ -108,26 +131,11 @@ public void hideStatusBar() {
}
}


@Override
public void onBackPressed() {
super.onBackPressed();
}

@Override
protected void onStart() {
super.onStart();
if (mCalculatorSetting != null) {
mCalculatorSetting.registerOnSharedPreferenceChangeListener(this);
}
if (!DLog.UI_TESTING_MODE) {
// Monitor launch times and interval from installation
RateThisApp.onStart(this);
// If the criteria is satisfied, "Rate this app" dialog will be shown
RateThisApp.showRateDialogIfNeeded(this);
}
}

/**
* set theme for app
*
Expand Down Expand Up @@ -164,14 +172,6 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}
}

@Override
protected void onDestroy() {
if (mCalculatorSetting != null) {
mCalculatorSetting.unregisterOnSharedPreferenceChangeListener(this);
}
super.onDestroy();
}

/**
* share app
*/
Expand Down Expand Up @@ -243,5 +243,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

/**
* Call after {@link #setContentView(int)}
*/
@SuppressWarnings("ConstantConditions")
protected void setupToolbar() {
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
import com.duy.calculator.evaluator.thread.Command;
import com.duy.calculator.history.ResultEntry;
import com.duy.calculator.symja.activities.ResultAdapter;
import com.duy.ncalc.document.MarkdownActivity;
import com.duy.ncalc.document.FunctionSuggestionAdapter;
import com.duy.ncalc.document.MarkdownDocumentActivity;
import com.duy.ncalc.document.model.FunctionDocumentItem;
import com.duy.ncalc.view.ResizingEditText;
import com.duy.ncalc.view.editor.SuggestAdapter;

import org.matheclipse.parser.client.SyntaxError;
import org.matheclipse.parser.client.math.MathException;
Expand All @@ -61,7 +62,7 @@
* Created by Duy on 19/7/2016
*/
public abstract class BaseEvaluatorActivity extends NavDrawerActivity
implements View.OnClickListener, SuggestAdapter.OnSuggestionListener {
implements View.OnClickListener, FunctionSuggestionAdapter.OnSuggestionClickListener {
protected String TAG = BaseEvaluatorActivity.class.getName();

/*Limit, integrate, derivative*/
Expand Down Expand Up @@ -125,7 +126,7 @@ protected void onPause() {
private void initView() {
mBtnEvaluate = findViewById(R.id.btn_solve);
mInputFormula = findViewById(R.id.edit_input);
mInputFormula.setOnHelpListener(this);
mInputFormula.setOnSuggestionClickListener(this);

mProgress = findViewById(R.id.progress_bar);
mSpinner = findViewById(R.id.spinner);
Expand Down Expand Up @@ -276,10 +277,11 @@ protected String getExpression() {
public abstract void clickHelp();

@Override
public void clickOpenDocument(String functionName) {
MarkdownActivity.open(this, functionName);
public void clickOpenDocument(FunctionDocumentItem functionDocumentItem) {
MarkdownDocumentActivity.open(this, functionDocumentItem);
}


@Nullable
public abstract Command<ArrayList<String>, String> getCommand();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@
import com.duy.calculator.symja.activities.TrigActivity;
import com.duy.ncalc.calculator.BasicCalculatorActivity;
import com.duy.ncalc.calculator.LogicCalculatorActivity;
import com.duy.ncalc.document.InfoActivity;
import com.duy.ncalc.document.ListDocumentActivity;
import com.duy.ncalc.document.ListDocumentFragment;
import com.duy.ncalc.document.MarkdownListDocumentActivity;
import com.duy.ncalc.document.info.InfoActivity;
import com.duy.ncalc.geom2d.GeometryDescartesActivity;
import com.duy.ncalc.graph.GraphActivity;
import com.duy.ncalc.matrix.MatrixCalculatorActivity;
Expand Down Expand Up @@ -109,7 +108,7 @@ private void setupHeaderNavigation(NavigationView navigationView) {
@Override
public void onClick(View v) {
closeDrawer();
startActivity(new Intent(getApplicationContext(), ListDocumentActivity.class));
startActivity(new Intent(getApplicationContext(), MarkdownListDocumentActivity.class));
}
});
header.findViewById(R.id.img_setting).setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -146,15 +145,8 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
closeDrawer();
Intent intent;
switch (id) {
case R.id.action_getting_started: {
intent = new Intent(getApplicationContext(), ListDocumentActivity.class);
intent.putExtra(ListDocumentFragment.KEY_ASSET_PATH, "doc");
startActivity(intent);
break;
}
case R.id.action_all_functions: {
intent = new Intent(getApplicationContext(), ListDocumentActivity.class);
intent.putExtra(ListDocumentFragment.KEY_ASSET_PATH, "doc/functions");
intent = new Intent(getApplicationContext(), MarkdownListDocumentActivity.class);
startActivity(intent);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import com.duy.calculator.evaluator.EvaluateConfig;
import com.duy.calculator.evaluator.MathEvaluator;
import com.duy.calculator.evaluator.thread.Command;
import com.duy.ncalc.document.ListDocumentActivity;
import com.duy.ncalc.document.ListDocumentFragment;
import com.duy.ncalc.document.MarkdownListDocumentActivity;
import com.gx.common.collect.Lists;

import java.util.ArrayList;
Expand All @@ -25,8 +24,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

@Override
public void clickHelp() {
Intent intent = new Intent(this, ListDocumentActivity.class);
intent.putExtra(ListDocumentFragment.KEY_ASSET_PATH, "doc");
Intent intent = new Intent(this, MarkdownListDocumentActivity.class);
startActivity(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import com.duy.calculator.evaluator.MathEvaluator;
import com.duy.calculator.evaluator.thread.Command;
import com.duy.calculator.symja.models.NumberIntegerItem;
import com.duy.ncalc.document.MarkdownActivity;
import com.duy.ncalc.document.MarkdownDocumentActivity;
import com.duy.ncalc.document.model.FunctionDocumentItem;
import com.gx.common.collect.Lists;

import java.util.ArrayList;
Expand Down Expand Up @@ -129,7 +130,7 @@ public void clickHelp() {
function = "";
break;
}
MarkdownActivity.open(this, function);
MarkdownDocumentActivity.open(this, new FunctionDocumentItem("doc/functions/" + function, function, ""));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
import android.widget.Button;

import com.duy.calculator.R;
import com.duy.ncalc.document.MarkdownListDocumentFragment;
import com.duy.ncalc.settings.SettingsActivity;
import com.duy.ncalc.view.ButtonID;
import com.duy.ncalc.view.CalcButton;
import com.duy.ncalc.view.CalculatorEditText;
import com.duy.ncalc.document.ListDocumentActivity;
import com.duy.ncalc.document.ListDocumentFragment;

/**
* Created by Duy on 9/21/2017.
Expand Down Expand Up @@ -131,8 +130,7 @@ public void onClick(View view) {
mCalculatorListener.clickFactorPrime();
break;
case R.id.btn_help: {
Intent intent = new Intent(getContext(), ListDocumentActivity.class);
intent.putExtra(ListDocumentFragment.KEY_ASSET_PATH, "doc");
Intent intent = new Intent(getContext(), MarkdownListDocumentFragment.class);
startActivity(intent);
}
case R.id.btn_solve_:
Expand Down
Loading

0 comments on commit 6998521

Please sign in to comment.