Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Revert "Merge branch 'dvhh-TV-Mode'"
Browse files Browse the repository at this point in the history
This reverts commit 8bcf2e3, reversing
changes made to 310ad8f.
  • Loading branch information
jackpal committed Apr 14, 2015
1 parent 8bcf2e3 commit cf65b55
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 118 deletions.
Expand Up @@ -43,7 +43,6 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
Expand Down Expand Up @@ -1102,7 +1101,7 @@ private void sendMouseEventCode(MotionEvent e, int button_code) {
x > 255-32 || y > 255-32;
//Log.d(TAG, "mouse button "+x+","+y+","+button_code+",oob="+out_of_bounds);
if(button_code < 0 || button_code > 255-32) {
Log.e(TAG, "mouse button_code out of range: " + button_code);
Log.e(TAG, "mouse button_code out of range: "+button_code);
return;
}
if(!out_of_bounds) {
Expand Down Expand Up @@ -1469,8 +1468,8 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
}

private void updateSize(int w, int h) {
mColumns = Math.max(1, (int) Math.floor(((float) w) / mCharacterWidth));
mVisibleColumns = Math.max(1, (int) Math.floor(((float) mVisibleWidth) / mCharacterWidth));
mColumns = Math.max(1, (int) (((float) w) / mCharacterWidth));
mVisibleColumns = Math.max(1, (int) (((float) mVisibleWidth) / mCharacterWidth));

mTopOfScreenMargin = mTextRenderer.getTopMargin();
mRows = Math.max(1, (h - mTopOfScreenMargin) / mCharacterHeight);
Expand All @@ -1494,18 +1493,9 @@ public void updateSize(boolean force) {
//Need to clear saved links on each display refresh
mLinkLayer.clear();
if (mKnownSize) {

int w = getWidth() - getPaddingLeft() -getPaddingRight();
int h = getHeight() -getPaddingTop() -getPaddingBottom();
ViewParent parent=getParent();
while(parent instanceof View) {
w -= ((View) parent).getPaddingLeft() + ((View) parent).getPaddingRight();
h -= ((View) parent).getPaddingTop() + ((View) parent).getPaddingBottom();
parent = ((View)parent).getParent();
}

//Log.w("Term", "(" + w + ", " + h + ")");

int w = getWidth();
int h = getHeight();
// Log.w("Term", "(" + w + ", " + h + ")");
if (force || w != mVisibleWidth || h != mVisibleHeight) {
mVisibleWidth = w;
mVisibleHeight = h;
Expand Down Expand Up @@ -1721,5 +1711,4 @@ public String getURLat(float x, float y)
else
return null;
}

}
Expand Up @@ -65,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
mSettings = new TermSettings(this, prefs);
mSettings = new TermSettings(getResources(), prefs);

Intent TSIntent = new Intent(this, TermService.class);
mTSIntent = TSIntent;
Expand Down
19 changes: 4 additions & 15 deletions term/src/main/java/jackpal/androidterm/Term.java
Expand Up @@ -21,7 +21,6 @@
import jackpal.androidterm.compat.ActivityCompat;
import jackpal.androidterm.compat.AndroidCompat;
import jackpal.androidterm.compat.MenuItemCompat;
import jackpal.androidterm.compat.UIModeCompat;
import jackpal.androidterm.emulatorview.EmulatorView;
import jackpal.androidterm.emulatorview.TermSession;
import jackpal.androidterm.emulatorview.UpdateCallback;
Expand All @@ -39,7 +38,6 @@

import android.app.Activity;
import android.app.AlertDialog;
import android.app.UiModeManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand All @@ -62,7 +60,6 @@
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.GestureDetector.SimpleOnGestureListener;
Expand Down Expand Up @@ -333,15 +330,15 @@ public void onCreate(Bundle icicle) {

Log.v(TermDebug.LOG_TAG, "onCreate");

final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mSettings = new TermSettings(this, mPrefs);
mPrefs.registerOnSharedPreferenceChangeListener(this);

mPrivateAlias = new ComponentName(this, RemoteInterface.PRIVACT_ACTIVITY_ALIAS);

if (icicle == null)
onNewIntent(getIntent());

final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mSettings = new TermSettings(getResources(), mPrefs);
mPrefs.registerOnSharedPreferenceChangeListener(this);

Intent broadcast = new Intent(ACTION_PATH_BROADCAST);
if (AndroidCompat.SDK >= 12) {
broadcast.addFlags(FLAG_INCLUDE_STOPPED_PACKAGES);
Expand Down Expand Up @@ -402,7 +399,6 @@ public void onCreate(Bundle icicle) {
mAlreadyStarted = true;
}


private String makePathFromBundle(Bundle extras) {
if (extras == null || extras.size() == 0) {
return "";
Expand Down Expand Up @@ -528,7 +524,6 @@ private TermSession createTermSession() throws IOException {
private TermView createEmulatorView(TermSession session) {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

TermView emulatorView = new TermView(this, session, metrics);

emulatorView.setExtGestureListener(new EmulatorViewGestureListener(emulatorView));
Expand Down Expand Up @@ -591,11 +586,6 @@ private void updatePrefs() {
}
}

/*
EmulatorView v = (EmulatorView) mViewFlipper.getCurrentView();
if(v!=null)
v.updateSize(true);
*/
int orientation = mSettings.getScreenOrientation();
int o = 0;
if (orientation == 0) {
Expand All @@ -607,7 +597,6 @@ private void updatePrefs() {
} else {
/* Shouldn't be happened. */
}

setRequestedOrientation(o);
}

Expand Down
24 changes: 0 additions & 24 deletions term/src/main/java/jackpal/androidterm/TermViewFlipper.java
Expand Up @@ -20,12 +20,10 @@
import java.util.LinkedList;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;
Expand Down Expand Up @@ -102,33 +100,11 @@ private void commonConstructor(Context context) {
Gravity.TOP|Gravity.LEFT);
}

protected int dpToPixel(int input) {
Resources r = getResources();
int px = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
input,
r.getDisplayMetrics()
);
return px;
}

public void updatePrefs(TermSettings settings) {
boolean statusBarVisible = settings.showStatusBar();
int[] colorScheme = settings.getColorScheme();
setBackgroundColor(colorScheme[1]);
mStatusBarVisible = statusBarVisible;
if(settings.getSafeMargins()) {
setPadding(
dpToPixel(48), dpToPixel(27),
dpToPixel(48), dpToPixel(27)
);
}else{
setPadding(0, 0, 0, 0);
}
EmulatorView view = (EmulatorView) getCurrentView();
if (view != null) {
view.updateSize(true);
}
}

public Iterator<View> iterator() {
Expand Down
33 changes: 0 additions & 33 deletions term/src/main/java/jackpal/androidterm/compat/UIModeCompat.java

This file was deleted.

18 changes: 0 additions & 18 deletions term/src/main/java/jackpal/androidterm/util/TermSettings.java
Expand Up @@ -18,9 +18,7 @@

import jackpal.androidterm.R;
import jackpal.androidterm.compat.AndroidCompat;
import jackpal.androidterm.compat.UIModeCompat;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.view.KeyEvent;
Expand All @@ -34,7 +32,6 @@ public class TermSettings {
private int mStatusBar;
private int mActionBarMode;
private int mOrientation;
private boolean mSafeMargins;
private int mCursorStyle;
private int mCursorBlink;
private int mFontSize;
Expand Down Expand Up @@ -66,7 +63,6 @@ public class TermSettings {
private static final String STATUSBAR_KEY = "statusbar";
private static final String ACTIONBAR_KEY = "actionbar";
private static final String ORIENTATION_KEY = "orientation";
private static final String SAFE_MARGINS_KEY = "safe_margins";
private static final String FONTSIZE_KEY = "fontsize";
private static final String COLOR_KEY = "color";
private static final String UTF8_KEY = "utf8_by_default";
Expand Down Expand Up @@ -161,15 +157,6 @@ public TermSettings(Resources res, SharedPreferences prefs) {
readPrefs(prefs);
}

public TermSettings(Context context, SharedPreferences prefs) {
readDefaultPrefs(context);
readPrefs(prefs);
}
private void readDefaultPrefs(Context context) {
Resources res=context.getResources();
readDefaultPrefs(res);
mSafeMargins = UIModeCompat.isUIModeTV(context);
}
private void readDefaultPrefs(Resources res) {
mStatusBar = Integer.parseInt(res.getString(R.string.pref_statusbar_default));
mActionBarMode = res.getInteger(R.integer.pref_actionbar_default);
Expand All @@ -195,15 +182,13 @@ private void readDefaultPrefs(Resources res) {
mAltSendsEsc = res.getBoolean(R.bool.pref_alt_sends_esc_default);
mMouseTracking = res.getBoolean(R.bool.pref_mouse_tracking_default);
mUseKeyboardShortcuts = res.getBoolean(R.bool.pref_use_keyboard_shortcuts_default);
mSafeMargins = res.getBoolean(R.bool.pref_safe_margins_default);
}

public void readPrefs(SharedPreferences prefs) {
mPrefs = prefs;
mStatusBar = readIntPref(STATUSBAR_KEY, mStatusBar, 1);
mActionBarMode = readIntPref(ACTIONBAR_KEY, mActionBarMode, ACTION_BAR_MODE_MAX);
mOrientation = readIntPref(ORIENTATION_KEY, mOrientation, 2);
mSafeMargins = readBooleanPref(SAFE_MARGINS_KEY,mSafeMargins);
// mCursorStyle = readIntPref(CURSORSTYLE_KEY, mCursorStyle, 2);
// mCursorBlink = readIntPref(CURSORBLINK_KEY, mCursorBlink, 1);
mFontSize = readIntPref(FONTSIZE_KEY, mFontSize, 288);
Expand Down Expand Up @@ -262,8 +247,6 @@ public int getScreenOrientation() {
return mOrientation;
}

public boolean getSafeMargins() {return mSafeMargins; }

public int getCursorStyle() {
return mCursorStyle;
}
Expand Down Expand Up @@ -387,5 +370,4 @@ public void setHomePath(String homePath) {
public String getHomePath() {
return mHomePath;
}

}
1 change: 0 additions & 1 deletion term/src/main/res/values/defaults.xml
Expand Up @@ -4,7 +4,6 @@
<string name="pref_statusbar_default" translatable="false">1</string>
<integer name="pref_actionbar_default">1</integer>
<integer name="pref_orientation_default">0</integer>
<bool name="pref_safe_margins_default">false</bool>
<string name="pref_cursorstyle_default" translatable="false">0</string>
<string name="pref_cursorblink_default" translatable="false">0</string>
<string name="pref_fontsize_default" translatable="false">10</string>
Expand Down
3 changes: 0 additions & 3 deletions term/src/main/res/values/strings.xml
Expand Up @@ -62,9 +62,6 @@
<string name="summary_orientation_preference">Choose the screen orientation behavior.</string>
<string name="dialog_title_orientation_preference">Screen orientation behavior</string>

<string name="title_safe_margins_preference">Safe margins</string>
<string name="summary_safe_margins_preference">Add overscan margins to the terminal screen.</string>

<string name="title_cursorstyle_preference">Cursor style</string>
<string name="summary_cursorstyle_preference">Choose cursor style.</string>
<string name="dialog_title_cursorstyle_preference">Cursor style</string>
Expand Down
6 changes: 0 additions & 6 deletions term/src/main/res/xml/preferences.xml
Expand Up @@ -48,12 +48,6 @@
android:entryValues="@array/entryvalues_orientation_preference"
android:dialogTitle="@string/dialog_title_orientation_preference" />

<CheckBoxPreference
android:key="safe_margins"
android:defaultValue="@bool/pref_safe_margins_default"
android:title="@string/title_safe_margins_preference"
android:summary="@string/summary_safe_margins_preference"
/>
<!--
<ListPreference
android:key="cursorstyle"
Expand Down

0 comments on commit cf65b55

Please sign in to comment.