New style for group headers in local tab, and size dialog when download is idle

This commit is contained in:
GaidamakUA 2015-10-20 18:09:38 +03:00
parent 23b98e0ade
commit 54f776b9db
6 changed files with 54 additions and 78 deletions

View file

@ -1,24 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/list_header_padding"
android:paddingRight="@dimen/list_header_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/section_name"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:maxLines="1"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="World Regions"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/section_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:maxLines="1"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="World Regions"/>
osmand:typeface="@string/font_roboto_medium"
tools:text="600Mb"
tools:visibility="visible"
android:visibility="gone"/>
</LinearLayout>

View file

@ -5,47 +5,6 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/dialog_content_bottom_margin"
android:paddingRight="@dimen/dialog_content_bottom_margin"
android:layout_marginBottom="@dimen/dialog_content_bottom_margin"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/local_size_height"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/device_memory"/>
<TextView
android:id="@+id/sizeFreeTextView"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/free"/>
</LinearLayout>
<ProgressBar
android:id="@+id/memoryLeftProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="?attr/size_progress_bar"
android:layout_width="fill_parent"
android:layout_height="20dp" />
</LinearLayout>
<ExpandableListView
android:id="@android:id/list"
android:layout_width="fill_parent"

View file

@ -41,7 +41,8 @@
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:progressDrawable="?attr/size_progress_bar"/>
android:progressDrawable="?attr/size_progress_bar"
tools:progress="50"/>
</LinearLayout>

View file

@ -62,6 +62,9 @@ public class DownloadActivity extends BaseDownloadActivity {
}
setContentView(R.layout.download);
final View downloadProgressLayout = findViewById(R.id.downloadProgressLayout);
downloadProgressLayout.setVisibility(View.VISIBLE);
updateDescriptionTextWithSize(this, downloadProgressLayout);
int currentTab = 0;
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
if (tab != null) {
@ -245,12 +248,6 @@ public class DownloadActivity extends BaseDownloadActivity {
initFreeVersionBanner();
updateFreeVersionBanner();
updateBannerInProgress();
downloadProgressLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ActiveDownloadsDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
}
});
}
public void updateBannerInProgress() {
@ -258,8 +255,8 @@ public class DownloadActivity extends BaseDownloadActivity {
final boolean isFinished = basicProgressAsyncTask == null
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
if (isFinished) {
downloadProgressLayout.setVisibility(View.GONE);
updateFreeVersionBanner();
downloadProgressLayout.setOnClickListener(null);
updateDescriptionTextWithSize(ctx, downloadProgressLayout);
} else {
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
String message = basicProgressAsyncTask.getDescription();
@ -267,7 +264,12 @@ public class DownloadActivity extends BaseDownloadActivity {
setMinimizedFreeVersionBanner(true);
updateAvailableDownloads();
downloadProgressLayout.setVisibility(View.VISIBLE);
downloadProgressLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ActiveDownloadsDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
}
});
progressBar.setIndeterminate(indeterminate);
if (indeterminate) {
leftTextView.setText(message);
@ -346,11 +348,12 @@ public class DownloadActivity extends BaseDownloadActivity {
@SuppressWarnings("deprecation")
public void updateDescriptionTextWithSize(View view){
TextView descriptionText = (TextView) view.findViewById(R.id.sizeFreeTextView);
ProgressBar sizeProgress = (ProgressBar) view.findViewById(R.id.memoryLeftProgressBar);
public static void updateDescriptionTextWithSize(DownloadActivity activity, View view){
TextView descriptionText = (TextView) view.findViewById(R.id.rightTextView);
TextView messageTextView = (TextView) view.findViewById(R.id.leftTextView);
ProgressBar sizeProgress = (ProgressBar) view.findViewById(R.id.progressBar);
File dir = getMyApplication().getAppPath("").getParentFile();
File dir = activity.getMyApplication().getAppPath("").getParentFile();
String size = formatGb.format(new Object[]{0});
int percent = 0;
if(dir.canRead()){
@ -358,14 +361,13 @@ public class DownloadActivity extends BaseDownloadActivity {
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
percent = 100 - (int) (fs.getAvailableBlocks() * 100 / fs.getBlockCount());
}
sizeProgress.setIndeterminate(false);
sizeProgress.setProgress(percent);
String text = getString(R.string.free, size);
int l = text.indexOf('.');
if(l == -1) {
l = text.length();
}
String text = activity.getString(R.string.free, size);
descriptionText.setText(text);
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
messageTextView.setText(R.string.device_memory);
}
}

View file

@ -379,7 +379,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
View v = convertView;
String section = getGroup(groupPosition);
if (v == null) {
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = LayoutInflater.from(ctx);
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
}
TextView nameView = ((TextView) v.findViewById(R.id.section_name));

View file

@ -5,6 +5,7 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
@ -15,6 +16,7 @@ import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.view.ActionMode;
import android.support.v7.widget.PopupMenu;
import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
@ -104,7 +106,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
listView.setAdapter(listAdapter);
expandAllGroups();
setListView(listView);
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(view);
colorDrawables();
return view;
}
@ -459,7 +460,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
@Override
public void downloadHasFinished() {
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
reloadData();
}
@ -664,7 +664,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
@Override
public void onDestroyActionMode(ActionMode mode) {
selectionMode = false;
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
listAdapter.cancelFilter();
expandAllGroups();
listAdapter.notifyDataSetChanged();
@ -1021,8 +1020,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
View v = convertView;
LocalIndexInfo group = getGroup(groupPosition);
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.local_index_list_category, parent, false);
LayoutInflater inflater = LayoutInflater.from(ctx);
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
}
StringBuilder name = new StringBuilder(group.getType().getHumanString(getDownloadActivity()));
if (group.getSubfolder() != null) {
@ -1031,8 +1030,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
if (group.isBackupedData()) {
name.append(" - ").append(getString(R.string.local_indexes_cat_backup));
}
TextView nameView = ((TextView) v.findViewById(R.id.category_name));
TextView sizeView = ((TextView) v.findViewById(R.id.category_size));
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
TextView sizeView = ((TextView) v.findViewById(R.id.section_description));
List<LocalIndexInfo> list = data.get(group);
int size = 0;
for (LocalIndexInfo aList : list) {
@ -1054,14 +1053,15 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
}
sizeView.setText(sz);
sizeView.setVisibility(View.VISIBLE);
nameView.setText(name.toString());
if (!group.isBackupedData()) {
nameView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} else {
nameView.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
}
v.setOnClickListener(null);
TypedValue typedValue = new TypedValue();
Resources.Theme theme = ctx.getTheme();
theme.resolveAttribute(R.attr.ctx_menu_info_view_bg, typedValue, true);
v.setBackgroundColor(typedValue.data);
return v;
}