Skip to content

Commit

Permalink
Add support for app to operate in Landscape mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew McMillan committed Sep 6, 2012
1 parent a1e1fbe commit b087b26
Show file tree
Hide file tree
Showing 13 changed files with 472 additions and 292 deletions.
3 changes: 2 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
android:uiOptions="splitActionBarWhenNarrow">
<activity
android:name=".FileExplorerTabActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:configChanges="screenSize|keyboardHidden"
android:screenOrientation="sensor"
android:uiOptions="splitActionBarWhenNarrow">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
Expand Down
Binary file added res/drawable-land-hdpi/category_bar_apk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_mask.9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_music.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_other.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_picture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-land-hdpi/category_bar_zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
702 changes: 426 additions & 276 deletions res/layout-land/file_explorer_category.xml

Large diffs are not rendered by default.

59 changes: 44 additions & 15 deletions src/net/micode/fileexplorer/CategoryBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,59 @@ public boolean setCategoryValue(int index, long value) {

@Override
protected void onDraw(Canvas canvas) {
int width = getWidth() - MARGIN * 2;
Drawable d = getDrawable(R.drawable.category_bar_empty);

int left = MARGIN;
Rect bounds = new Rect(left, 0, left + width, d.getIntrinsicHeight());
int width = getWidth() - MARGIN * 2;
int height = getHeight() - MARGIN * 2;
boolean isHorizontal = (width > height);

Rect bounds = null;
if ( isHorizontal )
bounds = new Rect(MARGIN, 0, MARGIN + width, d.getIntrinsicHeight());
else
bounds = new Rect(0, MARGIN, d.getIntrinsicWidth(), MARGIN + height);

int beginning = MARGIN;
if ( !isHorizontal ) beginning += height;
d.setBounds(bounds);
d.draw(canvas);
if (mFullValue != 0) {
for (Category c : categories) {
long value = (timer == null ? c.value : c.tmpValue);
int w = (int) (value * width / mFullValue);
if (w == 0)
continue;
bounds.left = left;
bounds.right = left + w;
d = getDrawable(c.resImg);
bounds.bottom = bounds.top + d.getIntrinsicHeight();
d.setBounds(bounds);
d.draw(canvas);
left += w;
if ( isHorizontal ) {
int w = (int) (value * width / mFullValue);
if (w == 0)
continue;
bounds.left = beginning;
bounds.right = beginning + w;
d = getDrawable(c.resImg);
bounds.bottom = bounds.top + d.getIntrinsicHeight();
d.setBounds(bounds);
d.draw(canvas);
beginning += w;
}
else {
int h = (int) (value * height / mFullValue);
if (h == 0)
continue;
bounds.bottom = beginning;
bounds.top = beginning - h;
d = getDrawable(c.resImg);
bounds.right = bounds.left + d.getIntrinsicWidth();
d.setBounds(bounds);
d.draw(canvas);
beginning -= h;
}
}
}
bounds.left = 0;
bounds.right = bounds.left + getWidth();
if ( isHorizontal ) {
bounds.left = 0;
bounds.right = bounds.left + getWidth();
}
else {
bounds.top = 0;
bounds.bottom = bounds.top + getHeight();
}
d = getDrawable(R.drawable.category_bar_mask);
d.setBounds(bounds);
d.draw(canvas);
Expand Down

0 comments on commit b087b26

Please sign in to comment.