New style for group headers in local tab, and size dialog when download is idle
This commit is contained in:
parent
23b98e0ade
commit
54f776b9db
6 changed files with 54 additions and 78 deletions
|
@ -1,24 +1,38 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="@dimen/list_header_padding"
|
android:paddingLeft="@dimen/list_header_padding"
|
||||||
android:paddingRight="@dimen/list_header_padding">
|
android:paddingRight="@dimen/list_header_padding">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/section_name"
|
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_height="wrap_content"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
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>
|
</LinearLayout>
|
|
@ -5,47 +5,6 @@
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical">
|
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
|
<ExpandableListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:progressDrawable="?attr/size_progress_bar"/>
|
android:progressDrawable="?attr/size_progress_bar"
|
||||||
|
tools:progress="50"/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -62,6 +62,9 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
setContentView(R.layout.download);
|
setContentView(R.layout.download);
|
||||||
|
final View downloadProgressLayout = findViewById(R.id.downloadProgressLayout);
|
||||||
|
downloadProgressLayout.setVisibility(View.VISIBLE);
|
||||||
|
updateDescriptionTextWithSize(this, downloadProgressLayout);
|
||||||
int currentTab = 0;
|
int currentTab = 0;
|
||||||
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
|
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
|
@ -245,12 +248,6 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
initFreeVersionBanner();
|
initFreeVersionBanner();
|
||||||
updateFreeVersionBanner();
|
updateFreeVersionBanner();
|
||||||
updateBannerInProgress();
|
updateBannerInProgress();
|
||||||
downloadProgressLayout.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
new ActiveDownloadsDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBannerInProgress() {
|
public void updateBannerInProgress() {
|
||||||
|
@ -258,8 +255,8 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
final boolean isFinished = basicProgressAsyncTask == null
|
final boolean isFinished = basicProgressAsyncTask == null
|
||||||
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
|
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
|
||||||
if (isFinished) {
|
if (isFinished) {
|
||||||
downloadProgressLayout.setVisibility(View.GONE);
|
downloadProgressLayout.setOnClickListener(null);
|
||||||
updateFreeVersionBanner();
|
updateDescriptionTextWithSize(ctx, downloadProgressLayout);
|
||||||
} else {
|
} else {
|
||||||
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
|
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
|
||||||
String message = basicProgressAsyncTask.getDescription();
|
String message = basicProgressAsyncTask.getDescription();
|
||||||
|
@ -267,7 +264,12 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
setMinimizedFreeVersionBanner(true);
|
setMinimizedFreeVersionBanner(true);
|
||||||
|
|
||||||
updateAvailableDownloads();
|
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);
|
progressBar.setIndeterminate(indeterminate);
|
||||||
if (indeterminate) {
|
if (indeterminate) {
|
||||||
leftTextView.setText(message);
|
leftTextView.setText(message);
|
||||||
|
@ -346,11 +348,12 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void updateDescriptionTextWithSize(View view){
|
public static void updateDescriptionTextWithSize(DownloadActivity activity, View view){
|
||||||
TextView descriptionText = (TextView) view.findViewById(R.id.sizeFreeTextView);
|
TextView descriptionText = (TextView) view.findViewById(R.id.rightTextView);
|
||||||
ProgressBar sizeProgress = (ProgressBar) view.findViewById(R.id.memoryLeftProgressBar);
|
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});
|
String size = formatGb.format(new Object[]{0});
|
||||||
int percent = 0;
|
int percent = 0;
|
||||||
if(dir.canRead()){
|
if(dir.canRead()){
|
||||||
|
@ -358,14 +361,13 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
|
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
|
||||||
percent = 100 - (int) (fs.getAvailableBlocks() * 100 / fs.getBlockCount());
|
percent = 100 - (int) (fs.getAvailableBlocks() * 100 / fs.getBlockCount());
|
||||||
}
|
}
|
||||||
|
sizeProgress.setIndeterminate(false);
|
||||||
sizeProgress.setProgress(percent);
|
sizeProgress.setProgress(percent);
|
||||||
String text = getString(R.string.free, size);
|
String text = activity.getString(R.string.free, size);
|
||||||
int l = text.indexOf('.');
|
|
||||||
if(l == -1) {
|
|
||||||
l = text.length();
|
|
||||||
}
|
|
||||||
descriptionText.setText(text);
|
descriptionText.setText(text);
|
||||||
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
|
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
|
messageTextView.setText(R.string.device_memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
String section = getGroup(groupPosition);
|
String section = getGroup(groupPosition);
|
||||||
if (v == null) {
|
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);
|
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
|
||||||
}
|
}
|
||||||
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
|
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
@ -15,6 +16,7 @@ import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -104,7 +106,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
setListView(listView);
|
setListView(listView);
|
||||||
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(view);
|
|
||||||
colorDrawables();
|
colorDrawables();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -459,7 +460,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadHasFinished() {
|
public void downloadHasFinished() {
|
||||||
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
|
|
||||||
reloadData();
|
reloadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,7 +664,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
selectionMode = false;
|
selectionMode = false;
|
||||||
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
|
|
||||||
listAdapter.cancelFilter();
|
listAdapter.cancelFilter();
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
@ -1021,8 +1020,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
LocalIndexInfo group = getGroup(groupPosition);
|
LocalIndexInfo group = getGroup(groupPosition);
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||||
v = inflater.inflate(R.layout.local_index_list_category, parent, false);
|
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
|
||||||
}
|
}
|
||||||
StringBuilder name = new StringBuilder(group.getType().getHumanString(getDownloadActivity()));
|
StringBuilder name = new StringBuilder(group.getType().getHumanString(getDownloadActivity()));
|
||||||
if (group.getSubfolder() != null) {
|
if (group.getSubfolder() != null) {
|
||||||
|
@ -1031,8 +1030,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
if (group.isBackupedData()) {
|
if (group.isBackupedData()) {
|
||||||
name.append(" - ").append(getString(R.string.local_indexes_cat_backup));
|
name.append(" - ").append(getString(R.string.local_indexes_cat_backup));
|
||||||
}
|
}
|
||||||
TextView nameView = ((TextView) v.findViewById(R.id.category_name));
|
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
|
||||||
TextView sizeView = ((TextView) v.findViewById(R.id.category_size));
|
TextView sizeView = ((TextView) v.findViewById(R.id.section_description));
|
||||||
List<LocalIndexInfo> list = data.get(group);
|
List<LocalIndexInfo> list = data.get(group);
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (LocalIndexInfo aList : list) {
|
for (LocalIndexInfo aList : list) {
|
||||||
|
@ -1054,14 +1053,15 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
|
|
||||||
}
|
}
|
||||||
sizeView.setText(sz);
|
sizeView.setText(sz);
|
||||||
|
sizeView.setVisibility(View.VISIBLE);
|
||||||
nameView.setText(name.toString());
|
nameView.setText(name.toString());
|
||||||
if (!group.isBackupedData()) {
|
|
||||||
nameView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
} else {
|
|
||||||
nameView.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
v.setOnClickListener(null);
|
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;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue