This commit is contained in:
Sergey Solovyev 2012-12-01 21:51:40 +04:00
parent c0e57175c8
commit 87254f5335
6 changed files with 45 additions and 9 deletions

View File

@ -2,7 +2,6 @@ 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;
@ -18,7 +17,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.core.R;
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;
@ -138,7 +136,7 @@ public final class CalculatorButtons {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_create_var_dialog, null);
result = true;
} else if ( dragDirection == DragDirection.down ) {
context.startActivity(new Intent(context, CalculatorMatrixActivity.class));
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_create_matrix_dialog, null);
result = true;
}

View File

@ -4,14 +4,14 @@
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:picker="http://schemas.android.com/apk/res-auto"
a:id="@+id/main_fragment_layout"
style="?fragmentLayoutStyle"
style="?cpp_fragment_layout_style"
a:layout_width="match_parent"
a:layout_height="match_parent">
<TextView a:id="@+id/fragmentTitle"
a:layout_height="wrap_content"
a:layout_width="match_parent"
style="?fragmentTitleStyle"/>
style="?cpp_fragment_title_style"/>
<include layout="@layout/ad"/>

View File

@ -2,6 +2,7 @@ package org.solovyev.android.calculator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -21,6 +22,7 @@ import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
import org.solovyev.android.calculator.help.CalculatorHelpActivity;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
import org.solovyev.android.calculator.math.edit.*;
import org.solovyev.android.calculator.matrix.CalculatorMatrixActivity;
import org.solovyev.android.calculator.plot.CalculatorPlotActivity;
import org.solovyev.android.calculator.plot.CalculatorPlotFragment;
import org.solovyev.android.calculator.plot.PlotInput;
@ -113,6 +115,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
intent.putExtra(ChartFactory.TITLE, context.getString(R.string.c_graph));
intent.putExtra(CalculatorPlotFragment.INPUT, new CalculatorPlotFragment.Input(generic.toString(), constant.getName()));
intent.setClass(context, CalculatorPlotActivity.class);
addFlags(intent, false);
context.startActivity(intent);
}
@ -127,6 +130,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} else {
final Intent intent = new Intent(context, CalculatorVarsActivity.class);
intent.putExtra(CalculatorVarsFragment.CREATE_VAR_EXTRA_STRING, varValue);
addFlags(intent, false);
context.startActivity(intent);
}
} else {
@ -179,12 +183,24 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
@Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
final Application application = App.getInstance().getApplication();
switch (calculatorEventType){
case show_create_matrix_dialog:
App.getInstance().getUiThreadExecutor().execute(new Runnable() {
@Override
public void run() {
final Intent intent = new Intent(application, CalculatorMatrixActivity.class);
addFlags(intent, false);
application.startActivity(intent);
}
});
break;
case show_create_var_dialog:
App.getInstance().getUiThreadExecutor().execute(new Runnable() {
@Override
public void run() {
CalculatorActivityLauncher.createVar(App.getInstance().getApplication(), Locator.getInstance().getDisplay());
CalculatorActivityLauncher.createVar(application, Locator.getInstance().getDisplay());
}
});
break;
@ -192,7 +208,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
App.getInstance().getUiThreadExecutor().execute(new Runnable() {
@Override
public void run() {
CalculatorActivityLauncher.createFunction(App.getInstance().getApplication(), Locator.getInstance().getDisplay());
CalculatorActivityLauncher.createFunction(application, Locator.getInstance().getDisplay());
}
});
break;
@ -202,7 +218,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
App.getInstance().getUiThreadExecutor().execute(new Runnable() {
@Override
public void run() {
plotGraph(App.getInstance().getApplication(), plotInput.getFunction(), plotInput.getConstant());
plotGraph(application, plotInput.getFunction(), plotInput.getConstant());
}
});
break;
@ -212,7 +228,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
App.getInstance().getUiThreadExecutor().execute(new Runnable() {
@Override
public void run() {
showEvaluationError(App.getInstance().getApplication(), errorMessage);
showEvaluationError(application, errorMessage);
}
});
}

View File

@ -17,6 +17,9 @@ import org.solovyev.android.calculator.external.AndroidExternalListenersContaine
import org.solovyev.android.calculator.history.AndroidCalculatorHistory;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import java.util.ArrayList;
import java.util.List;
/**
* User: serso
* Date: 12/1/11
@ -50,6 +53,17 @@ public class CalculatorApplication extends android.app.Application {
@NotNull
private static CalculatorApplication instance;
/*
**********************************************************************
*
* FIELDS
*
**********************************************************************
*/
private final List<CalculatorEventListener> listeners = new ArrayList<CalculatorEventListener>();
/*
**********************************************************************
*
@ -133,6 +147,12 @@ public class CalculatorApplication extends android.app.Application {
}
}).start();
listeners.add(new CalculatorActivityLauncher());
for (CalculatorEventListener listener : listeners) {
calculator.addCalculatorEventListener(listener);
}
Locator.getInstance().getLogger().debug(TAG, "Application started!");
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!");
}

View File

@ -167,6 +167,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
FunctionEditDialogFragment.showDialog(input, ((SherlockFragmentActivity) context).getSupportFragmentManager());
} else {
final Intent intent = new Intent(context, CalculatorFunctionsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(CalculatorFunctionsFragment.CREATE_FUNCTION_EXTRA, input);
context.startActivity(intent);
}

View File

@ -156,6 +156,7 @@ public enum CalculatorEventType {
show_like_dialog,
show_create_var_dialog,
show_create_matrix_dialog,
show_create_function_dialog,
//org.solovyev.android.calculator.plot.PlotInput