fixes + @NotNull -> @Nonnull
This commit is contained in:
@@ -2,4 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.solovyev.android.calculator.onscreen"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" />
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="4"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
</manifest>
|
@@ -5,7 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
||||
|
||||
/**
|
||||
@@ -19,8 +19,8 @@ public final class CalculatorOnscreenBroadcastReceiver extends BroadcastReceiver
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(@NotNull Context context,
|
||||
@NotNull Intent intent) {
|
||||
public void onReceive(@Nonnull Context context,
|
||||
@Nonnull Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (CalculatorPreferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) {
|
||||
|
@@ -9,8 +9,8 @@ import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.solovyev.android.Views;
|
||||
import org.solovyev.android.calculator.CalculatorDisplayViewState;
|
||||
import org.solovyev.android.calculator.CalculatorEditorViewState;
|
||||
@@ -29,14 +29,14 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
|
||||
|
||||
private static final int NOTIFICATION_ID = 9031988; // my birthday =)
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private final ExternalCalculatorIntentHandler intentHandler = new DefaultExternalCalculatorIntentHandler(this);
|
||||
public static final Class<CalculatorOnscreenBroadcastReceiver> INTENT_LISTENER_CLASS = CalculatorOnscreenBroadcastReceiver.class;
|
||||
|
||||
@Nullable
|
||||
private static String cursorColor;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private CalculatorOnscreenView view;
|
||||
|
||||
private boolean compatibilityStart = true;
|
||||
@@ -89,7 +89,7 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
|
||||
Locator.getInstance().getExternalListenersContainer().addExternalListener(getIntentListenerClass());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private static Class<?> getIntentListenerClass() {
|
||||
return INTENT_LISTENER_CLASS;
|
||||
}
|
||||
@@ -108,13 +108,13 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(@NotNull Context context, @NotNull CalculatorEditorViewState editorState, @NotNull CalculatorDisplayViewState displayState) {
|
||||
public void updateState(@Nonnull Context context, @Nonnull CalculatorEditorViewState editorState, @Nonnull CalculatorDisplayViewState displayState) {
|
||||
view.updateDisplayState(displayState);
|
||||
view.updateEditorState(editorState);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getCursorColor(@NotNull Context context) {
|
||||
@Nonnull
|
||||
private static String getCursorColor(@Nonnull Context context) {
|
||||
if (cursorColor == null) {
|
||||
cursorColor = Integer.toHexString(context.getResources().getColor(R.color.cpp_onscreen_cursor_color)).substring(2);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInitIntent(@NotNull Intent intent) {
|
||||
private boolean isInitIntent(@Nonnull Intent intent) {
|
||||
return intent.getAction().equals(AndroidExternalListenersContainer.INIT_ACTION);
|
||||
}
|
||||
|
||||
@@ -200,19 +200,19 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
|
||||
nm.notify(NOTIFICATION_ID, builder.getNotification());
|
||||
}
|
||||
|
||||
public static void showNotification(@NotNull Context context) {
|
||||
public static void showNotification(@Nonnull Context context) {
|
||||
final Intent intent = new Intent(AndroidExternalListenersContainer.INIT_ACTION);
|
||||
intent.setClass(context, getIntentListenerClass());
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static void showOnscreenView(@NotNull Context context) {
|
||||
public static void showOnscreenView(@Nonnull Context context) {
|
||||
final Intent intent = createShowOnscreenViewIntent(context);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Intent createShowOnscreenViewIntent(@NotNull Context context) {
|
||||
@Nonnull
|
||||
private static Intent createShowOnscreenViewIntent(@Nonnull Context context) {
|
||||
final Intent intent = new Intent(AndroidExternalListenersContainer.INIT_ACTION);
|
||||
intent.setClass(context, getIntentListenerClass());
|
||||
intent.putExtra(AndroidExternalListenersContainer.INIT_ACTION_CREATE_VIEW_EXTRA, true);
|
||||
|
@@ -5,7 +5,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.solovyev.android.Android;
|
||||
import org.solovyev.android.App;
|
||||
import org.solovyev.android.calculator.AbstractFixableError;
|
||||
@@ -38,7 +38,7 @@ public class CalculatorOnscreenStartActivity extends Activity {
|
||||
|
||||
public static class RemoveIconFixableError extends AbstractFixableError {
|
||||
|
||||
public RemoveIconFixableError(@NotNull Context context) {
|
||||
public RemoveIconFixableError(@Nonnull Context context) {
|
||||
super(context.getString(R.string.cpp_onscreen_remove_icon_button_text));
|
||||
}
|
||||
|
||||
|
@@ -11,8 +11,8 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
|
||||
@@ -50,28 +50,28 @@ public class CalculatorOnscreenView {
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private View root;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private View content;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private View header;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private AndroidCalculatorEditorView editorView;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private AndroidCalculatorDisplayView displayView;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private Context context;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private CalculatorOnscreenViewState state = CalculatorOnscreenViewState.newDefaultState();
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private String cursorColor;
|
||||
|
||||
@Nullable
|
||||
@@ -107,9 +107,9 @@ public class CalculatorOnscreenView {
|
||||
private CalculatorOnscreenView() {
|
||||
}
|
||||
|
||||
public static CalculatorOnscreenView newInstance(@NotNull Context context,
|
||||
@NotNull CalculatorOnscreenViewState state,
|
||||
@NotNull String cursorColor,
|
||||
public static CalculatorOnscreenView newInstance(@Nonnull Context context,
|
||||
@Nonnull CalculatorOnscreenViewState state,
|
||||
@Nonnull String cursorColor,
|
||||
@Nullable OnscreenViewListener viewListener) {
|
||||
final CalculatorOnscreenView result = new CalculatorOnscreenView();
|
||||
|
||||
@@ -136,12 +136,12 @@ public class CalculatorOnscreenView {
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
public void updateDisplayState(@NotNull CalculatorDisplayViewState displayState) {
|
||||
public void updateDisplayState(@Nonnull CalculatorDisplayViewState displayState) {
|
||||
checkInit();
|
||||
displayView.setState(displayState);
|
||||
}
|
||||
|
||||
public void updateEditorState(@NotNull CalculatorEditorViewState editorState) {
|
||||
public void updateEditorState(@Nonnull CalculatorEditorViewState editorState) {
|
||||
checkInit();
|
||||
editorView.setState(editorState);
|
||||
}
|
||||
@@ -312,13 +312,13 @@ public class CalculatorOnscreenView {
|
||||
}
|
||||
}
|
||||
|
||||
public static void persistState(@NotNull Context context, @NotNull CalculatorOnscreenViewState state) {
|
||||
public static void persistState(@Nonnull Context context, @Nonnull CalculatorOnscreenViewState state) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
viewStatePreference.putPreference(preferences, state);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CalculatorOnscreenViewState readState(@NotNull Context context) {
|
||||
public static CalculatorOnscreenViewState readState(@Nonnull Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (viewStatePreference.isSet(preferences)) {
|
||||
return viewStatePreference.getPreference(preferences);
|
||||
@@ -344,12 +344,12 @@ public class CalculatorOnscreenView {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private WindowManager getWindowManager() {
|
||||
return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
public CalculatorOnscreenViewState getCurrentState(boolean useRealSize) {
|
||||
final WindowManager.LayoutParams params = (WindowManager.LayoutParams) root.getLayoutParams();
|
||||
if (useRealSize) {
|
||||
@@ -389,7 +389,7 @@ public class CalculatorOnscreenView {
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private final WindowManager wm;
|
||||
|
||||
private int orientation;
|
||||
@@ -400,7 +400,7 @@ public class CalculatorOnscreenView {
|
||||
|
||||
private long time = 0;
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private final View view;
|
||||
|
||||
private int displayWidth;
|
||||
@@ -415,8 +415,8 @@ public class CalculatorOnscreenView {
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
public WindowDragTouchListener(@NotNull WindowManager wm,
|
||||
@NotNull View view) {
|
||||
public WindowDragTouchListener(@Nonnull WindowManager wm,
|
||||
@Nonnull View view) {
|
||||
this.wm = wm;
|
||||
this.view = view;
|
||||
initDisplayParams();
|
||||
@@ -503,7 +503,7 @@ public class CalculatorOnscreenView {
|
||||
return δx >= DIST_EPS && δx < DIST_MAX;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
private static String toString(float x, float y) {
|
||||
return "(" + formatFloat(x) + ", " + formatFloat(y) + ")";
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import android.content.SharedPreferences;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.solovyev.android.prefs.AbstractPreference;
|
||||
@@ -23,7 +23,7 @@ public class CalculatorOnscreenViewState implements Parcelable {
|
||||
private static final String TAG = CalculatorOnscreenViewState.class.getSimpleName();
|
||||
|
||||
public static final Parcelable.Creator<CalculatorOnscreenViewState> CREATOR = new Parcelable.Creator<CalculatorOnscreenViewState>() {
|
||||
public CalculatorOnscreenViewState createFromParcel(@NotNull Parcel in) {
|
||||
public CalculatorOnscreenViewState createFromParcel(@Nonnull Parcel in) {
|
||||
return CalculatorOnscreenViewState.fromParcel(in);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ public class CalculatorOnscreenViewState implements Parcelable {
|
||||
private CalculatorOnscreenViewState() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorOnscreenViewState fromParcel(@NotNull Parcel in) {
|
||||
@Nonnull
|
||||
private static CalculatorOnscreenViewState fromParcel(@Nonnull Parcel in) {
|
||||
final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState();
|
||||
result.width = in.readInt();
|
||||
result.height = in.readInt();
|
||||
@@ -53,12 +53,12 @@ public class CalculatorOnscreenViewState implements Parcelable {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
public static CalculatorOnscreenViewState newDefaultState() {
|
||||
return newInstance(200, 400, 0, 0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nonnull
|
||||
public static CalculatorOnscreenViewState newInstance(int width, int height, int x, int y) {
|
||||
final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState();
|
||||
result.width = width;
|
||||
@@ -106,7 +106,7 @@ public class CalculatorOnscreenViewState implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NotNull Parcel out, int flags) {
|
||||
public void writeToParcel(@Nonnull Parcel out, int flags) {
|
||||
out.writeInt(width);
|
||||
out.writeInt(height);
|
||||
out.writeInt(x);
|
||||
@@ -125,13 +125,13 @@ public class CalculatorOnscreenViewState implements Parcelable {
|
||||
|
||||
public static class Preference extends AbstractPreference<CalculatorOnscreenViewState> {
|
||||
|
||||
public Preference(@NotNull String key, @Nullable CalculatorOnscreenViewState defaultValue) {
|
||||
public Preference(@Nonnull String key, @Nullable CalculatorOnscreenViewState defaultValue) {
|
||||
super(key, defaultValue);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected CalculatorOnscreenViewState getPersistedValue(@NotNull SharedPreferences preferences) {
|
||||
protected CalculatorOnscreenViewState getPersistedValue(@Nonnull SharedPreferences preferences) {
|
||||
try {
|
||||
final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState();
|
||||
final JSONObject jsonObject = new JSONObject(preferences.getString(getKey(), "{}"));
|
||||
@@ -149,7 +149,7 @@ public class CalculatorOnscreenViewState implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putPersistedValue(@NotNull SharedPreferences.Editor editor, @NotNull CalculatorOnscreenViewState value) {
|
||||
protected void putPersistedValue(@Nonnull SharedPreferences.Editor editor, @Nonnull CalculatorOnscreenViewState value) {
|
||||
final Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put("width", value.getWidth());
|
||||
properties.put("height", value.getHeight());
|
||||
|
Reference in New Issue
Block a user