This commit is contained in:
serso 2012-10-02 18:31:42 +04:00
parent 327f43a323
commit 604c61cf29

View File

@ -6,12 +6,9 @@ import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.Display;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
@ -66,24 +63,22 @@ public final class CalculatorButtons {
@NotNull Activity activity) { @NotNull Activity activity) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT || !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) { final boolean large = activity.getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE);
final Display display = activity.getWindowManager().getDefaultDisplay();
if (!large) {
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT
|| !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
final DragButton equalsButton = (DragButton)activity.findViewById(R.id.equalsButton); final DragButton equalsButton = (DragButton)activity.findViewById(R.id.equalsButton);
if (equalsButton != null) { if (equalsButton != null) {
// todo serso: visibility should be changed only for some cases (like small screens)
if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) { if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) {
equalsButton.setVisibility(View.VISIBLE); equalsButton.setVisibility(View.VISIBLE);
if (display.getWidth() <= 480) {
// mobile phones
final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView(); final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView();
if (calculatorDisplayView != null) { if (calculatorDisplayView != null) {
calculatorDisplayView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); calculatorDisplayView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
} }
}
} else { } else {
equalsButton.setVisibility(View.GONE); equalsButton.setVisibility(View.GONE);
if (display.getWidth() <= 480) {
// mobile phones // mobile phones
final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView(); final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView();
if (calculatorDisplayView != null) { if (calculatorDisplayView != null) {