deps versions update

This commit is contained in:
Sergey Solovyev 2013-06-12 23:08:44 +04:00
parent 0b902355e0
commit a00a2ac684
31 changed files with 310 additions and 123 deletions

View File

@ -10,6 +10,7 @@ import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
import android.text.Html;
import android.util.AttributeSet;
import android.util.TypedValue;
@ -183,7 +184,11 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.cpp_display_text_size_mobile));
}
this.setOnClickListener(new CalculatorDisplayOnClickListener(context));
if (context instanceof FragmentActivity) {
this.setOnClickListener(new CalculatorDisplayOnClickListener((FragmentActivity) context));
} else {
throw new IllegalArgumentException("Must be fragment activity, got " + context.getClass());
}
}
this.initialized = true;

View File

@ -15,7 +15,7 @@ import jscl.AngleUnit;
import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AViews;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.core.R;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.view.AngleUnitsButton;
@ -43,7 +43,7 @@ public final class CalculatorButtons {
final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile);
AViews.processViewsOfType(root, DragButton.class, new AViews.ViewProcessor<DragButton>() {
Views.processViewsOfType(root, DragButton.class, new Views.ViewProcessor<DragButton>() {
@Override
public void process(@NotNull DragButton button) {
button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
@ -68,11 +68,11 @@ public final class CalculatorButtons {
@NotNull Activity activity) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
final boolean large = AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) &&
final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) &&
CalculatorPreferences.Gui.getLayout(preferences) != CalculatorPreferences.Gui.Layout.main_calculator_mobile;
if (!large) {
if (AViews.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT
if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT
|| !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
final DragButton equalsButton = (DragButton)activity.findViewById(R.id.cpp_button_equals);

View File

@ -1,6 +1,6 @@
package org.solovyev.android.calculator;
import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.menu.ContextMenuBuilder;
@ -17,10 +17,10 @@ import java.util.List;
public class CalculatorDisplayOnClickListener implements View.OnClickListener {
@NotNull
private final Context context;
private final FragmentActivity activity;
public CalculatorDisplayOnClickListener(@NotNull Context context) {
this.context = context;
public CalculatorDisplayOnClickListener(@NotNull FragmentActivity activity) {
this.activity = activity;
}
@Override
@ -39,13 +39,13 @@ public class CalculatorDisplayOnClickListener implements View.OnClickListener {
}
if (!filteredMenuItems.isEmpty()) {
ContextMenuBuilder.newInstance(context, ListContextMenu.newInstance(filteredMenuItems)).create(displayViewState).show();
ContextMenuBuilder.newInstance(activity, "display-menu", ListContextMenu.newInstance(filteredMenuItems)).build(displayViewState).show();
}
} else {
final String errorMessage = displayViewState.getErrorMessage();
if (errorMessage != null) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_evaluation_error, errorMessage, context);
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_evaluation_error, errorMessage, activity);
}
}
}

View File

@ -4,7 +4,8 @@ import android.content.SharedPreferences;
import jscl.AngleUnit;
import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.DeviceModel;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.plot.PlotLineColor;
@ -19,6 +20,10 @@ import org.solovyev.android.view.VibratorContainer;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import static org.solovyev.android.Android.isPhoneModel;
import static org.solovyev.android.DeviceModel.samsung_galaxy_s;
import static org.solovyev.android.DeviceModel.samsung_galaxy_s_2;
/**
* User: serso
* Date: 4/20/12
@ -166,7 +171,7 @@ public final class CalculatorPreferences {
}
if (!AndroidCalculatorEngine.Preferences.multiplicationSign.isSet(preferences)) {
if (AndroidUtils.isPhoneModel(AndroidUtils.PhoneModel.samsung_galaxy_s) || AndroidUtils.isPhoneModel(AndroidUtils.PhoneModel.samsung_galaxy_s_2)) {
if (isPhoneModel(samsung_galaxy_s) || isPhoneModel(samsung_galaxy_s_2)) {
// workaround ofr samsung galaxy s phones
AndroidCalculatorEngine.Preferences.multiplicationSign.putPreference(preferences, "*");
}

View File

@ -11,7 +11,7 @@ import android.util.DisplayMetrics;
import android.view.WindowManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AViews;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState;
import org.solovyev.android.calculator.Locator;
@ -65,7 +65,7 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
twoThirdWidth = Math.min(twoThirdWidth, twoThirdHeight);
twoThirdHeight = Math.max(twoThirdWidth, getHeight(twoThirdWidth));
final int baseWidth = AViews.toPixels(dm, 300);
final int baseWidth = Views.toPixels(dm, 300);
final int width0 = Math.min(twoThirdWidth, baseWidth);
final int height0 = Math.min(twoThirdHeight, getHeight(baseWidth));

View File

@ -6,7 +6,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.App;
import org.solovyev.android.calculator.AbstractFixableError;
import org.solovyev.android.calculator.CalculatorPreferences;
@ -22,7 +22,7 @@ public class CalculatorOnscreenStartActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (AndroidUtils.isComponentEnabled(this, CalculatorOnscreenStartActivity.class)) {
if (Android.isComponentEnabled(this, CalculatorOnscreenStartActivity.class)) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!CalculatorPreferences.OnscreenCalculator.removeIconDialogShown.getPreference(prefs)) {

View File

@ -114,7 +114,6 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2012. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:orientation="vertical">
</LinearLayout>

View File

@ -8,6 +8,6 @@
a:summary="@string/c_calc_ad_free_summary"
a:defaultValue="false"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/acl_adview_pref"/>
</PreferenceScreen>

View File

@ -6,7 +6,7 @@
<PreferenceScreen
a:title="@string/c_prefs_appearance_category">
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/acl_adview_pref"/>
<android.preference.CheckBoxPreference
a:key="@string/p_calc_color_display_key"

View File

@ -5,7 +5,7 @@
<PreferenceScreen a:title="@string/c_prefs_calculations_category">
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/acl_adview_pref"/>
<android.preference.CheckBoxPreference
a:key="@string/p_calc_round_result_key"

View File

@ -4,7 +4,7 @@
<PreferenceScreen a:title="@string/prefs_onscreen_title">
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/acl_adview_pref"/>
<android.preference.CheckBoxPreference
a:key="onscreen_start_on_boot"

View File

@ -5,7 +5,7 @@
<PreferenceScreen
a:title="@string/c_prefs_other_category">
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/acl_adview_pref"/>
<android.preference.CheckBoxPreference
a:key="@string/p_calc_show_release_notes_key"

View File

@ -4,7 +4,7 @@
<PreferenceScreen a:title="@string/prefs_graph_screen_title">
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/admob_pref"/>
<org.solovyev.android.ads.AdViewPreference a:layout="@layout/acl_adview_pref"/>
<android.preference.CheckBoxPreference
a:key="graph_plot_imag"

View File

@ -80,7 +80,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
}
public void processButtons(@NotNull final Activity activity, @NotNull View root) {
dpclRegister.removeAll();
dpclRegister.removeListeners();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity);

View File

@ -5,7 +5,7 @@ import android.os.Handler;
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AThreads;
import org.solovyev.android.Threads;
import org.solovyev.android.msg.AndroidMessage;
import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageType;
@ -32,7 +32,7 @@ public class AndroidCalculatorNotifier implements CalculatorNotifier {
}
public AndroidCalculatorNotifier(@NotNull Application application, boolean showDebugMessages) {
assert AThreads.isUiThread();
assert Threads.isUiThread();
this.application = application;
this.showDebugMessages = showDebugMessages;
@ -61,7 +61,7 @@ public class AndroidCalculatorNotifier implements CalculatorNotifier {
}
private void showMessageInUiThread(@NotNull final String message) {
if (AThreads.isUiThread()) {
if (Threads.isUiThread()) {
Toast.makeText(application, message, Toast.LENGTH_SHORT).show();
} else {
uiHandler.post(new Runnable() {

View File

@ -23,9 +23,9 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AActivities;
import org.solovyev.android.AThreads;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Activities;
import org.solovyev.android.Android;
import org.solovyev.android.Threads;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.plot.CalculatorPlotActivity;
import org.solovyev.android.fragments.FragmentUtils;
@ -109,7 +109,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
final Integer savedVersion = CalculatorPreferences.appVersion.getPreference(preferences);
final int appVersion = AndroidUtils.getAppVersionCode(context, CalculatorActivity.class.getPackage().getName());
final int appVersion = Android.getAppVersionCode(context);
CalculatorPreferences.appVersion.putPreference(preferences, appVersion);
@ -201,7 +201,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
if ( newLayout != activityHelper.getLayout() ) {
AActivities.restartActivity(this);
Activities.restartActivity(this);
}
this.activityHelper.onResume(this);
@ -332,23 +332,23 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) {
case plot_graph:
AThreads.tryRunOnUiThread(this, new Runnable() {
@Override
public void run() {
if (isMultiPane()) {
final ActionBar.Tab selectedTab = getSupportActionBar().getSelectedTab();
if (selectedTab != null && CalculatorFragmentType.plotter.getFragmentTag().equals(selectedTab.getTag())) {
// do nothing - fragment shown and already registered for plot updates
} else {
// otherwise - open fragment
activityHelper.selectTab(CalculatorActivity.this, CalculatorFragmentType.plotter);
}
} else {
// start new activity
CalculatorActivityLauncher.plotGraph(CalculatorActivity.this);
}
}
});
Threads.tryRunOnUiThread(this, new Runnable() {
@Override
public void run() {
if (isMultiPane()) {
final ActionBar.Tab selectedTab = getSupportActionBar().getSelectedTab();
if (selectedTab != null && CalculatorFragmentType.plotter.getFragmentTag().equals(selectedTab.getTag())) {
// do nothing - fragment shown and already registered for plot updates
} else {
// otherwise - open fragment
activityHelper.selectTab(CalculatorActivity.this, CalculatorFragmentType.plotter);
}
} else {
// start new activity
CalculatorActivityLauncher.plotGraph(CalculatorActivity.this);
}
}
});
break;
}
}

View File

@ -18,8 +18,8 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AActivities;
import org.solovyev.android.AViews;
import org.solovyev.android.Activities;
import org.solovyev.android.Views;
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
/**
@ -113,7 +113,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final ActionBar actionBar = activity.getSupportActionBar();
if (activity instanceof CalculatorActivity) {
if (AViews.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
actionBar.setDisplayShowTitleEnabled(true);
} else {
actionBar.setDisplayShowTitleEnabled(false);
@ -145,7 +145,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences);
if (!theme.equals(newTheme)) {
AActivities.restartActivity(activity);
Activities.restartActivity(activity);
}
}
@ -282,13 +282,13 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
final StringBuilder helpText = new StringBuilder();
helpText.append("Size: ");
if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) {
if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) {
helpText.append("xlarge");
} else if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) {
} else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) {
helpText.append("large");
} else if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) {
} else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) {
helpText.append("normal");
} else if (AViews.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) {
} else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) {
helpText.append("small");
} else {
helpText.append("unknown");

View File

@ -14,7 +14,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import jscl.math.Generic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.App;
import org.solovyev.android.calculator.about.CalculatorAboutActivity;
import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
@ -47,7 +47,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showHistory(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorHistoryActivity.class);
AndroidUtils.addIntentFlags(intent, detached, context);
Android.addIntentFlags(intent, detached, context);
context.startActivity(intent);
}
@ -60,7 +60,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
}
public static void showSettings(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorPreferencesActivity.class);
AndroidUtils.addIntentFlags(intent, detached, context);
Android.addIntentFlags(intent, detached, context);
context.startActivity(intent);
}
@ -74,7 +74,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showFunctions(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorFunctionsActivity.class);
AndroidUtils.addIntentFlags(intent, detached, context);
Android.addIntentFlags(intent, detached, context);
context.startActivity(intent);
}
@ -84,7 +84,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showOperators(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorOperatorsActivity.class);
AndroidUtils.addIntentFlags(intent, detached, context);
Android.addIntentFlags(intent, detached, context);
context.startActivity(intent);
}
@ -94,14 +94,14 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showVars(@NotNull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorVarsActivity.class);
AndroidUtils.addIntentFlags(intent, detached, context);
Android.addIntentFlags(intent, detached, context);
context.startActivity(intent);
}
public static void plotGraph(@NotNull final Context context){
final Intent intent = new Intent();
intent.setClass(context, CalculatorPlotActivity.class);
AndroidUtils.addIntentFlags(intent, false, context);
Android.addIntentFlags(intent, false, context);
context.startActivity(intent);
}
@ -117,7 +117,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} else {
final Intent intent = new Intent(context, CalculatorVarsActivity.class);
intent.putExtra(CalculatorVarsFragment.CREATE_VAR_EXTRA_STRING, varValue);
AndroidUtils.addIntentFlags(intent, false, context);
Android.addIntentFlags(intent, false, context);
context.startActivity(intent);
}
} else {
@ -184,7 +184,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void likeButtonPressed(@NotNull final Context context) {
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(CalculatorApplication.FACEBOOK_APP_URL));
AndroidUtils.addIntentFlags(intent, false, context);
Android.addIntentFlags(intent, false, context);
context.startActivity(intent);
}
@ -213,7 +213,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
@Override
public void run() {
final Intent intent = new Intent(context, CalculatorMatrixActivity.class);
AndroidUtils.addIntentFlags(intent, false, context);
Android.addIntentFlags(intent, false, context);
context.startActivity(intent);
}
});

View File

@ -13,8 +13,9 @@ import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.App;
import org.solovyev.android.ServiceLocator;
import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.external.AndroidExternalListenersContainer;
import org.solovyev.android.calculator.history.AndroidCalculatorHistory;
@ -40,7 +41,7 @@ import java.util.List;
resToastText = R.string.crashed,
resDialogTitle = R.string.crash_dialog_title,
resDialogText = R.string.crash_dialog_text)
public class CalculatorApplication extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener {
public class CalculatorApplication extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener, ServiceLocator {
/*
**********************************************************************
@ -221,7 +222,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (CalculatorPreferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) {
boolean showAppIcon = CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(prefs);
AndroidUtils.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon);
Android.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon);
Locator.getInstance().getNotifier().showMessage(R.string.cpp_this_change_may_require_reboot, MessageType.info);
}
}

View File

@ -11,7 +11,7 @@ import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.fragments.FragmentUtils;
import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.Strings;
@ -33,7 +33,7 @@ public class CalculatorDialogActivity extends SherlockFragmentActivity {
final Intent intent = new Intent();
intent.setClass(context, CalculatorDialogActivity.class);
intent.putExtra(DIALOG_DATA_EXTRA, ParcelableDialogData.wrap(dialogData));
AndroidUtils.addIntentFlags(intent, false, context);
Android.addIntentFlags(intent, false, context);
context.startActivity(intent);
}

View File

@ -13,7 +13,7 @@ import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.TextView;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.CalculatorFragment;
import org.solovyev.android.calculator.CalculatorFragmentType;
@ -51,7 +51,7 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
final StringBuilder result = new StringBuilder();
final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title);
final int version = AndroidUtils.getAppVersionCode(context, CalculatorApplication.class.getPackage().getName());
final int version = Android.getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());

View File

@ -8,6 +8,7 @@ package org.solovyev.android.calculator.history;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -22,7 +23,6 @@ import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.menu.*;
import org.solovyev.android.sherlock.menu.SherlockMenuHelper;
@ -140,7 +140,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
final CalculatorHistoryState historyState = (CalculatorHistoryState) parent.getItemAtPosition(position);
final Context context = getActivity();
final FragmentActivity activity = getActivity();
final HistoryItemMenuData data = new HistoryItemMenuData(historyState, adapter);
@ -160,8 +160,8 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
menuItems.remove(HistoryItemMenuItem.copy_result);
}
final ContextMenuBuilder<HistoryItemMenuItem, HistoryItemMenuData> menuBuilder = ContextMenuBuilder.newInstance(context, ListContextMenu.newInstance(menuItems));
menuBuilder.create(data).show();
final ContextMenuBuilder<HistoryItemMenuItem, HistoryItemMenuData> menuBuilder = ContextMenuBuilder.newInstance(activity, "history-menu", ListContextMenu.newInstance(menuItems));
menuBuilder.build(data).show();
return true;
}
@ -220,7 +220,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
historyState.setSaved(true);
if ( Collections.contains(historyState, Locator.getInstance().getHistory().getSavedHistory(), new Equalizer<CalculatorHistoryState>() {
@Override
public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) {
public boolean areEqual(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) {
return first != null && second != null &&
first.getTime() == second.getTime() &&
first.getDisplayState().equals(second.getDisplayState()) &&

View File

@ -51,7 +51,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
public static final String MATH_ENTITY_CATEGORY_EXTRA_STRING = "org.solovyev.android.calculator.CalculatorVarsActivity_math_entity_category";
protected final static List<Character> acceptableChars = Arrays.asList(Strings.toObject("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_".toCharArray()));
protected final static List<Character> acceptableChars = Arrays.asList(Strings.toObjects("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_".toCharArray()));
/*
@ -124,8 +124,8 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
final List<LabeledMenuItem<T>> menuItems = getMenuItemsOnLongClick(item);
if (!menuItems.isEmpty()) {
final ContextMenuBuilder<LabeledMenuItem<T>, T> menuBuilder = ContextMenuBuilder.newInstance(AbstractMathEntityListFragment.this.getActivity(), ListContextMenu.newInstance(menuItems));
menuBuilder.create(item).show();
final ContextMenuBuilder<LabeledMenuItem<T>, T> menuBuilder = ContextMenuBuilder.newInstance(AbstractMathEntityListFragment.this.getActivity(), "math-entity-menu", ListContextMenu.newInstance(menuItems));
menuBuilder.build(item).show();
}
return true;

View File

@ -16,8 +16,8 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AThreads;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.Android;
import org.solovyev.android.Threads;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.menu.AMenuItem;
@ -153,19 +153,19 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
}
private void updateChart(@NotNull final PlotData plotData, @Nullable final SherlockFragmentActivity activity) {
AThreads.tryRunOnUiThread(activity, new Runnable() {
@Override
public void run() {
createChart(plotData);
Threads.tryRunOnUiThread(activity, new Runnable() {
@Override
public void run() {
createChart(plotData);
final View view = getView();
if (view != null) {
createGraphicalView(view, plotData);
}
final View view = getView();
if (view != null) {
createGraphicalView(view, plotData);
}
activity.invalidateOptionsMenu();
}
});
activity.invalidateOptionsMenu();
}
});
}
protected abstract void onError();
@ -309,7 +309,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
final File externalFilesDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (externalFilesDir != null) {
final String path = externalFilesDir.getPath();
AndroidUtils.saveBitmap(screenshot, path, screenShotFileName);
Android.saveBitmap(screenshot, path, screenShotFileName);
Locator.getInstance().getNotifier().showMessage(R.string.cpp_plot_screenshot_saved, MessageType.info, path + "/" + screenShotFileName);
} else {
Locator.getInstance().getNotifier().showMessage(R.string.cpp_plot_unable_to_save_screenshot, MessageType.error);

View File

@ -10,7 +10,7 @@ import org.solovyev.android.calculator.CalculatorListFragment;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
import org.solovyev.android.fragments.FragmentUtils;
import org.solovyev.android.list.ListItemArrayAdapter;
import org.solovyev.android.list.ListItemAdapter;
import java.util.List;
@ -48,7 +48,7 @@ public class CalculatorPlotFunctionsActivity extends SherlockFragmentActivity {
}
});
ListItemArrayAdapter.createAndAttach(getListView(), this.getActivity(), items);
ListItemAdapter.createAndAttach(this, items);
}
}
}

View File

@ -5,7 +5,7 @@ package org.solovyev.android.calculator.plot;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AViews;
import org.solovyev.android.Views;
class TouchHandler {
@ -43,7 +43,7 @@ class TouchHandler {
float x = event.getX();
float y = event.getY();
int pointerCount = AViews.getPointerCountFromMotionEvent(event);
int pointerCount = Views.getPointerCountFromMotionEvent(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
@ -63,7 +63,7 @@ class TouchHandler {
velocityTracker.addMovement(event);
listener.onTouchMove(x, y);
} else if (pointerCount == 2) {
listener.onTouchZoomMove(x, y, AViews.getXFromMotionEvent(event, 1), AViews.getYFromMotionEvent(event, 1));
listener.onTouchZoomMove(x, y, Views.getXFromMotionEvent(event, 1), Views.getYFromMotionEvent(event, 1));
}
break;
@ -75,7 +75,7 @@ class TouchHandler {
case MotionEvent.ACTION_POINTER_DOWN:
if (pointerCount == 2) {
listener.onTouchZoomDown(x, y, AViews.getXFromMotionEvent(event, 1), AViews.getYFromMotionEvent(event, 1));
listener.onTouchZoomDown(x, y, Views.getXFromMotionEvent(event, 1), Views.getYFromMotionEvent(event, 1));
}
break;

View File

@ -21,7 +21,7 @@ import net.robotmedia.billing.ResponseCode;
import net.robotmedia.billing.helper.AbstractBillingObserver;
import net.robotmedia.billing.model.Transaction;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AActivities;
import org.solovyev.android.Activities;
import org.solovyev.android.App;
import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.*;
@ -156,7 +156,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
case PURCHASED:
adFreePreference.setEnabled(false);
// restart activity to disable ads
AActivities.restartActivity(this);
Activities.restartActivity(this);
break;
case CANCELLED:
adFreePreference.setEnabled(true);

View File

@ -22,6 +22,11 @@
<artifactId>common-text</artifactId>
</dependency>
<dependency>
<groupId>org.solovyev</groupId>
<artifactId>common-listeners</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -57,6 +62,12 @@
<artifactId>simple-xml</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
</dependencies>

View File

@ -0,0 +1,168 @@
package org.solovyev.acraanalyzer;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.cli.*;
import org.solovyev.common.text.Strings;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import static org.solovyev.common.collections.Collections.getFirstCollectionElement;
/**
* User: serso
* Date: 6/12/13
* Time: 10:08 PM
*/
public final class AcraAnalyzer {
private static final String NEW_LINE = System.getProperty("line.separator");
public static void main(String[] args) throws ParseException {
final Options options = new Options();
options.addOption("path", true, "Path to the ACRA reports");
final CommandLineParser parser = new GnuParser();
final CommandLine cmd = parser.parse(options, args);
final String path = cmd.getOptionValue("path");
if (Strings.isEmpty(path)) {
throw new IllegalArgumentException("Path should be specified");
} else {
final Multimap<String, AcraReport> reports = ArrayListMultimap.create(100, 20);
scanFiles(path, reports);
final List<Collection<AcraReport>> sortedReports = new ArrayList<Collection<AcraReport>>(reports.size());
for (String stackTrace : reports.keys()) {
sortedReports.add(reports.get(stackTrace));
}
Collections.sort(sortedReports, new Comparator<Collection<AcraReport>>() {
@Override
public int compare(Collection<AcraReport> lhs, Collection<AcraReport> rhs) {
if (lhs.size() == rhs.size()) {
return 0;
} else if (lhs.size() < rhs.size()) {
return 1;
} else {
return -1;
}
}
});
for (Collection<AcraReport> sortedReport : sortedReports) {
final AcraReport report = getFirstCollectionElement(sortedReport);
System.out.println("Count: " + sortedReport.size());
System.out.println("App version: " + report.appVersion);
System.out.println("Stack trace: " + report.stackTrace);
}
}
}
private static void scanFiles(String path, Multimap<String, AcraReport> reports) {
final File directory = new File(path);
if (directory.isDirectory()) {
scanFiles(directory, reports);
}
}
private static void scanFiles(File directory, Multimap<String, AcraReport> reports) {
final File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
scanFiles(file, reports);
} else {
analyzeFile(file, reports);
}
}
}
}
private static void analyzeFile(File file, Multimap<String, AcraReport> reports) {
final AcraReport report = readReport(file);
if (!Strings.isEmpty(report.stackTrace)) {
reports.put(report.stackTrace, report);
}
}
private static AcraReport readReport(File file) {
final AcraReport result = new AcraReport();
Scanner scanner = null;
try {
scanner = new Scanner(file);
while (scanner.hasNextLine()) {
final String line = scanner.nextLine();
if (line.startsWith("STACK_TRACE")) {
result.stackTrace = readStackTrace(line.substring("STACK_TRACE=".length()), scanner);
break;
} else if (line.startsWith("ANDROID_VERSION")) {
result.androidVersion = line.substring("ANDROID_VERSION=".length());
} else if (line.startsWith("APP_VERSION_NAME")) {
result.appVersion = line.substring("APP_VERSION_NAME=".length());
} else if (line.startsWith("BRAND")) {
result.brand = line.substring("BRAND=".length());
} else if (line.startsWith("USER_COMMENT")) {
result.userComment = line.substring("USER_COMMENT=".length());
} else if (line.startsWith("PHONE_MODEL")) {
result.phoneModel = line.substring("PHONE_MODEL=".length());
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (scanner != null) {
scanner.close();
}
}
return result;
}
private static String readStackTrace(String firstLine, Scanner scanner) {
final StringBuilder sb = new StringBuilder();
sb.append(firstLine.trim()).append(newLine());
while (scanner.hasNextLine()) {
final String line = scanner.nextLine().trim();
if (line.startsWith("at")) {
sb.append(line).append(newLine());
} else {
break;
}
}
return sb.toString();
}
private static final class AcraReport {
private String userComment;
private String phoneModel;
private String brand;
private String appVersion;
private String androidVersion;
private String stackTrace = "";
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AcraReport that = (AcraReport) o;
if (!stackTrace.equals(that.stackTrace)) return false;
return true;
}
@Override
public int hashCode() {
return stackTrace.hashCode();
}
}
public static String newLine() {
return NEW_LINE;
}
}

20
pom.xml
View File

@ -33,8 +33,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<android.common.version>1.0.7-SNAPSHOT</android.common.version>
<common.version>1.0.4-SNAPSHOT</common.version>
<android.common.version>1.1.1-SNAPSHOT</android.common.version>
<common.version>1.0.4</common.version>
</properties>
<dependencyManagement>
@ -79,6 +79,12 @@
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>org.solovyev</groupId>
<artifactId>common-listeners</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>org.solovyev.android</groupId>
<artifactId>android-common-core</artifactId>
@ -209,6 +215,12 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.2</version>
<exclusions>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
@ -237,7 +249,7 @@
<plugin>
<groupId>com.electriccloud</groupId>
<artifactId>javac2-maven-plugin</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<executions>
<execution>
<id>@NotNull Instrumentation</id>
@ -295,7 +307,7 @@
</sourceDirectories>
<sdk>
<platform>15</platform>
<platform>17</platform>
</sdk>
<emulator>