Eric Kok
12 years ago
19 changed files with 250 additions and 104 deletions
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 848 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
@ -1,26 +1,11 @@
@@ -1,26 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- File created by the Android Action Bar Style Generator |
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime"> |
||||
|
||||
Copyright (C) 2011 The Android Open Source Project |
||||
Copyright (C) 2012 readyState Software Ltd |
||||
<item android:drawable="@drawable/pressed_background_transdroid2" android:state_selected="true"/> |
||||
<item android:drawable="@drawable/pressed_background_transdroid2" android:state_checked="true" /> |
||||
<item android:drawable="@drawable/pressed_background_transdroid2" android:state_activated="true"/> |
||||
<item android:drawable="@drawable/list_focused_transdroid2" android:state_focused="true" /> |
||||
<item android:drawable="@drawable/pressed_background_transdroid2" android:state_pressed="true"/> |
||||
<item android:drawable="@android:color/transparent"/> |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
||||
--> |
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:exitFadeDuration="@android:integer/config_mediumAnimTime" > |
||||
<item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/list_focused_transdroid2" /> |
||||
<item android:state_pressed="false" android:state_checked="true" android:drawable="@drawable/list_focused_transdroid2" /> |
||||
<item android:state_pressed="true" android:drawable="@drawable/pressed_background_transdroid2" /> |
||||
<item android:drawable="@android:color/transparent" /> |
||||
</selector> |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
package org.transdroid.core.gui.lists; |
||||
|
||||
import org.transdroid.daemon.Priority; |
||||
|
||||
import android.content.Context; |
||||
import android.graphics.Canvas; |
||||
import android.graphics.Paint; |
||||
import android.graphics.RectF; |
||||
import android.util.AttributeSet; |
||||
import fr.marvinlabs.widget.CheckableRelativeLayout; |
||||
|
||||
public class TorrentFilePriorityLayout extends CheckableRelativeLayout { |
||||
|
||||
private final float scale = getContext().getResources().getDisplayMetrics().density; |
||||
private final int WIDTH = (int) (5 * scale + 0.5f); |
||||
|
||||
private Priority priority = null; |
||||
private final Paint offPaint = new Paint(); |
||||
private final Paint lowPaint = new Paint(); |
||||
private final Paint highPaint = new Paint(); |
||||
private final Paint normalPaint = new Paint(); |
||||
private final RectF fullRect = new RectF(); |
||||
|
||||
public TorrentFilePriorityLayout(Context context) { |
||||
super(context); |
||||
initPaints(); |
||||
setWillNotDraw(false); |
||||
} |
||||
|
||||
public TorrentFilePriorityLayout(Context context, AttributeSet attrs) { |
||||
super(context, attrs); |
||||
initPaints(); |
||||
setWillNotDraw(false); |
||||
} |
||||
|
||||
private void initPaints() { |
||||
offPaint.setColor(0xFF9E9E9E); // Grey
|
||||
lowPaint.setColor(0x778ACC12); // Very Light green
|
||||
normalPaint.setColor(0xBB8ACC12); // Light green
|
||||
highPaint.setColor(0xFF8ACC12); // Green
|
||||
} |
||||
|
||||
public void setPriority(Priority priority) { |
||||
this.priority = priority; |
||||
this.invalidate(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onDraw(Canvas canvas) { |
||||
super.onDraw(canvas); |
||||
|
||||
int height = getHeight(); |
||||
int width = WIDTH; |
||||
fullRect.set(0, 0, width, height); |
||||
|
||||
if (priority == null) { |
||||
return; |
||||
} |
||||
|
||||
switch (priority) { |
||||
case Low: |
||||
canvas.drawRect(fullRect, lowPaint); |
||||
break; |
||||
case Normal: |
||||
canvas.drawRect(fullRect, normalPaint); |
||||
break; |
||||
case High: |
||||
canvas.drawRect(fullRect, highPaint); |
||||
break; |
||||
default: // Off
|
||||
canvas.drawRect(fullRect, offPaint); |
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue