Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
initial quota display implementation
  • Loading branch information
AndyScherzinger committed Aug 18, 2016
commit f8e0ee9ce1a89c3b724c70d794396245fb976fb3
2 changes: 1 addition & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<string name="drawer_item_on_device">On device</string>
<string name="drawer_item_settings">Settings</string>
<string name="drawer_item_uploads_list">Uploads</string>
<string name="drawer_quota">%1$s%2$s of %3$s%4$s used</string>
<string name="drawer_quota">%1$s of %2$s used</string>
<string name="drawer_close">Close</string>
<string name="drawer_open">Open</string>
<string name="prefs_category_general">General</string>
Expand Down
49 changes: 46 additions & 3 deletions src/com/owncloud/android/ui/activity/DrawerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.owncloud.android.MainApp;
Expand Down Expand Up @@ -120,6 +122,9 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
* accounts for the (max) three displayed accounts in the drawer header.
*/
private Account[] mAvatars = new Account[3];
private LinearLayout mQuotaView;
private ProgressBar mQuotaProgressBar;
private TextView mQuotaTextView;

/**
* Initializes the drawer, its content and highlights the menu item with the given id.
Expand All @@ -144,9 +149,8 @@ protected void setupDrawer() {
mAccountChooserToggle = (ImageView) findNavigationViewChildById(R.id.drawer_account_chooser_toogle);
mAccountChooserToggle.setImageResource(R.drawable.ic_down);
mIsAccountChooserActive = false;

mAccountMiddleAccountAvatar = (ImageView) findNavigationViewChildById(R.id.drawer_account_middle);
mAccountEndAccountAvatar = (ImageView) findNavigationViewChildById(R.id.drawer_account_end);
mAccountMiddleAccountAvatar = (ImageView) findViewById(R.id.drawer_account_middle);
mAccountEndAccountAvatar = (ImageView) findViewById(R.id.drawer_account_end);

// on pre lollipop the light theme adds a black tint to icons with white coloring
// ruining the generic avatars, so tinting for icons is deactivated pre lollipop
Expand All @@ -163,6 +167,12 @@ public void onClick(View v) {
toggleAccountList();
}
});

// Quota UI elements
mQuotaView = (LinearLayout) findNavigationViewChildById(R.id.drawer_quota);
mQuotaProgressBar = (ProgressBar) findNavigationViewChildById(R.id.drawer_quota_ProgressBar);
mQuotaTextView = (TextView) findNavigationViewChildById(R.id.drawer_quota_text);
DisplayUtils.colorPreLollipopHorizontalProgressBar(mQuotaProgressBar);
}

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
Expand Down Expand Up @@ -477,6 +487,39 @@ private void showMenu() {
}
}

/**
* shows or hides the quota UI elements.
*
* @param showQuota show/hide quota information
*/
private void showQuota(boolean showQuota) {
if (showQuota) {
mQuotaView.setVisibility(View.VISIBLE);
} else {
mQuotaView.setVisibility(View.GONE);
}
}

/**
* configured the quota to be displayed.
*
* @param usedSpace the used space
* @param totalSpace the total space
* @param percent the percentage of space already used
*/
private void setQuotaInformation(long usedSpace, long totalSpace, Double percent) {
int progress = (int) Math.ceil(percent);
mQuotaProgressBar.setProgress(progress);
mQuotaTextView.setText(String.format(
getString(R.string.drawer_quota),
DisplayUtils.bytesToHumanReadable(usedSpace),
DisplayUtils.bytesToHumanReadable(totalSpace)));

// TODO Think about coloring of the progressbar at certain thresholds

showQuota(true);
}

/**
* checks/highlights the provided menu item if the drawer has been initialized and the menu item exists.
*
Expand Down