Browse Source

[Sense 5] Code formatting and cleanup

sense5
Mikanoshi 6 years ago
parent
commit
551f810abb
6 changed files with 745 additions and 736 deletions
  1. +6
    -0
      OneToolbox/lint.xml
  2. +13
    -10
      OneToolbox/src/com/langerhans/one/ApmDialog.java
  3. +407
    -406
      OneToolbox/src/com/langerhans/one/dgv/DraggableGridView.java
  4. +49
    -48
      OneToolbox/src/com/langerhans/one/mods/PrismMods.java
  5. +233
    -235
      OneToolbox/src/com/langerhans/one/mods/SysUIMods.java
  6. +37
    -37
      OneToolbox/src/com/langerhans/one/utils/ColorFilterGenerator.java

+ 6
- 0
OneToolbox/lint.xml View File

@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="ClickableViewAccessibility">
<ignore path="src/com/langerhans/one/dgv/DraggableGridView.java" />
</issue>
<issue id="ExportedReceiver">
<ignore path="AndroidManifest.xml" />
</issue>
<issue id="ExportedService">
<ignore path="AndroidManifest.xml" />
</issue>
<issue id="InflateParams">
<ignore path="src/com/langerhans/one/ApmDialog.java" />
</issue>
<issue id="UseCompoundDrawables">
<ignore path="res/layout/about_screen.xml" />
</issue>

+ 13
- 10
OneToolbox/src/com/langerhans/one/ApmDialog.java View File

@@ -70,25 +70,28 @@ public class ApmDialog extends HtcAlertDialog.Builder {
items = itms;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return items.size();
}
public Object getItem(int position) {
return items.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View row;
if (convertView == null)
convertView = mInflater.inflate(R.layout.select_dialog_apm, null);
HtcListItem2LineText itemTitle = (HtcListItem2LineText) convertView.findViewById(R.id.list_item);
HtcListItemTileImage itemIcon = (HtcListItemTileImage) convertView.findViewById(R.id.list_item_img);
row = mInflater.inflate(R.layout.select_dialog_apm, null);
else
row = convertView;
HtcListItem2LineText itemTitle = (HtcListItem2LineText) row.findViewById(R.id.list_item);
HtcListItemTileImage itemIcon = (HtcListItemTileImage) row.findViewById(R.id.list_item_img);
itemTitle.setPrimaryText(items.get(position).getTitle());
itemTitle.setSecondaryTextSingleLine(true);
@@ -98,7 +101,7 @@ public class ApmDialog extends HtcAlertDialog.Builder {
itemIcon.setScaleY(0.65f);
itemIcon.setTranslationX(context.getResources().getDisplayMetrics().density * 5.0f);
return convertView;
return row;
}
}
@@ -107,7 +110,7 @@ public class ApmDialog extends HtcAlertDialog.Builder {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
case 0:
Intent rebIntent = new Intent("com.langerhans.one.mods.action.APMReboot");
((Activity)context).sendBroadcast(rebIntent);
break;


+ 407
- 406
OneToolbox/src/com/langerhans/one/dgv/DraggableGridView.java View File

@@ -34,278 +34,279 @@ import android.widget.ImageView;
public class DraggableGridView extends FrameLayout implements View.OnTouchListener, View.OnClickListener, View.OnLongClickListener {
//layout vars
public static float childRatio = .9f;
protected int colCount, childSize, padding, dpi, scroll = 0;
protected float lastDelta = 0;
protected Handler handler = new Handler();
//dragging vars
protected int dragged = -1, lastX = -1, lastY = -1, lastTarget = -1;
protected boolean enabled = true, touching = false;
//anim vars
public static int animT = 150;
protected ArrayList<Integer> newPositions = new ArrayList<Integer>();
//listeners
protected OnRearrangeListener onRearrangeListener;
protected OnClickListener secondaryOnClickListener;
private OnItemClickListener onItemClickListener;
//CONSTRUCTOR AND HELPERS
public DraggableGridView (Context context, AttributeSet attrs) {
super(context, attrs);
setListeners();
handler.removeCallbacks(updateTask);
handler.postAtTime(updateTask, SystemClock.uptimeMillis() + 500);
setChildrenDrawingOrderEnabled(true);
protected int colCount, childSize, padding, dpi, scroll = 0;
protected float lastDelta = 0;
protected Handler handler = new Handler();
//dragging vars
protected int dragged = -1, lastX = -1, lastY = -1, lastTarget = -1;
protected boolean enabled = true, touching = false;
//anim vars
public static int animT = 150;
protected ArrayList<Integer> newPositions = new ArrayList<Integer>();
//listeners
protected OnRearrangeListener onRearrangeListener;
protected OnClickListener secondaryOnClickListener;
private OnItemClickListener onItemClickListener;
//CONSTRUCTOR AND HELPERS
public DraggableGridView (Context context, AttributeSet attrs) {
super(context, attrs);
setListeners();
handler.removeCallbacks(updateTask);
handler.postAtTime(updateTask, SystemClock.uptimeMillis() + 500);
setChildrenDrawingOrderEnabled(true);

DisplayMetrics metrics = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
DisplayMetrics metrics = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
dpi = metrics.densityDpi;
}
protected void setListeners()
{
setOnTouchListener(this);
super.setOnClickListener(this);
setOnLongClickListener(this);
}
@Override
public void setOnClickListener(OnClickListener l) {
secondaryOnClickListener = l;
}
protected Runnable updateTask = new Runnable() {
@SuppressLint("WrongCall")
public void run()
{
if (dragged != -1)
{
if (lastY < padding * 3 && scroll > 0)
scroll -= 20;
else if (lastY > getBottom() - getTop() - (padding * 3) && scroll < getMaxScroll())
scroll += 20;
}
else if (lastDelta != 0 && !touching)
{
scroll += lastDelta;
lastDelta *= .9;
if (Math.abs(lastDelta) < .25)
lastDelta = 0;
}
clampScroll();
onLayout(true, getLeft(), getTop(), getRight(), getBottom());
handler.postDelayed(this, 25);
}
};
//OVERRIDES
@Override
public void addView(View child) {
super.addView(child);
newPositions.add(-1);
};
@Override
public void removeViewAt(int index) {
super.removeViewAt(index);
newPositions.remove(index);
};
//LAYOUT
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
//compute width of view, in dp
float w = (r - l) / (dpi / 160f);
//determine number of columns, at least 2
colCount = 2;
int sub = 240;
w -= 280;
while (w > 0)
{
colCount++;
w -= sub;
sub += 40;
}
//determine childSize and padding, in px
childSize = (r - l) / colCount;
childSize = Math.round(childSize * childRatio);
padding = ((r - l) - (childSize * colCount)) / (colCount + 1);
for (int i = 0; i < getChildCount(); i++)
if (i != dragged)
{
Point xy = getCoorFromIndex(i);
getChildAt(i).layout(xy.x, xy.y, xy.x + childSize, xy.y + childSize);
}
}
@Override
protected int getChildDrawingOrder(int childCount, int i) {
if (dragged == -1)
return i;
else if (i == childCount - 1)
return dragged;
else if (i >= dragged)
return i + 1;
return i;
}
public int getIndexFromCoor(int x, int y)
{
int col = getColOrRowFromCoor(x), row = getColOrRowFromCoor(y + scroll);
if (col == -1 || row == -1) //touch is between columns or rows
return -1;
int index = row * colCount + col;
if (index >= getChildCount())
return -1;
return index;
}
protected int getColOrRowFromCoor(int coor)
{
coor -= padding;
for (int i = 0; coor > 0; i++)
{
if (coor < childSize)
return i;
coor -= (childSize + padding);
}
return -1;
}
protected int getTargetFromCoor(int x, int y)
{
if (getColOrRowFromCoor(y + scroll) == -1) //touch is between rows
return -1;
//if (getIndexFromCoor(x, y) != -1) //touch on top of another visual
//return -1;
int leftPos = getIndexFromCoor(x - (childSize / 4), y);
int rightPos = getIndexFromCoor(x + (childSize / 4), y);
if (leftPos == -1 && rightPos == -1) //touch is in the middle of nowhere
return -1;
if (leftPos == rightPos) //touch is in the middle of a visual
return -1;
int target = -1;
if (rightPos > -1)
target = rightPos;
else if (leftPos > -1)
target = leftPos + 1;
if (dragged < target)
return target - 1;
//Toast.makeText(getContext(), "Target: " + target + ".", Toast.LENGTH_SHORT).show();
return target;
}
protected Point getCoorFromIndex(int index)
{
int col = index % colCount;
int row = index / colCount;
return new Point(padding + (childSize + padding) * col,
padding + (childSize + padding) * row - scroll);
}
public int getIndexOf(View child)
{
for (int i = 0; i < getChildCount(); i++)
if (getChildAt(i) == child)
return i;
return -1;
}
//EVENT HANDLERS
public void onClick(View view) {
if (enabled)
{
if (secondaryOnClickListener != null)
secondaryOnClickListener.onClick(view);
if (onItemClickListener != null && getLastIndex() != -1)
onItemClickListener.onItemClick(null, getChildAt(getLastIndex()), getLastIndex(), getLastIndex() / colCount);
}
}
public boolean onLongClick(View view)
{
if (!enabled)
return false;
int index = getLastIndex();
if (index != -1)
{
dragged = index;
animateDragged();
return true;
}
return false;
}
@SuppressLint("WrongCall")
}
protected void setListeners()
{
setOnTouchListener(this);
super.setOnClickListener(this);
setOnLongClickListener(this);
}
@Override
public void setOnClickListener(OnClickListener l) {
secondaryOnClickListener = l;
}
protected Runnable updateTask = new Runnable() {
@SuppressLint("WrongCall")
public void run()
{
if (dragged != -1)
{
if (lastY < padding * 3 && scroll > 0)
scroll -= 20;
else if (lastY > getBottom() - getTop() - (padding * 3) && scroll < getMaxScroll())
scroll += 20;
}
else if (lastDelta != 0 && !touching)
{
scroll += lastDelta;
lastDelta *= .9;
if (Math.abs(lastDelta) < .25)
lastDelta = 0;
}
clampScroll();
onLayout(true, getLeft(), getTop(), getRight(), getBottom());
handler.postDelayed(this, 25);
}
};
//OVERRIDES
@Override
public void addView(View child) {
super.addView(child);
newPositions.add(-1);
};
@Override
public void removeViewAt(int index) {
super.removeViewAt(index);
newPositions.remove(index);
};
//LAYOUT
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
//compute width of view, in dp
float w = (r - l) / (dpi / 160f);
//determine number of columns, at least 2
colCount = 2;
int sub = 240;
w -= 280;
while (w > 0)
{
colCount++;
w -= sub;
sub += 40;
}
//determine childSize and padding, in px
childSize = (r - l) / colCount;
childSize = Math.round(childSize * childRatio);
padding = ((r - l) - (childSize * colCount)) / (colCount + 1);
for (int i = 0; i < getChildCount(); i++)
if (i != dragged)
{
Point xy = getCoorFromIndex(i);
getChildAt(i).layout(xy.x, xy.y, xy.x + childSize, xy.y + childSize);
}
}
@Override
protected int getChildDrawingOrder(int childCount, int i) {
if (dragged == -1)
return i;
else if (i == childCount - 1)
return dragged;
else if (i >= dragged)
return i + 1;
return i;
}
public int getIndexFromCoor(int x, int y)
{
int col = getColOrRowFromCoor(x), row = getColOrRowFromCoor(y + scroll);
if (col == -1 || row == -1) //touch is between columns or rows
return -1;
int index = row * colCount + col;
if (index >= getChildCount())
return -1;
return index;
}
protected int getColOrRowFromCoor(int coor)
{
int coor_local = coor;
coor_local -= padding;
for (int i = 0; coor_local > 0; i++)
{
if (coor_local < childSize)
return i;
coor_local -= (childSize + padding);
}
return -1;
}
protected int getTargetFromCoor(int x, int y)
{
if (getColOrRowFromCoor(y + scroll) == -1) //touch is between rows
return -1;
//if (getIndexFromCoor(x, y) != -1) //touch on top of another visual
//return -1;
int leftPos = getIndexFromCoor(x - (childSize / 4), y);
int rightPos = getIndexFromCoor(x + (childSize / 4), y);
if (leftPos == -1 && rightPos == -1) //touch is in the middle of nowhere
return -1;
if (leftPos == rightPos) //touch is in the middle of a visual
return -1;
int target = -1;
if (rightPos > -1)
target = rightPos;
else if (leftPos > -1)
target = leftPos + 1;
if (dragged < target)
return target - 1;
//Toast.makeText(getContext(), "Target: " + target + ".", Toast.LENGTH_SHORT).show();
return target;
}
protected Point getCoorFromIndex(int index)
{
int col = index % colCount;
int row = index / colCount;
return new Point(padding + (childSize + padding) * col,
padding + (childSize + padding) * row - scroll);
}
public int getIndexOf(View child)
{
for (int i = 0; i < getChildCount(); i++)
if (getChildAt(i) == child)
return i;
return -1;
}
//EVENT HANDLERS
public void onClick(View view) {
if (enabled)
{
if (secondaryOnClickListener != null)
secondaryOnClickListener.onClick(view);
if (onItemClickListener != null && getLastIndex() != -1)
onItemClickListener.onItemClick(null, getChildAt(getLastIndex()), getLastIndex(), getLastIndex() / colCount);
}
}
public boolean onLongClick(View view)
{
if (!enabled)
return false;
int index = getLastIndex();
if (index != -1)
{
dragged = index;
animateDragged();
return true;
}
return false;
}
@SuppressLint("WrongCall")
public boolean onTouch(View view, MotionEvent event)
{
int action = event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
enabled = true;
lastX = (int) event.getX();
lastY = (int) event.getY();
touching = true;
break;
case MotionEvent.ACTION_MOVE:
int delta = lastY - (int)event.getY();
if (dragged != -1)
{
//change draw location of dragged visual
int x = (int)event.getX(), y = (int)event.getY();
int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
getChildAt(dragged).layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
//check for new target hover
int target = getTargetFromCoor(x, y);
if (lastTarget != target)
{
if (target != -1)
{
animateGap(target);
lastTarget = target;
}
}
}
else
{
scroll += delta;
clampScroll();
if (Math.abs(delta) > 2)
enabled = false;
onLayout(true, getLeft(), getTop(), getRight(), getBottom());
}
lastX = (int) event.getX();
lastY = (int) event.getY();
lastDelta = delta;
break;
case MotionEvent.ACTION_UP:
if (dragged != -1)
{
View v = getChildAt(dragged);
if (lastTarget != -1)
reorderChildren();
else
{
Point xy = getCoorFromIndex(dragged);
v.layout(xy.x, xy.y, xy.x + childSize, xy.y + childSize);
}
v.clearAnimation();
if (v instanceof ImageView)
((ImageView)v).setImageAlpha(255);
lastTarget = -1;
dragged = -1;
}
touching = false;
break;
}
if (dragged != -1)
return true;
return false;
}
//EVENT HELPERS
protected void animateDragged()
{
View v = getChildAt(dragged);
int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
AnimationSet animSet = new AnimationSet(true);
{
int action = event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
enabled = true;
lastX = (int) event.getX();
lastY = (int) event.getY();
touching = true;
break;
case MotionEvent.ACTION_MOVE:
int delta = lastY - (int)event.getY();
if (dragged != -1)
{
//change draw location of dragged visual
int x = (int)event.getX(), y = (int)event.getY();
int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
getChildAt(dragged).layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
//check for new target hover
int target = getTargetFromCoor(x, y);
if (lastTarget != target)
{
if (target != -1)
{
animateGap(target);
lastTarget = target;
}
}
}
else
{
scroll += delta;
clampScroll();
if (Math.abs(delta) > 2)
enabled = false;
onLayout(true, getLeft(), getTop(), getRight(), getBottom());
}
lastX = (int) event.getX();
lastY = (int) event.getY();
lastDelta = delta;
break;
case MotionEvent.ACTION_UP:
if (dragged != -1)
{
View v = getChildAt(dragged);
if (lastTarget != -1)
reorderChildren();
else
{
Point xy = getCoorFromIndex(dragged);
v.layout(xy.x, xy.y, xy.x + childSize, xy.y + childSize);
}
v.clearAnimation();
if (v instanceof ImageView)
((ImageView)v).setImageAlpha(255);
lastTarget = -1;
dragged = -1;
}
touching = false;
break;
}
if (dragged != -1)
return true;
return false;
}
//EVENT HELPERS
protected void animateDragged()
{
View v = getChildAt(dragged);
int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
AnimationSet animSet = new AnimationSet(true);
ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * 3 / 4);
scale.setDuration(animT);
AlphaAnimation alpha = new AlphaAnimation(1, .5f);
@@ -318,148 +319,148 @@ public class DraggableGridView extends FrameLayout implements View.OnTouchListen
v.clearAnimation();
v.startAnimation(animSet);
}
protected void animateGap(int target)
{
for (int i = 0; i < getChildCount(); i++)
{
View v = getChildAt(i);
if (i == dragged)
continue;
int newPos = i;
if (dragged < target && i >= dragged + 1 && i <= target)
newPos--;
else if (target < dragged && i >= target && i < dragged)
newPos++;
//animate
int oldPos = i;
if (newPositions.get(i) != -1)
oldPos = newPositions.get(i);
if (oldPos == newPos)
continue;
Point oldXY = getCoorFromIndex(oldPos);
Point newXY = getCoorFromIndex(newPos);
Point oldOffset = new Point(oldXY.x - v.getLeft(), oldXY.y - v.getTop());
Point newOffset = new Point(newXY.x - v.getLeft(), newXY.y - v.getTop());
TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, oldOffset.x,
Animation.ABSOLUTE, newOffset.x,
Animation.ABSOLUTE, oldOffset.y,
Animation.ABSOLUTE, newOffset.y);
}
protected void animateGap(int target)
{
for (int i = 0; i < getChildCount(); i++)
{
View v = getChildAt(i);
if (i == dragged)
continue;
int newPos = i;
if (dragged < target && i >= dragged + 1 && i <= target)
newPos--;
else if (target < dragged && i >= target && i < dragged)
newPos++;
//animate
int oldPos = i;
if (newPositions.get(i) != -1)
oldPos = newPositions.get(i);
if (oldPos == newPos)
continue;
Point oldXY = getCoorFromIndex(oldPos);
Point newXY = getCoorFromIndex(newPos);
Point oldOffset = new Point(oldXY.x - v.getLeft(), oldXY.y - v.getTop());
Point newOffset = new Point(newXY.x - v.getLeft(), newXY.y - v.getTop());
TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, oldOffset.x,
Animation.ABSOLUTE, newOffset.x,
Animation.ABSOLUTE, oldOffset.y,
Animation.ABSOLUTE, newOffset.y);
translate.setDuration(animT);
translate.setFillEnabled(true);
translate.setFillAfter(true);
v.clearAnimation();
v.startAnimation(translate);
newPositions.set(i, newPos);
}
}
@SuppressLint("WrongCall")
protected void reorderChildren()
{
//FIGURE OUT HOW TO REORDER CHILDREN WITHOUT REMOVING THEM ALL AND RECONSTRUCTING THE LIST!!!
if (onRearrangeListener != null)
onRearrangeListener.onRearrange(dragged, lastTarget);
ArrayList<View> children = new ArrayList<View>();
for (int i = 0; i < getChildCount(); i++)
{
getChildAt(i).clearAnimation();
children.add(getChildAt(i));
}
removeAllViews();
while (dragged != lastTarget)
if (lastTarget == children.size()) // dragged and dropped to the right of the last element
{
children.add(children.remove(dragged));
dragged = lastTarget;
}
else if (dragged < lastTarget) // shift to the right
{
Collections.swap(children, dragged, dragged + 1);
dragged++;
}
else if (dragged > lastTarget) // shift to the left
{
Collections.swap(children, dragged, dragged - 1);
dragged--;
}
for (int i = 0; i < children.size(); i++)
{
newPositions.set(i, -1);
addView(children.get(i));
}
onLayout(true, getLeft(), getTop(), getRight(), getBottom());
}
public void scrollToTop()
{
scroll = 0;
}
public void scrollToBottom()
{
scroll = Integer.MAX_VALUE;
clampScroll();
}
protected void clampScroll()
{
int stretch = 3, overreach = getHeight() / 2;
int max = getMaxScroll();
max = Math.max(max, 0);
if (scroll < -overreach)
{
scroll = -overreach;
lastDelta = 0;
}
else if (scroll > max + overreach)
{
scroll = max + overreach;
lastDelta = 0;
}
else if (scroll < 0)
{
if (scroll >= -stretch)
scroll = 0;
else if (!touching)
scroll -= scroll / stretch;
}
else if (scroll > max)
{
if (scroll <= max + stretch)
scroll = max;
else if (!touching)
scroll += (max - scroll) / stretch;
}
}
protected int getMaxScroll()
{
int rowCount = (int)Math.ceil((double)getChildCount()/colCount), max = rowCount * childSize + (rowCount + 1) * padding - getHeight();
return max;
}
public int getLastIndex()
{
return getIndexFromCoor(lastX, lastY);
}
//OTHER METHODS
public void setOnRearrangeListener(OnRearrangeListener l)
{
this.onRearrangeListener = l;
}
public void setOnItemClickListener(OnItemClickListener l)
{
this.onItemClickListener = l;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@SuppressLint("WrongCall")
protected void reorderChildren()
{
//FIGURE OUT HOW TO REORDER CHILDREN WITHOUT REMOVING THEM ALL AND RECONSTRUCTING THE LIST!!!
if (onRearrangeListener != null)
onRearrangeListener.onRearrange(dragged, lastTarget);
ArrayList<View> children = new ArrayList<View>();
for (int i = 0; i < getChildCount(); i++)
{
getChildAt(i).clearAnimation();
children.add(getChildAt(i));
}
removeAllViews();
while (dragged != lastTarget)
if (lastTarget == children.size()) // dragged and dropped to the right of the last element
{
children.add(children.remove(dragged));
dragged = lastTarget;
}
else if (dragged < lastTarget) // shift to the right
{
Collections.swap(children, dragged, dragged + 1);
dragged++;
}
else if (dragged > lastTarget) // shift to the left
{
Collections.swap(children, dragged, dragged - 1);
dragged--;
}
for (int i = 0; i < children.size(); i++)
{
newPositions.set(i, -1);
addView(children.get(i));
}
onLayout(true, getLeft(), getTop(), getRight(), getBottom());
}
public void scrollToTop()
{
scroll = 0;
}
public void scrollToBottom()
{
scroll = Integer.MAX_VALUE;
clampScroll();
}
protected void clampScroll()
{
int stretch = 3, overreach = getHeight() / 2;
int max = getMaxScroll();
max = Math.max(max, 0);
if (scroll < -overreach)
{
scroll = -overreach;
lastDelta = 0;
}
else if (scroll > max + overreach)
{
scroll = max + overreach;
lastDelta = 0;
}
else if (scroll < 0)
{
if (scroll >= -stretch)
scroll = 0;
else if (!touching)
scroll -= scroll / stretch;
}
else if (scroll > max)
{
if (scroll <= max + stretch)
scroll = max;
else if (!touching)
scroll += (max - scroll) / stretch;
}
}
protected int getMaxScroll()
{
int rowCount = (int)Math.ceil((double)getChildCount()/colCount), max = rowCount * childSize + (rowCount + 1) * padding - getHeight();
return max;
}
public int getLastIndex()
{
return getIndexFromCoor(lastX, lastY);
}
//OTHER METHODS
public void setOnRearrangeListener(OnRearrangeListener l)
{
this.onRearrangeListener = l;
}
public void setOnItemClickListener(OnItemClickListener l)
{
this.onItemClickListener = l;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}
}
}

+ 49
- 48
OneToolbox/src/com/langerhans/one/mods/PrismMods.java View File

@@ -168,14 +168,14 @@ public class PrismMods {
public static void execHook_20Folder_code(final LoadPackageParam lpparam) {
findAndHookMethod("com.htc.launcher.folder.Folder", lpparam.classLoader, "isFull", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
findAndHookMethod("com.htc.launcher.folder.Folder", lpparam.classLoader, "isFull", findClass("com.htc.launcher.folder.FolderInfo", lpparam.classLoader), new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
@@ -183,21 +183,21 @@ public class PrismMods {
XposedBridge.hookAllConstructors(findClass("com.htc.launcher.folder.Folder", lpparam.classLoader), new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
setBooleanField(param.thisObject, "m_bMultiplePage", true);
setBooleanField(param.thisObject, "m_bMultiplePage", true);
setStaticIntField(param.thisObject.getClass(), "FOLDER_MAX_COUNT", 9999);
}
});
findAndHookMethod("com.htc.launcher.folder.Folder", lpparam.classLoader, "setMultiplePage", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(true);
}
});
findAndHookMethod("com.htc.launcher.pageview.CheckedAppsDataManager", lpparam.classLoader, "setMaxCheckedAmount", int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
setIntField(param.thisObject, "m_MaxCheckedAmount", 9999);
}
});
@@ -207,14 +207,14 @@ public class PrismMods {
if (XMain.senseVersion.compareTo(new Version("5.5")) >= 0) {
findAndHookMethod("com.htc.launcher.bar.BarController", lpparam.classLoader, "setStatusBarTransparent", Context.class, boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});
}else {
findAndHookMethod("com.htc.launcher.bar.BarController", lpparam.classLoader, "setStatusBarTransparent", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});
@@ -299,7 +299,7 @@ public class PrismMods {
boolean isAllAppsOpen = false;
Object m_launcher = XposedHelpers.getObjectField(param.thisObject, "m_launcher");
if (m_launcher != null)
isAllAppsOpen = (Boolean)XposedHelpers.callMethod(m_launcher, "isAllAppsShown");
isAllAppsOpen = (Boolean)XposedHelpers.callMethod(m_launcher, "isAllAppsShown");
if (isAllAppsOpen)
param.args[0] = 0;
@@ -308,7 +308,7 @@ public class PrismMods {
}
});
// Animate Workspace alpha during transition between Workspace and AllApps
// Animate Workspace alpha during transition between Workspace and AllApps
final Class<?> Properties = XposedHelpers.findClass("com.htc.launcher.LauncherViewPropertyAnimator.Properties", lpparam.classLoader);
findAndHookMethod("com.htc.launcher.LauncherViewPropertyAnimator", lpparam.classLoader, "start", new XC_MethodHook() {
@Override
@@ -346,7 +346,7 @@ public class PrismMods {
}
});
*/
} else {
} else {
findAndHookMethod("com.htc.launcher.pageview.AllAppsPagedViewHost", lpparam.classLoader, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
@@ -357,7 +357,7 @@ public class PrismMods {
((RelativeLayout)vp).getBackground().setAlpha(transparency);
} else if (vp instanceof FrameLayout) {
((FrameLayout)vp).getBackground().setAlpha(transparency);
}
}
}
}
});
@@ -374,7 +374,7 @@ public class PrismMods {
m_workspace.setVisibility(4);
}
});
}
}
}
// Move Action Bar
@@ -391,7 +391,7 @@ public class PrismMods {
if (container.getClass().getCanonicalName().equalsIgnoreCase(feedClass)) {
Resources res = m_headerActionBar.getContext().getResources();
lp.topMargin = res.getDimensionPixelSize(res.getIdentifier("header_height", "dimen", "com.htc.launcher"));
} else {
} else {
lp.topMargin = 0;
}
m_headerActionBar.setLayoutParams(lp);
@@ -407,7 +407,7 @@ public class PrismMods {
int m_nControllerState = XposedHelpers.getIntField(param.thisObject, "m_nControllerState");
Object m_AllAppsPagedView = XposedHelpers.getObjectField(param.thisObject, "m_AllAppsPagedView");
View m_headerContent = (View)XposedHelpers.getObjectField(param.args[0], "m_headerContent");
m_headerContent.setVisibility(8);
m_headerContent.setVisibility(8);
if (m_nControllerState == 1) {
XposedHelpers.callMethod(param.args[0], "attachTo", m_AllAppsPagedView);
XposedHelpers.callMethod(param.thisObject, "addActionBarListenerToMasthead", param.args[0]);
@@ -418,7 +418,7 @@ public class PrismMods {
} catch (NoSuchMethodError e){
Object m_AllAppsDataManager = XposedHelpers.getObjectField(param.thisObject, "m_AllAppsDataManager");
XposedHelpers.callMethod(param.thisObject, "updateSortType", XposedHelpers.callMethod(param.args[0], "getActionBar"), XposedHelpers.callMethod(m_AllAppsDataManager, "getAppSort"));
}
}
}
XposedHelpers.findField(param.thisObject.getClass(), "m_masthead").set(param.thisObject, param.args[0]);
param.setResult(null);
@@ -467,7 +467,7 @@ public class PrismMods {
int m_nPageLayoutPaddingTop = XposedHelpers.getIntField(param.thisObject, "m_nPageLayoutPaddingTop");
XposedHelpers.setIntField(param.thisObject, "m_nPageLayoutPaddingTop", (int)Math.round((float)m_nPageLayoutPaddingTop/1.5));
}
});
});
}

public static void execHook_AppDrawerGridSizes(LoadPackageParam lpparam) {
@@ -508,7 +508,7 @@ public class PrismMods {
display.getSize(size);
XposedHelpers.setIntField(param.thisObject, "m_nItemViewWidth", Math.round(size.x / (cellX + 0.5f)));
XposedHelpers.setIntField(param.thisObject, "m_nItemViewHeight", Math.round(size.y / (cellY + 1.5f)));
}
}
}
});

@@ -588,7 +588,7 @@ public class PrismMods {
//m_nEditLayoutPageSpacing
//param.args[4] = 300;
}
});
});
}

// Add 5x5, 4x6 and 5x6 grid options to dialog
@@ -596,12 +596,12 @@ public class PrismMods {
int apps_grid_option = resparam.res.getIdentifier("apps_grid_option", "array", "com.htc.launcher");
String[] gridSizes = resparam.res.getStringArray(apps_grid_option);
final int n = gridSizes.length;
gridSizes = Arrays.copyOf(gridSizes, n + 3);
gridSizes[n] = "5 × 5";
gridSizes[n + 1] = "4 × 6";
gridSizes[n + 2] = "5 × 6";
final int n = gridSizes.length;
gridSizes = Arrays.copyOf(gridSizes, n + 3);
gridSizes[n] = "5 × 5";
gridSizes[n + 1] = "4 × 6";
gridSizes[n + 2] = "5 × 6";
resparam.res.setReplacement(apps_grid_option, gridSizes);
}
@@ -619,7 +619,7 @@ public class PrismMods {
itemlabel = (TextView) ((LinearLayout) item).getChildAt(1);
itemlabel.setPadding(itemlabel.getPaddingLeft(), itemlabel.getPaddingTop(), itemlabel.getPaddingRight(), 0);
}
if (itemlabel != null) {
if (gridSizeVal == 3 || gridSizeVal == 4)
itemlabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.73f * itemlabel.getTextSize());
@@ -702,13 +702,13 @@ public class PrismMods {
float density = helperContext.getResources().getDisplayMetrics().density;
SWIPE_MIN_DISTANCE = Math.round(100 * density);
SWIPE_MAX_OFF_PATH = Math.round(85 * density);
SWIPE_THRESHOLD_VELOCITY = Math.round(65 * density);
SWIPE_THRESHOLD_VELOCITY = Math.round(65 * density);
}
@Override
public boolean onDown(MotionEvent e) {
return true;
}
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
@@ -726,7 +726,7 @@ public class PrismMods {
case 7: return GlobalActions.launchApp(helperContext, 1);
case 8: return GlobalActions.toggleThis(helperContext, Integer.parseInt(XMain.pref.getString("pref_key_prism_swipedown_toggle", "0")));
case 12: return GlobalActions.launchShortcut(helperContext, 1);
default: return false;
default: return false;
}
}
@@ -756,7 +756,7 @@ public class PrismMods {
try {
findAndHookMethod("com.htc.launcher.util.Protection", lpparam.classLoader, "isFeedEnabled", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
@@ -835,8 +835,8 @@ public class PrismMods {
@Override
public boolean onDown(MotionEvent e) {
return true;
}
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
@@ -853,7 +853,7 @@ public class PrismMods {
case 7: return GlobalActions.launchApp(helperContext, 5);
case 8: return GlobalActions.toggleThis(helperContext, Integer.parseInt(XMain.pref.getString("pref_key_prism_swiperight_toggle", "0")));
case 12: return GlobalActions.launchShortcut(helperContext, 5);
default: return false;
default: return false;
}
}
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE_HORIZ && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
@@ -867,7 +867,7 @@ public class PrismMods {
case 7: return GlobalActions.launchApp(helperContext, 6);
case 8: return GlobalActions.toggleThis(helperContext, Integer.parseInt(XMain.pref.getString("pref_key_prism_swipeleft_toggle", "0")));
case 12: return GlobalActions.launchShortcut(helperContext, 6);
default: return false;
default: return false;
}
}

@@ -896,9 +896,10 @@ public class PrismMods {
}
public static void createAndShowPopup(ViewGroup m_workspace, final Activity launcher) {
if (m_workspace == null) if (launcher != null) m_workspace = (ViewGroup)XposedHelpers.getObjectField(launcher, "m_workspace");
ViewGroup m_workspace_local = m_workspace;
if (m_workspace_local == null) if (launcher != null) m_workspace_local = (ViewGroup)XposedHelpers.getObjectField(launcher, "m_workspace");
if (popup == null) {
popup = new HtcPopupWindow(m_workspace.getContext());
popup = new HtcPopupWindow(m_workspace_local.getContext());
popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
popup.setTouchable(true);
@@ -906,7 +907,7 @@ public class PrismMods {
popup.setOutsideTouchable(true);
}
ListView options = new ListView(m_workspace.getContext());
ListView options = new ListView(m_workspace_local.getContext());
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
ListAdapter listAdapter = new PopupAdapter(options.getContext(), Helpers.xl10n_array(modRes, R.array.home_menu), false);
options.setFocusableInTouchMode(true);
@@ -928,20 +929,20 @@ public class PrismMods {
} else if (position == 5) {
Settings.System.putString(view.getContext().getContentResolver(), "lock_homescreen_dragging", String.valueOf(!Boolean.parseBoolean(Settings.System.getString(view.getContext().getContentResolver(), "lock_homescreen_dragging"))));
}
}
}
});
options.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN) {
popup.dismiss();
return true;
}
return false;
}
options.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN) {
popup.dismiss();
return true;
}
return false;
}
});
popup.setContentView(options);
popup.showAtLocation(m_workspace, Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
popup.showAtLocation(m_workspace_local, Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
}
public static void execHook_SevenScreens(final LoadPackageParam lpparam) {


+ 233
- 235
OneToolbox/src/com/langerhans/one/mods/SysUIMods.java View File

@@ -136,7 +136,7 @@ public class SysUIMods {
//Enable mEQS
findAndHookMethod("com.android.systemui.statusbar.StatusBarFlag", lpparam.classLoader, "loadMinorQuickSetting", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(true);
}
});
@@ -162,33 +162,33 @@ public class SysUIMods {
}
}else
{
paramArgs = (int[]) param.args[0];
paramArgs = (int[]) param.args[0];
}
if (paramArgs == null || paramArgs.length == 0)
paramArgs = QS_DEFAULT;
int i = QS_MAPPING.length;
int j = 0;
for (int k = paramArgs.length; j < k; j++)
{
int i1 = paramArgs[j];
if (i1 >= 0 && i1 < i)
qsContent.add(QS_MAPPING[i1]);
}
qsContent2 = new ArrayList<String>();
int l = 0;
do
{
if (l >= qsContent.size())
break;
if (!((String)qsContent.get(l)).equals("user_card"))
qsContent2.add(qsContent.get(l));
int j = 0;
for (int k = paramArgs.length; j < k; j++)
{
int i1 = paramArgs[j];
if (i1 >= 0 && i1 < i)
qsContent.add(QS_MAPPING[i1]);
}
qsContent2 = new ArrayList<String>();
int l = 0;
do
{
if (l >= qsContent.size())
break;
if (!((String)qsContent.get(l)).equals("user_card"))
qsContent2.add(qsContent.get(l));
// if (qsContent2.size() == 5)
// break;
l++;
} while (true);
setObjectField(param.thisObject, "qsContent", qsContent);
setObjectField(param.thisObject, "qsContent2", qsContent2);
l++;
} while (true);
setObjectField(param.thisObject, "qsContent", qsContent);
setObjectField(param.thisObject, "qsContent2", qsContent2);
return null;
}
});
@@ -198,17 +198,17 @@ public class SysUIMods {
{
findAndHookMethod("com.android.systemui.statusbar.phone.QuickSettings", lpparam.classLoader, "repositionQuickSettingTile", ViewGroup.class, ArrayList.class, boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ViewGroup qsContainer = (ViewGroup) getObjectField(param.thisObject, "mContainerView2");
if(!param.args[0].equals(qsContainer))
return;
WindowManager wm = (WindowManager) qsContainer.getContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager wm = (WindowManager) qsContainer.getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point displaySize = new Point();
display.getSize(displaySize);
int displayWidth = displaySize.x;
for(int k = 0; k < qsContainer.getChildCount(); k++)
for(int k = 0; k < qsContainer.getChildCount(); k++)
{
LinearLayout tmp = (LinearLayout) qsContainer.getChildAt(k);
LinearLayout.LayoutParams tmpParams = (LinearLayout.LayoutParams) tmp.getLayoutParams();
@@ -221,7 +221,7 @@ public class SysUIMods {
qsImg.setPadding(0, 0, 0, 20);
}
}
qsContainer.invalidate();
qsContainer.invalidate();
}
});
}
@@ -229,7 +229,7 @@ public class SysUIMods {
//Makes them scrolling. Showing 5 at once.
findAndHookMethod("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader, "makeStatusBarView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
FrameLayout mStatusBarWindow = (FrameLayout) getObjectField(param.thisObject, "mStatusBarWindow");
if (mStatusBarWindow != null)
{
@@ -292,7 +292,7 @@ public class SysUIMods {
public static void execHook_AospRecent(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.statusbar.StatusBarFlag", lpparam.classLoader, "isHtcStyleRecentApp", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
@@ -302,7 +302,7 @@ public class SysUIMods {
{
findAndHookMethod("com.android.systemui.recent.RecentsActivity", lpparam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
BroadcastReceiver mIntentReceiver = (BroadcastReceiver) getObjectField(param.thisObject, "mIntentReceiver");
IntentFilter mIntentFilter = (IntentFilter) getObjectField(param.thisObject, "mIntentFilter");
if(mIntentReceiver != null && mIntentFilter != null) {
@@ -324,7 +324,7 @@ public class SysUIMods {
LinearLayout statusBarContents = (LinearLayout) liparam.view.findViewById(resparam.res.getIdentifier("status_bar_contents", "id", "com.android.systemui"));
if(statusBar != null && clock != null && systemIconArea != null && statusBarContents != null)
{
{
clock.setGravity(Gravity.CENTER);
clock.setPadding(0, 0, 0, 0);
LinearLayout clockContainer = new LinearLayout(clock.getContext());
@@ -425,8 +425,6 @@ public class SysUIMods {
}
});
} catch (Throwable t) {
// TODO: handle exception
// ^YOU DON'T TELL ME WHAT I HAVE TO DO ECLIPSE!
}
//Helper class to hold needed variables for later methods (because nested methods and final and blah blah... Couldn't think of a better solution)
@@ -523,7 +521,7 @@ public class SysUIMods {
{
final XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
FrameLayout mStatusBarWindow = (FrameLayout) getObjectField(param.thisObject, "mStatusBarWindow");
FrameLayout mStatusBarWindow = (FrameLayout) getObjectField(param.thisObject, "mStatusBarWindow");
LinearLayout panel = (LinearLayout) mStatusBarWindow.findViewById(mStatusBarWindow.getResources().getIdentifier("panel", "id", "com.android.systemui"));
//Inflate the slider layout
@@ -622,16 +620,16 @@ public class SysUIMods {
@SuppressLint("DefaultLocale")
private static ArrayList<String> humanReadableByteCount(long bytes) {
ArrayList<String> out = new ArrayList<String>();
if (bytes < 1024) {
out.add(String.valueOf(bytes));
out.add("B/s");
return out;
}
int exp = (int) (Math.log(bytes) / Math.log(1024));
char pre = "KMGTPE".charAt(exp-1);
out.add(String.format("%.1f", bytes / Math.pow(1024, exp)));
out.add(String.format("%sB/s", pre));
return out;
if (bytes < 1024) {
out.add(String.valueOf(bytes));
out.add("B/s");
return out;
}
int exp = (int) (Math.log(bytes) / Math.log(1024));
char pre = "KMGTPE".charAt(exp-1);
out.add(String.format("%.1f", bytes / Math.pow(1024, exp)));
out.add(String.format("%sB/s", pre));
return out;
}
private static BroadcastReceiver connectChanged = new BroadcastReceiver() {
@@ -716,7 +714,7 @@ public class SysUIMods {
long rxBytes = TrafficStats.getTotalRxBytes();
long txBytes = TrafficStats.getTotalTxBytes();
long newBytes = 0;
if (rxBytes != -1L && txBytes != -1L) newBytes = rxBytes + txBytes;
if (rxBytes != -1L && txBytes != -1L) newBytes = rxBytes + txBytes;
long newBytesFixed = newBytes - bytesTotal;
if (newBytesFixed < 0 || bytesTotal == 0) newBytesFixed = 0;
long speed = Math.round(newBytesFixed/2);
@@ -763,12 +761,12 @@ public class SysUIMods {
}
//Need this to listen for settings changes
protected static class SettingsObserver extends ContentObserver {
protected static class SettingsObserver extends ContentObserver {
private HtcCheckBox cb = null;
private HtcSeekBar sb = null;
private ContentResolver cr;
public SettingsObserver(Handler handler) {
super(handler);
super(handler);
}
public void setup(HtcCheckBox cb, HtcSeekBar sb, ContentResolver cr) {
this.cb = cb;
@@ -778,7 +776,7 @@ public class SysUIMods {
@Override
public void onChange(boolean selfChange) {
this.onChange(selfChange, null);
}
}
@Override
public void onChange(boolean selfChange, Uri uri) {
if (!this.sb.isPressed()) try {
@@ -787,7 +785,7 @@ public class SysUIMods {
} catch (SettingNotFoundException e) {
//No brightness setting?
}
}
}
}
/*
public static void execHook_DisableEQS(final InitPackageResourcesParam resparam) {
@@ -798,23 +796,23 @@ public class SysUIMods {
public static void execHook_DisableEQS(final LoadPackageParam lpparam) {
XposedBridge.hookAllConstructors(findClass("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader), new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
View.OnClickListener newButtonOnClick = new View.OnClickListener() {
public void onClick(View view) {
XposedHelpers.callMethod(param.thisObject, "startActivityDismissingKeyguard", new Intent("android.settings.SETTINGS"), true);
return;
}
};
XposedHelpers.findField(param.thisObject.getClass(), "mSettingsButtonListener").set(param.thisObject, newButtonOnClick);
public void onClick(View view) {
XposedHelpers.callMethod(param.thisObject, "startActivityDismissingKeyguard", new Intent("android.settings.SETTINGS"), true);
return;
}
};
XposedHelpers.findField(param.thisObject.getClass(), "mSettingsButtonListener").set(param.thisObject, newButtonOnClick);
}
});
findAndHookMethod("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader, "makeStatusBarView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ImageView mSettingsButton = (ImageView)XposedHelpers.findField(param.thisObject.getClass(), "mSettingsButton").get(param.thisObject);
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
mSettingsButton.setImageDrawable(modRes.getDrawable(R.drawable.ic_sysbar_quicksettings));
mSettingsButton.setImageDrawable(modRes.getDrawable(R.drawable.ic_sysbar_quicksettings));
}
});
}
@@ -823,7 +821,7 @@ public class SysUIMods {
public static void execHook_hEQSLongClick(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.statusbar.phone.QuickSettingsTileView", lpparam.classLoader, "onAttachedToWindow", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
final LinearLayout thisTile = (LinearLayout) param.thisObject;
thisTile.setLongClickable(true);
thisTile.setOnLongClickListener(new OnLongClickListener() {
@@ -849,7 +847,7 @@ public class SysUIMods {
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Screenshots");
if (file != null)
{
mBucketId = file.getAbsolutePath().toLowerCase().hashCode();
mBucketId = file.getAbsolutePath().toLowerCase().hashCode();
}
settingIntent = new Intent("com.htc.album.action.VIEW_FOLDER_IN_THUMBNAIL");
settingIntent.putExtra("folder_type", (new StringBuilder()).append("collection_regular_bucket ").append(mBucketId).append(" Screenshots").toString());
@@ -866,7 +864,7 @@ public class SysUIMods {
callMethod(viewTag, "startSettingsActivity", intentPkg, intentClass);
else if (!(settingIntent == null))
callMethod(viewTag, "startSettingsActivity", settingIntent);
else
else
callMethod(viewTag, "startSettingsActivity", intentClass);
}
}
@@ -879,22 +877,22 @@ public class SysUIMods {
// Pinch to clear all recent apps
public static void execHook_RecentAppsInit(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.recent.RecentAppFxActivity", lpparam.classLoader, "onCreate", "android.os.Bundle", new XC_MethodHook(){
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
final GridView recentGridView = (GridView)XposedHelpers.findField(param.thisObject.getClass(), "mRecentGridView").get(param.thisObject);
killedEmAll = false;
gridViewObject = param.thisObject;
gridViewContext = recentGridView.getContext();
gridViewSelf = recentGridView;
}
});
findAndHookMethod("com.android.systemui.recent.RecentAppFxActivity", lpparam.classLoader, "onCreate", "android.os.Bundle", new XC_MethodHook(){
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
final GridView recentGridView = (GridView)XposedHelpers.findField(param.thisObject.getClass(), "mRecentGridView").get(param.thisObject);
killedEmAll = false;
gridViewObject = param.thisObject;
gridViewContext = recentGridView.getContext();
gridViewSelf = recentGridView;
}
});
}
public static void execHook_RecentAppsClearTouch(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.recent.RecentsGridView", lpparam.classLoader, "onTouchEvent", MotionEvent.class, new TouchListenerOnTouch());
findAndHookMethod("com.android.systemui.recent.RecentsGridView", lpparam.classLoader, "onInterceptTouchEvent", MotionEvent.class, new TouchListenerOnTouchIntercept());
findAndHookMethod("com.android.systemui.recent.RecentsGridView", lpparam.classLoader, "onTouchEvent", MotionEvent.class, new TouchListenerOnTouch());
findAndHookMethod("com.android.systemui.recent.RecentsGridView", lpparam.classLoader, "onInterceptTouchEvent", MotionEvent.class, new TouchListenerOnTouchIntercept());
}
private static GridView gridViewSelf;
@@ -938,7 +936,7 @@ public class SysUIMods {
if (am == null)
am = ((ActivityManager)gridViewContext.getSystemService("activity"));
if (am != null)
if (am != null)
XposedHelpers.callMethod(am, "removeTask", XposedHelpers.getIntField(gridViewItemTag, "persistentTaskId"), Integer.valueOf(1));
gridViewItem.startAnimation(terminateAnimation(i, cnt, animType, currApp));
@@ -973,12 +971,12 @@ public class SysUIMods {
drop.setStartOffset((i - cnt) * 70);
drop.setInterpolator(AnimationUtils.loadInterpolator(gridViewContext, android.R.anim.linear_interpolator));
localAnimationSet.addAnimation(drop);
} else {
} else {
fadeOut.setDuration(500l);
fadeOut.setStartOffset(cnt * 50);
fadeOut.setInterpolator(AnimationUtils.loadInterpolator(gridViewContext, android.R.anim.accelerate_interpolator));
ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
shrink.setDuration(500l);
shrink.setStartOffset(cnt * 50);
shrink.setInterpolator(AnimationUtils.loadInterpolator(gridViewContext, android.R.anim.accelerate_decelerate_interpolator));
@@ -996,7 +994,7 @@ public class SysUIMods {
try { if (i > 3) Thread.sleep((i + 1) * 15); } catch (Exception e) {}
if (currApp == null) closeRecents();
}
}).start();
}).start();
}
public void onAnimationRepeat(Animation paramAnonymousAnimation) {}
public void onAnimationStart(Animation paramAnonymousAnimation) {}
@@ -1006,16 +1004,16 @@ public class SysUIMods {
// Listener for scale gestures
private static class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
killedEmAll = true;
@Override
public boolean onScale(ScaleGestureDetector detector) {
killedEmAll = true;
try {
terminateAll(1);
} catch (Throwable t) {
XposedBridge.log(t);
}
return true;
}
return true;
}
}
// Listener for swipe gestures
@@ -1040,9 +1038,9 @@ public class SysUIMods {
try {
if (Math.abs(e1.getX() - e2.getX()) > SWIPE_MAX_OFF_PATH) return false;
if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
killedEmAll = true;
killedEmAll = true;
terminateAll(0);
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
@@ -1051,56 +1049,56 @@ public class SysUIMods {
}
private static void initDetectors(MethodHookParam param) throws Throwable {
final GridView recentGridView = (GridView)param.thisObject;
if (mScaleDetector == null) mScaleDetector = new ScaleGestureDetector(recentGridView.getContext(), new ScaleListener());
if (mDetector == null) mDetector = new GestureDetector(recentGridView.getContext(), new SwipeListener((recentGridView.getContext())));
final GridView recentGridView = (GridView)param.thisObject;
if (mScaleDetector == null) mScaleDetector = new ScaleGestureDetector(recentGridView.getContext(), new ScaleListener());
if (mDetector == null) mDetector = new GestureDetector(recentGridView.getContext(), new SwipeListener((recentGridView.getContext())));
}
// Detect second finger and cancel action if some app thumbnail was pressed
private static class TouchListenerOnTouchIntercept extends XC_MethodHook {
MotionEvent ev = null;
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
initDetectors(param);
ev = (MotionEvent)param.args[0];
if (ev == null) return;
mScaleDetector.onTouchEvent(ev);
mDetector.onTouchEvent(ev);
final int action = ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: {
}
case MotionEvent.ACTION_POINTER_DOWN: {
if (ev.getPointerCount() == 2)
try {
param.setResult(Boolean.valueOf(true));
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
initDetectors(param);
ev = (MotionEvent)param.args[0];
if (ev == null) return;
mScaleDetector.onTouchEvent(ev);
mDetector.onTouchEvent(ev);
final int action = ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: {
}
case MotionEvent.ACTION_POINTER_DOWN: {
if (ev.getPointerCount() == 2)
try {
param.setResult(Boolean.valueOf(true));
} catch (Throwable thw) {
param.setThrowable(thw);
}
}
}
}
}
}
}
}
// Detect scale/swipe gestures
private static class TouchListenerOnTouch extends XC_MethodHook {
MotionEvent ev = null;
@Override
MotionEvent ev = null;
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
}
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if (killedEmAll == true) return;
initDetectors(param);
ev = (MotionEvent)param.args[0];
if (ev == null) return;
mScaleDetector.onTouchEvent(ev);
mDetector.onTouchEvent(ev);
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if (killedEmAll == true) return;
initDetectors(param);
ev = (MotionEvent)param.args[0];
if (ev == null) return;
mScaleDetector.onTouchEvent(ev);
mDetector.onTouchEvent(ev);
}
}
@@ -1122,7 +1120,7 @@ public class SysUIMods {
int i = 0;
for (Integer e : list) ret[i++] = e.intValue();
return ret;
}
}
private static List<ActivityManager.RunningAppProcessInfo> procs = null;
private static String ramTAG = "RAMView";
@@ -1132,93 +1130,93 @@ public class SysUIMods {
TextView ramView = null;
String ramText = null;
@Override
protected Void doInBackground(final MethodHookParam... params) {
try {
final MethodHookParam param = params[0];
theView = (ViewGroup)param.getResult();
if (theView != null) {
int pos = (Integer)param.args[0];
Object viewholder = theView.getTag();
ArrayList<?> mRecentTaskDescriptions = (ArrayList<?>)XposedHelpers.getObjectField(XposedHelpers.getSurroundingThis(param.thisObject), "mRecentTaskDescriptions");
if (mRecentTaskDescriptions == null) return null;
int taskPos = mRecentTaskDescriptions.size() - pos - 1;
if (taskPos < 0) return null;
Object taskdescription = mRecentTaskDescriptions.get(taskPos);
if (taskdescription == null) return null;
ResolveInfo resolveInfo = (ResolveInfo)XposedHelpers.getObjectField(taskdescription, "resolveInfo");
final ActivityManager am = (ActivityManager)theView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
if (pos == 0 || procs == null) procs = am.getRunningAppProcesses();
final List<Integer> pids_mem = new ArrayList<Integer>();
for (ActivityManager.RunningAppProcessInfo process: procs)
if (process.processName.equals(resolveInfo.activityInfo.processName))
if (!pids_mem.contains(process.pid)) pids_mem.add(process.pid);
MemoryInfo[] mi = am.getProcessMemoryInfo(toIntArray(pids_mem));
int memTotal = 0;
for (MemoryInfo memInfo: mi)
memTotal += memInfo.getTotalPss();
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
ramText = String.format("%.1f", (float)(memTotal / 1024.0f)) + Helpers.xl10n(modRes, R.string.ram_mb);
if (theView.findViewWithTag(ramTAG) == null) {
ramView = new TextView(theView.getContext());
ramView.setTag(ramTAG);
ramView.setText(ramText);
final TextView text1 = (TextView)XposedHelpers.getObjectField(viewholder, "text1");
ramView.setTextSize(TypedValue.COMPLEX_UNIT_PX, text1.getTextSize());
ramView.setEllipsize(TruncateAt.END);
ramView.setSingleLine();
ramView.setTypeface(text1.getTypeface());
ramView.setTextColor(Color.argb(127, Color.red(text1.getCurrentTextColor()), Color.green(text1.getCurrentTextColor()), Color.blue(text1.getCurrentTextColor())));
if (XMain.senseVersion.compareTo(new Version("5.5")) == -1) {
RelativeLayout.LayoutParams p0 = (RelativeLayout.LayoutParams)text1.getLayoutParams();
ImageView img = (ImageView)XposedHelpers.getObjectField(viewholder, "img");
p0.setMargins(img.getPaddingLeft(), p0.topMargin, img.getPaddingRight(), 0);
ramView.setLayoutParams(p0);
ramView.setGravity(Gravity.CENTER);
ramView.setBackground(new ColorDrawable(Color.parseColor("#9F333333")));
ramView.setTranslationY(-32f * theView.getContext().getResources().getDisplayMetrics().density);
} else {
FrameLayout.LayoutParams p0 = (FrameLayout.LayoutParams)text1.getLayoutParams();
ramView.setLayoutParams(p0);
ramView.setGravity(Gravity.CENTER_VERTICAL);
ramView.setBackground(text1.getBackground());
ramView.setPadding(text1.getPaddingLeft(), text1.getPaddingTop(), text1.getPaddingRight(), text1.getPaddingBottom());
ramView.setTranslationY(-29.7f * theView.getContext().getResources().getDisplayMetrics().density);
}
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
return null;
}
@Override
protected Void doInBackground(final MethodHookParam... params) {
try {
final MethodHookParam param = params[0];
theView = (ViewGroup)param.getResult();
if (theView != null) {
int pos = (Integer)param.args[0];
Object viewholder = theView.getTag();
ArrayList<?> mRecentTaskDescriptions = (ArrayList<?>)XposedHelpers.getObjectField(XposedHelpers.getSurroundingThis(param.thisObject), "mRecentTaskDescriptions");
if (mRecentTaskDescriptions == null) return null;
int taskPos = mRecentTaskDescriptions.size() - pos - 1;
if (taskPos < 0) return null;
Object taskdescription = mRecentTaskDescriptions.get(taskPos);
if (taskdescription == null) return null;
ResolveInfo resolveInfo = (ResolveInfo)XposedHelpers.getObjectField(taskdescription, "resolveInfo");
final ActivityManager am = (ActivityManager)theView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
if (pos == 0 || procs == null) procs = am.getRunningAppProcesses();
final List<Integer> pids_mem = new ArrayList<Integer>();
for (ActivityManager.RunningAppProcessInfo process: procs)
if (process.processName.equals(resolveInfo.activityInfo.processName))
if (!pids_mem.contains(process.pid)) pids_mem.add(process.pid);
MemoryInfo[] mi = am.getProcessMemoryInfo(toIntArray(pids_mem));
int memTotal = 0;
for (MemoryInfo memInfo: mi)
memTotal += memInfo.getTotalPss();
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
ramText = String.format("%.1f", (float)(memTotal / 1024.0f)) + Helpers.xl10n(modRes, R.string.ram_mb);
if (theView.findViewWithTag(ramTAG) == null) {
ramView = new TextView(theView.getContext());
ramView.setTag(ramTAG);
ramView.setText(ramText);
final TextView text1 = (TextView)XposedHelpers.getObjectField(viewholder, "text1");
ramView.setTextSize(TypedValue.COMPLEX_UNIT_PX, text1.getTextSize());
ramView.setEllipsize(TruncateAt.END);
ramView.setSingleLine();
ramView.setTypeface(text1.getTypeface());
ramView.setTextColor(Color.argb(127, Color.red(text1.getCurrentTextColor()), Color.green(text1.getCurrentTextColor()), Color.blue(text1.getCurrentTextColor())));
if (XMain.senseVersion.compareTo(new Version("5.5")) == -1) {
RelativeLayout.LayoutParams p0 = (RelativeLayout.LayoutParams)text1.getLayoutParams();
ImageView img = (ImageView)XposedHelpers.getObjectField(viewholder, "img");
p0.setMargins(img.getPaddingLeft(), p0.topMargin, img.getPaddingRight(), 0);
ramView.setLayoutParams(p0);
ramView.setGravity(Gravity.CENTER);
ramView.setBackground(new ColorDrawable(Color.parseColor("#9F333333")));
ramView.setTranslationY(-32f * theView.getContext().getResources().getDisplayMetrics().density);
} else {
FrameLayout.LayoutParams p0 = (FrameLayout.LayoutParams)text1.getLayoutParams();
ramView.setLayoutParams(p0);
ramView.setGravity(Gravity.CENTER_VERTICAL);
ramView.setBackground(text1.getBackground());
ramView.setPadding(text1.getPaddingLeft(), text1.getPaddingTop(), text1.getPaddingRight(), text1.getPaddingBottom());
ramView.setTranslationY(-29.7f * theView.getContext().getResources().getDisplayMetrics().density);
}
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (theView != null)
if (theView.findViewWithTag(ramTAG) == null) {
if (ramView != null) theView.addView(ramView);
} else {
if (ramText != null)
((TextView)theView.findViewWithTag(ramTAG)).setText(ramText);
}
}
}
@Override
protected void onPostExecute(Void result) {
if (theView != null)
if (theView.findViewWithTag(ramTAG) == null) {
if (ramView != null) theView.addView(ramView);
} else {
if (ramText != null)
((TextView)theView.findViewWithTag(ramTAG)).setText(ramText);
}
}
}
public static void execHook_RAMInRecents(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.recent.RecentAppFxActivity.RecentGridViewAdapter", lpparam.classLoader, "getView", int.class, View.class, ViewGroup.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
// Text before actual data is available
ViewGroup theView = (ViewGroup)param.getResult();
if (theView != null && theView.findViewWithTag(ramTAG) != null)
((TextView)theView.findViewWithTag(ramTAG)).setText("...");
// Get RAM usage for the task of this view
if (theView != null && theView.findViewWithTag(ramTAG) != null)
((TextView)theView.findViewWithTag(ramTAG)).setText("...");
// Get RAM usage for the task of this view
new getRAMView().execute(param);
}
});
@@ -1229,10 +1227,10 @@ public class SysUIMods {
public static void execHook_RecentsLongTap(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.recent.RecentAppFxActivity.RecentGridViewAdapter", lpparam.classLoader, "getView", int.class, View.class, ViewGroup.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
final ViewGroup theView = (ViewGroup)param.getResult();
if (theView != null) {
theView.setOnLongClickListener(new OnLongClickListener() {
if (theView != null) {
theView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
try {
@@ -1251,7 +1249,7 @@ public class SysUIMods {
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
ListAdapter listAdapter = new PopupAdapter(options.getContext(), Helpers.xl10n_array(modRes, R.array.recents_menu), true);
options.setAdapter(listAdapter);
options.setFocusableInTouchMode(true);
options.setFocusableInTouchMode(true);
options.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@@ -1263,7 +1261,7 @@ public class SysUIMods {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", packageName, null));
intent.setComponent(intent.resolveActivity(view.getContext().getPackageManager()));
intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
view.getContext().startActivity(intent);
view.getContext().startActivity(intent);
} else if (position == 1) {
try {
theView.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)));
@@ -1291,14 +1289,14 @@ public class SysUIMods {
return false;
}
}
});
}
});
}
}
});
findAndHookMethod("com.android.systemui.recent.RecentAppFxActivity", lpparam.classLoader, "handleSwipe", View.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
if (popup != null) popup.dismiss();
}
});
@@ -1324,7 +1322,7 @@ public class SysUIMods {
totalC = total - totalLast;
}
workLast = work;
totalLast = total;
totalLast = total;
readStream.close();
readStream = new BufferedReader(new FileReader("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"));
@@ -1344,7 +1342,7 @@ public class SysUIMods {
public static void execHook_NotifDrawerHeaderSysInfo(final LoadPackageParam lpparam) {
XposedBridge.hookAllConstructors(findClass("com.android.systemui.statusbar.policy.DateView", lpparam.classLoader), new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
final TextView date = (TextView)param.thisObject;
OnClickListener ocl = new OnClickListener() {
@Override
@@ -1392,7 +1390,7 @@ public class SysUIMods {
findAndHookMethod("com.android.systemui.statusbar.policy.DateView", lpparam.classLoader, "updateClock", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if (isThreadActive) param.setResult(null);