GA integration + Base activity
This commit is contained in:
parent
c30645e5c7
commit
d23f8e2c40
@ -1,10 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
|
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
|
||||||
<file url="file://$PROJECT_DIR$/android-app-core-tests/build.gradle" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/android-app-core/src/main/java/org/solovyev/android/calculator/App.java" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/android-app-core/src/main/java/org/solovyev/android/calculator/ServiceLocator.java" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/android-app-tests/build.gradle" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/android-app-tests/build.gradle" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/android-app-tests/src/test/java/org/solovyev/android/CalculatorTestRunner.java" charset="UTF-8" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -45,12 +45,7 @@ import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
public class ActivityUi extends BaseUi {
|
||||||
* User: serso
|
|
||||||
* Date: 9/25/12
|
|
||||||
* Time: 10:32 PM
|
|
||||||
*/
|
|
||||||
public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper implements CalculatorActivityHelper {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@ -80,18 +75,18 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
|
|
||||||
private int selectedNavigationIndex = 0;
|
private int selectedNavigationIndex = 0;
|
||||||
|
|
||||||
public CalculatorActivityHelperImpl(int layoutId, @Nonnull String logTag) {
|
public ActivityUi(int layoutId, @Nonnull String logTag) {
|
||||||
super(logTag);
|
super(logTag);
|
||||||
this.layoutId = layoutId;
|
this.layoutId = layoutId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculatorActivityHelperImpl(int layoutId, boolean homeIcon) {
|
public ActivityUi(int layoutId, boolean homeIcon) {
|
||||||
this.layoutId = layoutId;
|
this.layoutId = layoutId;
|
||||||
this.homeIcon = homeIcon;
|
this.homeIcon = homeIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nonnull Activity activity, @Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nonnull Activity activity) {
|
||||||
super.onCreate(activity);
|
super.onCreate(activity);
|
||||||
|
|
||||||
if (activity instanceof CalculatorEventListener) {
|
if (activity instanceof CalculatorEventListener) {
|
||||||
@ -112,13 +107,12 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
processButtons(activity, root);
|
processButtons(activity, root);
|
||||||
addHelpInfo(activity, root);
|
addHelpInfo(activity, root);
|
||||||
} else {
|
} else {
|
||||||
Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
|
Log.e(ActivityUi.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onCreate(@Nonnull final SherlockFragmentActivity activity) {
|
||||||
public void onCreate(@Nonnull final SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState) {
|
onCreate((Activity)activity);
|
||||||
this.onCreate((Activity) activity, savedInstanceState);
|
|
||||||
|
|
||||||
final ActionBar actionBar = activity.getSupportActionBar();
|
final ActionBar actionBar = activity.getSupportActionBar();
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
actionBar.setDisplayUseLogoEnabled(false);
|
||||||
@ -153,16 +147,13 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(@Nonnull SherlockFragmentActivity activity, @Nonnull Bundle outState) {
|
public void onSaveInstanceState(@Nonnull SherlockFragmentActivity activity, @Nonnull Bundle outState) {
|
||||||
onSaveInstanceState((Activity) activity, outState);
|
onSaveInstanceState((Activity) activity, outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(@Nonnull Activity activity, @Nonnull Bundle outState) {
|
public void onSaveInstanceState(@Nonnull Activity activity, @Nonnull Bundle outState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume(@Nonnull Activity activity) {
|
public void onResume(@Nonnull Activity activity) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
@ -172,11 +163,9 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause(@Nonnull Activity activity) {
|
public void onPause(@Nonnull Activity activity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause(@Nonnull SherlockFragmentActivity activity) {
|
public void onPause(@Nonnull SherlockFragmentActivity activity) {
|
||||||
onPause((Activity) activity);
|
onPause((Activity) activity);
|
||||||
|
|
||||||
@ -204,12 +193,10 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy(@Nonnull SherlockFragmentActivity activity) {
|
public void onDestroy(@Nonnull SherlockFragmentActivity activity) {
|
||||||
this.onDestroy((Activity) activity);
|
this.onDestroy((Activity) activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTab(@Nonnull SherlockFragmentActivity activity,
|
public void addTab(@Nonnull SherlockFragmentActivity activity,
|
||||||
@Nonnull String tag,
|
@Nonnull String tag,
|
||||||
@Nonnull Class<? extends Fragment> fragmentClass,
|
@Nonnull Class<? extends Fragment> fragmentClass,
|
||||||
@ -227,12 +214,10 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
actionBar.addTab(tab);
|
actionBar.addTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
|
public void addTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
|
||||||
addTab(activity, fragmentType.getFragmentTag(), fragmentType.getFragmentClass(), fragmentArgs, fragmentType.getDefaultTitleResId(), parentViewId);
|
addTab(activity, fragmentType.getFragmentTag(), fragmentType.getFragmentClass(), fragmentArgs, fragmentType.getDefaultTitleResId(), parentViewId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFragment(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
|
public void setFragment(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
|
||||||
final FragmentManager fm = activity.getSupportFragmentManager();
|
final FragmentManager fm = activity.getSupportFragmentManager();
|
||||||
|
|
||||||
@ -252,7 +237,6 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType) {
|
public void selectTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType) {
|
||||||
final ActionBar actionBar = activity.getSupportActionBar();
|
final ActionBar actionBar = activity.getSupportActionBar();
|
||||||
for (int i = 0; i < actionBar.getTabCount(); i++) {
|
for (int i = 0; i < actionBar.getTabCount(); i++) {
|
||||||
@ -264,24 +248,20 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutId() {
|
public int getLayoutId() {
|
||||||
return layoutId;
|
return layoutId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorPreferences.Gui.Theme getTheme() {
|
public CalculatorPreferences.Gui.Theme getTheme() {
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorPreferences.Gui.Layout getLayout() {
|
public CalculatorPreferences.Gui.Layout getLayout() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume(@Nonnull SherlockFragmentActivity activity) {
|
public void onResume(@Nonnull SherlockFragmentActivity activity) {
|
||||||
onResume((Activity) activity);
|
onResume((Activity) activity);
|
||||||
|
|
||||||
@ -346,4 +326,12 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onStop(@Nonnull Activity activity) {
|
||||||
|
App.getGa().getAnalytics().reportActivityStop(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStart(@Nonnull Activity activity) {
|
||||||
|
App.getGa().getAnalytics().reportActivityStart(activity);
|
||||||
|
}
|
||||||
}
|
}
|
@ -24,6 +24,7 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import org.solovyev.android.UiThreadExecutor;
|
import org.solovyev.android.UiThreadExecutor;
|
||||||
|
import org.solovyev.android.calculator.ga.Ga;
|
||||||
import org.solovyev.common.listeners.JEvent;
|
import org.solovyev.common.listeners.JEvent;
|
||||||
import org.solovyev.common.listeners.JEventListener;
|
import org.solovyev.common.listeners.JEventListener;
|
||||||
import org.solovyev.common.listeners.JEventListeners;
|
import org.solovyev.common.listeners.JEventListeners;
|
||||||
@ -72,6 +73,9 @@ public final class App {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private static CalculatorBroadcaster broadcaster;
|
private static CalculatorBroadcaster broadcaster;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private static volatile Ga ga;
|
||||||
|
|
||||||
private App() {
|
private App() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
@ -100,6 +104,7 @@ public final class App {
|
|||||||
App.application = application;
|
App.application = application;
|
||||||
App.uiThreadExecutor = uiThreadExecutor;
|
App.uiThreadExecutor = uiThreadExecutor;
|
||||||
App.eventBus = eventBus;
|
App.eventBus = eventBus;
|
||||||
|
App.ga = new Ga(application, eventBus);
|
||||||
if (serviceLocator != null) {
|
if (serviceLocator != null) {
|
||||||
App.locator = serviceLocator;
|
App.locator = serviceLocator;
|
||||||
} else {
|
} else {
|
||||||
@ -138,16 +143,6 @@ public final class App {
|
|||||||
return (A) application;
|
return (A) application;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <L> real type of service locator
|
|
||||||
* @return instance of service locator user in application
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
public static <L extends ServiceLocator> L getLocator() {
|
|
||||||
checkInit();
|
|
||||||
return (L) locator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method returns executor which runs on Main Application's thread. It's safe to do all UI work on this executor
|
* Method returns executor which runs on Main Application's thread. It's safe to do all UI work on this executor
|
||||||
*
|
*
|
||||||
@ -172,4 +167,9 @@ public final class App {
|
|||||||
public static CalculatorBroadcaster getBroadcaster() {
|
public static CalculatorBroadcaster getBroadcaster() {
|
||||||
return broadcaster;
|
return broadcaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Ga getGa() {
|
||||||
|
return ga;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.LayoutRes;
|
||||||
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class BaseActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
protected final ActivityUi ui;
|
||||||
|
|
||||||
|
public BaseActivity(@Nonnull ActivityUi ui) {
|
||||||
|
this.ui = ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseActivity(@LayoutRes int layout) {
|
||||||
|
this(layout, "Activity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseActivity(@LayoutRes int layout, @Nonnull String logTag) {
|
||||||
|
this.ui = CalculatorApplication.getInstance().createActivityHelper(layout, logTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public ActivityUi getUi() {
|
||||||
|
return ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
ui.onCreate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
ui.onSaveInstanceState(this, outState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
ui.onStart(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
ui.onStop(this);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
ui.onResume(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
this.ui.onPause(this);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
ui.onDestroy(this);
|
||||||
|
}
|
||||||
|
}
|
@ -62,7 +62,7 @@ import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Pref
|
|||||||
* Date: 9/28/12
|
* Date: 9/28/12
|
||||||
* Time: 12:12 AM
|
* Time: 12:12 AM
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static final List<Integer> viewIds = new ArrayList<Integer>(200);
|
private static final List<Integer> viewIds = new ArrayList<Integer>(200);
|
||||||
@ -88,10 +88,10 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
|||||||
@Nullable
|
@Nullable
|
||||||
private NumeralBasesButton clearButton;
|
private NumeralBasesButton clearButton;
|
||||||
|
|
||||||
protected AbstractCalculatorHelper() {
|
protected BaseUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractCalculatorHelper(@Nonnull String logTag) {
|
protected BaseUi(@Nonnull String logTag) {
|
||||||
this.logTag = logTag;
|
this.logTag = logTag;
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
private boolean useBackAsPrev;
|
private boolean useBackAsPrev;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorActivityHelper activityHelper;
|
private ActivityUi activityUi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the activity is first created.
|
* Called when the activity is first created.
|
||||||
@ -81,20 +81,20 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
|
|
||||||
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
||||||
|
|
||||||
activityHelper = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
|
activityUi = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
|
||||||
activityHelper.logDebug("onCreate");
|
activityUi.logDebug("onCreate");
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
activityUi.onCreate(this);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
activityHelper.logDebug("super.onCreate");
|
activityUi.logDebug("super.onCreate");
|
||||||
|
|
||||||
if (isMultiPane()) {
|
if (isMultiPane()) {
|
||||||
activityHelper.addTab(this, CalculatorFragmentType.history, null, R.id.main_second_pane);
|
activityUi.addTab(this, CalculatorFragmentType.history, null, R.id.main_second_pane);
|
||||||
activityHelper.addTab(this, CalculatorFragmentType.saved_history, null, R.id.main_second_pane);
|
activityUi.addTab(this, CalculatorFragmentType.saved_history, null, R.id.main_second_pane);
|
||||||
activityHelper.addTab(this, CalculatorFragmentType.variables, null, R.id.main_second_pane);
|
activityUi.addTab(this, CalculatorFragmentType.variables, null, R.id.main_second_pane);
|
||||||
activityHelper.addTab(this, CalculatorFragmentType.functions, null, R.id.main_second_pane);
|
activityUi.addTab(this, CalculatorFragmentType.functions, null, R.id.main_second_pane);
|
||||||
activityHelper.addTab(this, CalculatorFragmentType.operators, null, R.id.main_second_pane);
|
activityUi.addTab(this, CalculatorFragmentType.operators, null, R.id.main_second_pane);
|
||||||
activityHelper.addTab(this, CalculatorPlotActivity.getPlotterFragmentType(), null, R.id.main_second_pane);
|
activityUi.addTab(this, CalculatorPlotActivity.getPlotterFragmentType(), null, R.id.main_second_pane);
|
||||||
} else {
|
} else {
|
||||||
final ActionBar actionBar = getSupportActionBar();
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
if (Build.VERSION.SDK_INT <= GINGERBREAD_MR1 || (Build.VERSION.SDK_INT >= ICE_CREAM_SANDWICH && hasPermanentMenuKey())) {
|
if (Build.VERSION.SDK_INT <= GINGERBREAD_MR1 || (Build.VERSION.SDK_INT >= ICE_CREAM_SANDWICH && hasPermanentMenuKey())) {
|
||||||
@ -127,6 +127,18 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
activityUi.onStart(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
activityUi.onStop(this);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||||
private boolean hasPermanentMenuKey() {
|
private boolean hasPermanentMenuKey() {
|
||||||
return ViewConfiguration.get(this).hasPermanentMenuKey();
|
return ViewConfiguration.get(this).hasPermanentMenuKey();
|
||||||
@ -232,7 +244,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
this.activityHelper.onPause(this);
|
this.activityUi.onPause(this);
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
@ -243,7 +255,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
|
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
|
||||||
if (newLayout != activityHelper.getLayout()) {
|
if (newLayout != activityUi.getLayout()) {
|
||||||
Activities.restartActivity(this);
|
Activities.restartActivity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,12 +266,12 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
window.clearFlags(FLAG_KEEP_SCREEN_ON);
|
window.clearFlags(FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activityHelper.onResume(this);
|
this.activityUi.onResume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
activityHelper.onDestroy(this);
|
activityUi.onDestroy(this);
|
||||||
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
|
PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
@ -281,7 +293,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
activityUi.onSaveInstanceState(this, outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
||||||
@ -391,7 +403,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
// do nothing - fragment shown and already registered for plot updates
|
// do nothing - fragment shown and already registered for plot updates
|
||||||
} else {
|
} else {
|
||||||
// otherwise - open fragment
|
// otherwise - open fragment
|
||||||
activityHelper.selectTab(CalculatorActivity.this, CalculatorFragmentType.plotter);
|
activityUi.selectTab(CalculatorActivity.this, CalculatorFragmentType.plotter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// start new activity
|
// start new activity
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 9/25/12
|
|
||||||
* Time: 10:31 PM
|
|
||||||
*/
|
|
||||||
public interface CalculatorActivityHelper {
|
|
||||||
|
|
||||||
void onCreate(@Nonnull SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState);
|
|
||||||
|
|
||||||
void onCreate(@Nonnull Activity activity, @Nullable Bundle savedInstanceState);
|
|
||||||
|
|
||||||
void onSaveInstanceState(@Nonnull SherlockFragmentActivity activity, @Nonnull Bundle outState);
|
|
||||||
|
|
||||||
void onSaveInstanceState(@Nonnull Activity activity, @Nonnull Bundle outState);
|
|
||||||
|
|
||||||
int getLayoutId();
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
CalculatorPreferences.Gui.Theme getTheme();
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
CalculatorPreferences.Gui.Layout getLayout();
|
|
||||||
|
|
||||||
void onResume(@Nonnull SherlockFragmentActivity activity);
|
|
||||||
|
|
||||||
void onResume(@Nonnull Activity activity);
|
|
||||||
|
|
||||||
void onPause(@Nonnull Activity activity);
|
|
||||||
|
|
||||||
void onPause(@Nonnull SherlockFragmentActivity activity);
|
|
||||||
|
|
||||||
void onDestroy(@Nonnull SherlockFragmentActivity activity);
|
|
||||||
|
|
||||||
void onDestroy(@Nonnull Activity activity);
|
|
||||||
|
|
||||||
void addTab(@Nonnull SherlockFragmentActivity activity,
|
|
||||||
@Nonnull String tag,
|
|
||||||
@Nonnull Class<? extends Fragment> fragmentClass,
|
|
||||||
@Nullable Bundle fragmentArgs,
|
|
||||||
int captionResId,
|
|
||||||
int parentViewId);
|
|
||||||
|
|
||||||
void addTab(@Nonnull SherlockFragmentActivity activity,
|
|
||||||
@Nonnull CalculatorFragmentType fragmentType,
|
|
||||||
@Nullable Bundle fragmentArgs,
|
|
||||||
int parentViewId);
|
|
||||||
|
|
||||||
void setFragment(@Nonnull SherlockFragmentActivity activity,
|
|
||||||
@Nonnull CalculatorFragmentType fragmentType,
|
|
||||||
@Nullable Bundle fragmentArgs,
|
|
||||||
int parentViewId);
|
|
||||||
|
|
||||||
|
|
||||||
void logDebug(@Nonnull String message);
|
|
||||||
|
|
||||||
void processButtons(@Nonnull Activity activity, @Nonnull View root);
|
|
||||||
|
|
||||||
void logError(@Nonnull String message);
|
|
||||||
|
|
||||||
void selectTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType);
|
|
||||||
}
|
|
@ -226,23 +226,23 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorActivityHelper createActivityHelper(int layoutResId, @Nonnull String logTag) {
|
public ActivityUi createActivityHelper(int layoutResId, @Nonnull String logTag) {
|
||||||
return new CalculatorActivityHelperImpl(layoutResId, logTag);
|
return new ActivityUi(layoutResId, logTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorFragmentHelper createFragmentHelper(int layoutId) {
|
public FragmentUi createFragmentHelper(int layoutId) {
|
||||||
return new CalculatorFragmentHelperImpl(layoutId);
|
return new FragmentUi(layoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId) {
|
public FragmentUi createFragmentHelper(int layoutId, int titleResId) {
|
||||||
return new CalculatorFragmentHelperImpl(layoutId, titleResId);
|
return new FragmentUi(layoutId, titleResId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) {
|
public FragmentUi createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) {
|
||||||
return new CalculatorFragmentHelperImpl(layoutId, titleResId, listenersOnCreate);
|
return new FragmentUi(layoutId, titleResId, listenersOnCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -41,7 +41,7 @@ import javax.annotation.Nonnull;
|
|||||||
public class CalculatorDisplayFragment extends SherlockFragment {
|
public class CalculatorDisplayFragment extends SherlockFragment {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorFragmentHelper fragmentHelper;
|
private FragmentUi fragmentHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -49,7 +49,7 @@ import org.solovyev.android.sherlock.menu.SherlockMenuHelper;
|
|||||||
public class CalculatorEditorFragment extends SherlockFragment {
|
public class CalculatorEditorFragment extends SherlockFragment {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorFragmentHelper fragmentHelper;
|
private FragmentUi fragmentHelper;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromEnum(CalculatorMenu.class, SherlockMenuHelper.getInstance());
|
private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromEnum(CalculatorMenu.class, SherlockMenuHelper.getInstance());
|
||||||
|
@ -40,7 +40,7 @@ import javax.annotation.Nonnull;
|
|||||||
public abstract class CalculatorFragment extends SherlockFragment {
|
public abstract class CalculatorFragment extends SherlockFragment {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final CalculatorFragmentHelper fragmentHelper;
|
private final FragmentUi fragmentHelper;
|
||||||
|
|
||||||
protected CalculatorFragment(int layoutResId, int titleResId) {
|
protected CalculatorFragment(int layoutResId, int titleResId) {
|
||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
||||||
@ -50,7 +50,7 @@ public abstract class CalculatorFragment extends SherlockFragment {
|
|||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CalculatorFragment(@Nonnull CalculatorFragmentHelper fragmentHelper) {
|
protected CalculatorFragment(@Nonnull FragmentUi fragmentHelper) {
|
||||||
this.fragmentHelper = fragmentHelper;
|
this.fragmentHelper = fragmentHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: Solovyev_S
|
|
||||||
* Date: 03.10.12
|
|
||||||
* Time: 14:07
|
|
||||||
*/
|
|
||||||
public abstract class CalculatorFragmentActivity extends SherlockFragmentActivity {
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final CalculatorActivityHelper activityHelper;
|
|
||||||
|
|
||||||
protected CalculatorFragmentActivity() {
|
|
||||||
this(R.layout.main_empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CalculatorFragmentActivity(int layoutResId) {
|
|
||||||
this.activityHelper = CalculatorApplication.getInstance().createActivityHelper(layoutResId, getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
protected CalculatorActivityHelper getActivityHelper() {
|
|
||||||
return activityHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
activityHelper.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
this.activityHelper.onPause(this);
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
activityHelper.onDestroy(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -55,7 +55,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
|||||||
private CalculatorPreferences.Gui.Theme theme;
|
private CalculatorPreferences.Gui.Theme theme;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorFragmentHelper fragmentHelper;
|
private FragmentUi fragmentHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -40,7 +40,7 @@ import javax.annotation.Nonnull;
|
|||||||
public abstract class CalculatorListFragment extends SherlockListFragment {
|
public abstract class CalculatorListFragment extends SherlockListFragment {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final CalculatorFragmentHelper fragmentHelper;
|
private final FragmentUi fragmentHelper;
|
||||||
|
|
||||||
protected CalculatorListFragment(int layoutResId, int titleResId) {
|
protected CalculatorListFragment(int layoutResId, int titleResId) {
|
||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
|
||||||
@ -50,7 +50,7 @@ public abstract class CalculatorListFragment extends SherlockListFragment {
|
|||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CalculatorListFragment(@Nonnull CalculatorFragmentHelper fragmentHelper) {
|
protected CalculatorListFragment(@Nonnull FragmentUi fragmentHelper) {
|
||||||
this.fragmentHelper = fragmentHelper;
|
this.fragmentHelper = fragmentHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import android.webkit.WebView;
|
|||||||
* Date: 6/16/13
|
* Date: 6/16/13
|
||||||
* Time: 6:26 PM
|
* Time: 6:26 PM
|
||||||
*/
|
*/
|
||||||
public final class CalculatorWikiActivity extends CalculatorFragmentActivity {
|
public final class CalculatorWikiActivity extends EmptyActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -22,35 +22,13 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
public abstract class EmptyActivity extends BaseActivity {
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
protected EmptyActivity() {
|
||||||
import javax.annotation.Nullable;
|
this(R.layout.main_empty);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
protected EmptyActivity(int layoutResId) {
|
||||||
* User: serso
|
super(layoutResId);
|
||||||
* Date: 9/26/12
|
}
|
||||||
* Time: 10:14 PM
|
|
||||||
*/
|
|
||||||
public interface CalculatorFragmentHelper {
|
|
||||||
|
|
||||||
boolean isPane(@Nonnull Fragment fragment);
|
|
||||||
|
|
||||||
void setPaneTitle(@Nonnull Fragment fragment, int titleResId);
|
|
||||||
|
|
||||||
void onCreate(@Nonnull Fragment fragment);
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
View onCreateView(@Nonnull Fragment fragment, @Nonnull LayoutInflater inflater, @Nullable ViewGroup container);
|
|
||||||
|
|
||||||
void onViewCreated(@Nonnull Fragment fragment, @Nonnull View root);
|
|
||||||
|
|
||||||
void onResume(@Nonnull Fragment fragment);
|
|
||||||
|
|
||||||
void onPause(@Nonnull Fragment fragment);
|
|
||||||
|
|
||||||
void onDestroy(@Nonnull Fragment fragment);
|
|
||||||
}
|
}
|
@ -42,7 +42,7 @@ import static java.util.Arrays.asList;
|
|||||||
* Date: 9/26/12
|
* Date: 9/26/12
|
||||||
* Time: 10:14 PM
|
* Time: 10:14 PM
|
||||||
*/
|
*/
|
||||||
public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper implements CalculatorFragmentHelper {
|
public class FragmentUi extends BaseUi {
|
||||||
|
|
||||||
private ActivityCheckout checkout;
|
private ActivityCheckout checkout;
|
||||||
|
|
||||||
@ -58,22 +58,21 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
@Nullable
|
@Nullable
|
||||||
private Boolean adFree = null;
|
private Boolean adFree = null;
|
||||||
|
|
||||||
public CalculatorFragmentHelperImpl(int layoutId) {
|
public FragmentUi(int layoutId) {
|
||||||
this.layoutId = layoutId;
|
this.layoutId = layoutId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculatorFragmentHelperImpl(int layoutId, int titleResId) {
|
public FragmentUi(int layoutId, int titleResId) {
|
||||||
this.layoutId = layoutId;
|
this.layoutId = layoutId;
|
||||||
this.titleResId = titleResId;
|
this.titleResId = titleResId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculatorFragmentHelperImpl(int layoutId, int titleResId, boolean listenersOnCreate) {
|
public FragmentUi(int layoutId, int titleResId, boolean listenersOnCreate) {
|
||||||
this.layoutId = layoutId;
|
this.layoutId = layoutId;
|
||||||
this.titleResId = titleResId;
|
this.titleResId = titleResId;
|
||||||
this.listenersOnCreate = listenersOnCreate;
|
this.listenersOnCreate = listenersOnCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPane(@Nonnull Fragment fragment) {
|
public boolean isPane(@Nonnull Fragment fragment) {
|
||||||
return fragment.getActivity() instanceof CalculatorActivity;
|
return fragment.getActivity() instanceof CalculatorActivity;
|
||||||
}
|
}
|
||||||
@ -89,7 +88,6 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nonnull Fragment fragment) {
|
public void onCreate(@Nonnull Fragment fragment) {
|
||||||
final FragmentActivity activity = fragment.getActivity();
|
final FragmentActivity activity = fragment.getActivity();
|
||||||
super.onCreate(activity);
|
super.onCreate(activity);
|
||||||
@ -104,7 +102,6 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
checkout.start();
|
checkout.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume(@Nonnull Fragment fragment) {
|
public void onResume(@Nonnull Fragment fragment) {
|
||||||
if (adView != null) {
|
if (adView != null) {
|
||||||
adView.resume();
|
adView.resume();
|
||||||
@ -136,7 +133,6 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause(@Nonnull Fragment fragment) {
|
public void onPause(@Nonnull Fragment fragment) {
|
||||||
adFree = null;
|
adFree = null;
|
||||||
if (adView != null) {
|
if (adView != null) {
|
||||||
@ -149,7 +145,6 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(@Nonnull Fragment fragment, @Nonnull View root) {
|
public void onViewCreated(@Nonnull Fragment fragment, @Nonnull View root) {
|
||||||
adView = (AdView) root.findViewById(R.id.ad);
|
adView = (AdView) root.findViewById(R.id.ad);
|
||||||
final ViewGroup mainFragmentLayout = (ViewGroup) root.findViewById(R.id.main_fragment_layout);
|
final ViewGroup mainFragmentLayout = (ViewGroup) root.findViewById(R.id.main_fragment_layout);
|
||||||
@ -170,7 +165,6 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy(@Nonnull Fragment fragment) {
|
public void onDestroy(@Nonnull Fragment fragment) {
|
||||||
if (adView != null) {
|
if (adView != null) {
|
||||||
adView.destroy();
|
adView.destroy();
|
||||||
@ -189,7 +183,6 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
|
||||||
public View onCreateView(@Nonnull Fragment fragment, @Nonnull LayoutInflater inflater, @Nullable ViewGroup container) {
|
public View onCreateView(@Nonnull Fragment fragment, @Nonnull LayoutInflater inflater, @Nullable ViewGroup container) {
|
||||||
return inflater.inflate(layoutId, container, false);
|
return inflater.inflate(layoutId, container, false);
|
||||||
}
|
}
|
@ -23,25 +23,24 @@
|
|||||||
package org.solovyev.android.calculator.about;
|
package org.solovyev.android.calculator.about;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import org.solovyev.android.calculator.EmptyActivity;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentActivity;
|
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
* Date: 9/16/11
|
* Date: 9/16/11
|
||||||
* Time: 11:52 PM
|
* Time: 11:52 PM
|
||||||
*/
|
*/
|
||||||
public class CalculatorAboutActivity extends CalculatorFragmentActivity {
|
public class CalculatorAboutActivity extends EmptyActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
getActivityHelper().addTab(this, CalculatorFragmentType.about, null, R.id.main_layout);
|
getUi().addTab(this, CalculatorFragmentType.about, null, R.id.main_layout);
|
||||||
getActivityHelper().addTab(this, CalculatorFragmentType.release_notes, null, R.id.main_layout);
|
getUi().addTab(this, CalculatorFragmentType.release_notes, null, R.id.main_layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package org.solovyev.android.calculator.ga;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.google.android.gms.analytics.GoogleAnalytics;
|
||||||
|
import com.google.android.gms.analytics.Tracker;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.common.listeners.JEvent;
|
||||||
|
import org.solovyev.common.listeners.JEventListener;
|
||||||
|
import org.solovyev.common.listeners.JEventListeners;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
public final class Ga {
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private final GoogleAnalytics analytics;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private final Tracker tracker;
|
||||||
|
|
||||||
|
public Ga(@Nonnull Context context, @Nonnull JEventListeners<JEventListener<? extends JEvent>, JEvent> bus) {
|
||||||
|
analytics = GoogleAnalytics.getInstance(context);
|
||||||
|
tracker = analytics.newTracker(R.xml.ga);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private String getStackTrace(@Nonnull Exception e) {
|
||||||
|
try {
|
||||||
|
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
e.printStackTrace(new PrintStream(out));
|
||||||
|
return new String(out.toByteArray());
|
||||||
|
} catch (Exception e1) {
|
||||||
|
Log.e("Ga", e1.getMessage(), e1);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public GoogleAnalytics getAnalytics() {
|
||||||
|
return analytics;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public Tracker getTracker() {
|
||||||
|
return tracker;
|
||||||
|
}
|
||||||
|
}
|
@ -108,7 +108,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
|||||||
private HistoryArrayAdapter adapter;
|
private HistoryArrayAdapter adapter;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorFragmentHelper fragmentHelper;
|
private FragmentUi fragmentHelper;
|
||||||
|
|
||||||
private final ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromResource(R.menu.history_menu, HistoryMenu.class, SherlockMenuHelper.getInstance(), new HistoryMenuFilter());
|
private final ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromResource(R.menu.history_menu, HistoryMenu.class, SherlockMenuHelper.getInstance(), new HistoryMenuFilter());
|
||||||
|
|
||||||
|
@ -23,64 +23,26 @@
|
|||||||
package org.solovyev.android.calculator.history;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import org.solovyev.android.calculator.*;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.*;
|
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.CalculatorFragmentType.history;
|
import static org.solovyev.android.calculator.CalculatorFragmentType.history;
|
||||||
import static org.solovyev.android.calculator.CalculatorFragmentType.saved_history;
|
import static org.solovyev.android.calculator.CalculatorFragmentType.saved_history;
|
||||||
|
|
||||||
/**
|
public class CalculatorHistoryActivity extends BaseActivity implements CalculatorEventListener {
|
||||||
* User: serso
|
|
||||||
* Date: 12/18/11
|
|
||||||
* Time: 7:37 PM
|
|
||||||
*/
|
|
||||||
public class CalculatorHistoryActivity extends SherlockFragmentActivity implements CalculatorEventListener {
|
|
||||||
|
|
||||||
@Nonnull
|
public CalculatorHistoryActivity() {
|
||||||
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
super(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
ui.addTab(this, history, null, R.id.main_layout);
|
||||||
|
ui.addTab(this, saved_history, null, R.id.main_layout);
|
||||||
activityHelper.addTab(this, history, null, R.id.main_layout);
|
|
||||||
activityHelper.addTab(this, saved_history, null, R.id.main_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
activityHelper.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
this.activityHelper.onPause(this);
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
activityHelper.onDestroy(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,9 +51,4 @@ public class CalculatorHistoryActivity extends SherlockFragmentActivity implemen
|
|||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
CalculatorActivityHelper getActivityHelper() {
|
|
||||||
return activityHelper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
|
|||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context instanceof CalculatorHistoryActivity) {
|
if (context instanceof CalculatorHistoryActivity) {
|
||||||
final CalculatorHistoryActivity activity = (CalculatorHistoryActivity) context;
|
final CalculatorHistoryActivity activity = (CalculatorHistoryActivity) context;
|
||||||
activity.getActivityHelper().selectTab(activity, saved_history);
|
activity.getUi().selectTab(activity, saved_history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,7 +33,6 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ import org.solovyev.android.calculator.CalculatorApplication;
|
|||||||
import org.solovyev.android.calculator.CalculatorEventData;
|
import org.solovyev.android.calculator.CalculatorEventData;
|
||||||
import org.solovyev.android.calculator.CalculatorEventListener;
|
import org.solovyev.android.calculator.CalculatorEventListener;
|
||||||
import org.solovyev.android.calculator.CalculatorEventType;
|
import org.solovyev.android.calculator.CalculatorEventType;
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentHelper;
|
import org.solovyev.android.calculator.FragmentUi;
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||||
import org.solovyev.android.calculator.CalculatorMathRegistry;
|
import org.solovyev.android.calculator.CalculatorMathRegistry;
|
||||||
import org.solovyev.android.calculator.Locator;
|
import org.solovyev.android.calculator.Locator;
|
||||||
@ -96,7 +95,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
|
|||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final CalculatorFragmentHelper fragmentHelper;
|
private final FragmentUi fragmentHelper;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final Handler uiHandler = new Handler();
|
private final Handler uiHandler = new Handler();
|
||||||
|
@ -25,31 +25,21 @@ package org.solovyev.android.calculator.math.edit;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import org.solovyev.android.calculator.*;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.*;
|
public class CalculatorFunctionsActivity extends BaseActivity implements CalculatorEventListener {
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
|
||||||
|
|
||||||
/**
|
public CalculatorFunctionsActivity() {
|
||||||
* User: serso
|
super(R.layout.main_empty, CalculatorFunctionsActivity.class.getSimpleName());
|
||||||
* Date: 12/21/11
|
}
|
||||||
* Time: 10:33 PM
|
|
||||||
*/
|
|
||||||
public class CalculatorFunctionsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
|
||||||
|
|
||||||
final Bundle bundle;
|
final Bundle bundle;
|
||||||
|
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
@ -74,41 +64,11 @@ public class CalculatorFunctionsActivity extends SherlockFragmentActivity implem
|
|||||||
fragmentParameters = AbstractMathEntityListFragment.createBundleFor(category.name());
|
fragmentParameters = AbstractMathEntityListFragment.createBundleFor(category.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), fragmentParameters, androidCategory.getCaptionId(), R.id.main_layout);
|
ui.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), fragmentParameters, androidCategory.getCaptionId(), R.id.main_layout);
|
||||||
} else {
|
} else {
|
||||||
Log.e(CalculatorFunctionsActivity.class.getSimpleName(), "Unable to find android function category for " + category);
|
Log.e(CalculatorFunctionsActivity.class.getSimpleName(), "Unable to find android function category for " + category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
activityHelper.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
this.activityHelper.onPause(this);
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
this.activityHelper.onDestroy(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,72 +23,33 @@
|
|||||||
package org.solovyev.android.calculator.math.edit;
|
package org.solovyev.android.calculator.math.edit;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import org.solovyev.android.calculator.*;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.*;
|
public class CalculatorOperatorsActivity extends BaseActivity implements CalculatorEventListener {
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
|
||||||
|
|
||||||
/**
|
public CalculatorOperatorsActivity() {
|
||||||
* User: serso
|
super(R.layout.main_empty, CalculatorOperatorsActivity.class.getSimpleName());
|
||||||
* Date: 12/21/11
|
}
|
||||||
* Time: 10:33 PM
|
|
||||||
*/
|
|
||||||
public class CalculatorOperatorsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
|
||||||
|
|
||||||
final CalculatorFragmentType fragmentType = CalculatorFragmentType.operators;
|
final CalculatorFragmentType fragmentType = CalculatorFragmentType.operators;
|
||||||
|
|
||||||
for (OperatorCategory category : OperatorCategory.getCategoriesByTabOrder()) {
|
for (OperatorCategory category : OperatorCategory.getCategoriesByTabOrder()) {
|
||||||
final AndroidOperatorCategory androidCategory = AndroidOperatorCategory.valueOf(category);
|
final AndroidOperatorCategory androidCategory = AndroidOperatorCategory.valueOf(category);
|
||||||
if (androidCategory != null) {
|
if (androidCategory != null) {
|
||||||
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), androidCategory.getCaptionId(), R.id.main_layout);
|
ui.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), androidCategory.getCaptionId(), R.id.main_layout);
|
||||||
} else {
|
} else {
|
||||||
activityHelper.logError("Unable to find android operator category for " + category);
|
ui.logError("Unable to find android operator category for " + category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
activityHelper.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
this.activityHelper.onPause(this);
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
this.activityHelper.onDestroy(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
||||||
switch (calculatorEventType) {
|
switch (calculatorEventType) {
|
||||||
|
@ -24,31 +24,21 @@ package org.solovyev.android.calculator.math.edit;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import org.solovyev.android.calculator.*;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.*;
|
public class CalculatorVarsActivity extends BaseActivity implements CalculatorEventListener {
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
|
||||||
|
|
||||||
/**
|
public CalculatorVarsActivity() {
|
||||||
* User: serso
|
super(R.layout.main_empty, CalculatorVarsActivity.class.getSimpleName());
|
||||||
* Date: 12/21/11
|
}
|
||||||
* Time: 11:05 PM
|
|
||||||
*/
|
|
||||||
public class CalculatorVarsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
|
||||||
|
|
||||||
final Bundle bundle;
|
final Bundle bundle;
|
||||||
|
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
@ -75,41 +65,11 @@ public class CalculatorVarsActivity extends SherlockFragmentActivity implements
|
|||||||
final AndroidVarCategory androidVarCategory = AndroidVarCategory.valueOf(category);
|
final AndroidVarCategory androidVarCategory = AndroidVarCategory.valueOf(category);
|
||||||
|
|
||||||
if (androidVarCategory != null) {
|
if (androidVarCategory != null) {
|
||||||
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), fragmentParameters, androidVarCategory.getCaptionId(), R.id.main_layout);
|
ui.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), fragmentParameters, androidVarCategory.getCaptionId(), R.id.main_layout);
|
||||||
} else {
|
} else {
|
||||||
activityHelper.logError("Unable to find android var category for " + category);
|
ui.logError("Unable to find android var category for " + category);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
activityHelper.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
this.activityHelper.onPause(this);
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
this.activityHelper.onDestroy(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,7 @@ package org.solovyev.android.calculator.matrix;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentActivity;
|
import org.solovyev.android.calculator.EmptyActivity;
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
@ -35,13 +35,13 @@ import static com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_STANDARD;
|
|||||||
* Date: 12.10.12
|
* Date: 12.10.12
|
||||||
* Time: 10:56
|
* Time: 10:56
|
||||||
*/
|
*/
|
||||||
public class CalculatorMatrixActivity extends CalculatorFragmentActivity {
|
public class CalculatorMatrixActivity extends EmptyActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
getSupportActionBar().setNavigationMode(NAVIGATION_MODE_STANDARD);
|
getSupportActionBar().setNavigationMode(NAVIGATION_MODE_STANDARD);
|
||||||
getActivityHelper().setFragment(this, CalculatorFragmentType.matrix_edit, null, R.id.main_layout);
|
getUi().setFragment(this, CalculatorFragmentType.matrix_edit, null, R.id.main_layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@ import android.content.res.Resources;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import org.simpleframework.xml.Serializer;
|
import org.simpleframework.xml.Serializer;
|
||||||
import org.simpleframework.xml.core.Persister;
|
import org.simpleframework.xml.core.Persister;
|
||||||
import org.solovyev.android.calculator.App;
|
|
||||||
import org.solovyev.android.calculator.MathEntityDao;
|
import org.solovyev.android.calculator.MathEntityDao;
|
||||||
import org.solovyev.android.calculator.MathEntityPersistenceContainer;
|
import org.solovyev.android.calculator.MathEntityPersistenceContainer;
|
||||||
import org.solovyev.android.calculator.MathPersistenceEntity;
|
import org.solovyev.android.calculator.MathPersistenceEntity;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -111,7 +111,7 @@ public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements Ma
|
|||||||
public String getDescription(@Nonnull String descriptionId) {
|
public String getDescription(@Nonnull String descriptionId) {
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
|
|
||||||
final int stringId = resources.getIdentifier(descriptionId, "string", App.getApplication().getClass().getPackage().getName());
|
final int stringId = resources.getIdentifier(descriptionId, "string", R.class.getPackage().getName());
|
||||||
try {
|
try {
|
||||||
return resources.getString(stringId);
|
return resources.getString(stringId);
|
||||||
} catch (Resources.NotFoundException e) {
|
} catch (Resources.NotFoundException e) {
|
||||||
|
@ -25,7 +25,7 @@ package org.solovyev.android.calculator.plot;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentActivity;
|
import org.solovyev.android.calculator.EmptyActivity;
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ import static com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_STANDARD;
|
|||||||
* Date: 9/30/12
|
* Date: 9/30/12
|
||||||
* Time: 4:56 PM
|
* Time: 4:56 PM
|
||||||
*/
|
*/
|
||||||
public class CalculatorPlotActivity extends CalculatorFragmentActivity {
|
public class CalculatorPlotActivity extends EmptyActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@ -55,7 +55,7 @@ public class CalculatorPlotActivity extends CalculatorFragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportActionBar().setNavigationMode(NAVIGATION_MODE_STANDARD);
|
getSupportActionBar().setNavigationMode(NAVIGATION_MODE_STANDARD);
|
||||||
getActivityHelper().setFragment(this, getPlotterFragmentType(), arguments, R.id.main_layout);
|
getUi().setFragment(this, getPlotterFragmentType(), arguments, R.id.main_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
6
android-app/src/main/res/xml/ga.xml
Normal file
6
android-app/src/main/res/xml/ga.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="ga_trackingId">UA-28724009-2</string>
|
||||||
|
<bool name="ga_reportUncaughtExceptions">true</bool>
|
||||||
|
<bool name="ga_autoActivityTracking">true</bool>
|
||||||
|
</resources>
|
Loading…
Reference in New Issue
Block a user