Skip to content

Commit 3efe8f2

Browse files
- CHG: Search now closes with a single click on the "x" symbol.
- BUG: Fixed wrong preference activity title. - CHG: Fixed fling behaviour for node details activity. Still no fix for about activity. - CHG: Added people involved to acknowledgements section.
1 parent aee2c8b commit 3efe8f2

16 files changed

Lines changed: 170 additions & 65 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/app-release.apk

2.85 KB
Binary file not shown.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ android {
3030
applicationId "uk.ac.hutton.ics.buntata"
3131
minSdkVersion 16
3232
targetSdkVersion 25
33-
versionCode 5
34-
versionName "0.17.02.21"
33+
versionCode 6
34+
versionName "0.17.02.22"
3535
multiDexEnabled true
3636
}
3737

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<activity android:name=".activity.IntroductionActivity"
4242
android:configChanges="orientation|screenSize"/>
4343
<activity android:name=".activity.DatasourceActivity"
44-
android:configChanges="orientation|screenSize"/>
44+
android:configChanges="keyboardHidden|orientation|screenSize"/>
4545
<activity android:name=".activity.ImageViewPagerActivity"
4646
android:configChanges="orientation|screenSize"/>
4747
<activity android:name=".activity.NodeDetailsActivity"

app/src/main/java/uk/ac/hutton/ics/buntata/activity/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ public boolean onQueryTextSubmit(String query)
333333
@Override
334334
public boolean onQueryTextChange(String s)
335335
{
336+
/* Close the search field when the search string is empty */
337+
if (StringUtils.isEmpty(s))
338+
searchView.setIconified(true);
336339
return false;
337340
}
338341
});

app/src/main/java/uk/ac/hutton/ics/buntata/activity/PreferencesActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected void onCreate(Bundle savedInstanceState)
4848
if (getSupportActionBar() != null)
4949
{
5050
/* Set the title */
51-
getSupportActionBar().setTitle(R.string.title_activity_datasource);
51+
getSupportActionBar().setTitle(R.string.title_activity_settings);
5252
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
5353
getSupportActionBar().setHomeButtonEnabled(true);
5454
}

app/src/main/java/uk/ac/hutton/ics/buntata/adapter/DatasourceAdapter.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ public class DatasourceAdapter extends SectionedRecyclerViewAdapter<DatasourceAd
5656

5757
private int expandedPosition = -1;
5858

59-
private Comparator<BuntataDatasourceAdvanced> comparator = new Comparator<BuntataDatasourceAdvanced>()
60-
{
61-
@Override
62-
public int compare(BuntataDatasourceAdvanced o1, BuntataDatasourceAdvanced o2)
63-
{
64-
return o1.getName().compareTo(o2.getName());
65-
}
66-
};
67-
6859
private Activity context;
6960
private RecyclerView parent;
7061
private List<BuntataDatasourceAdvanced> dataset;

app/src/main/java/uk/ac/hutton/ics/buntata/adapter/NodeAdapter.java

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -168,40 +168,53 @@ public void onBindViewHolder(final ViewHolder holder, int position)
168168
else
169169
{
170170
/* Load the image */
171-
final PaletteTransformation paletteTransformation = PaletteTransformation.instance();
172-
Picasso.with(context)
173-
.load(imagePath) // Load from file
174-
.transform(paletteTransformation) // Generate the palette based on the image
175-
.resize(viewWidth, viewWidth) // Resize to fit
176-
.onlyScaleDown() // But only scale down
177-
.centerCrop() // And respect the aspect ratio
178-
.into(holder.image, new Callback.EmptyCallback() // When done, use the palette
179-
{
180-
@Override
181-
public void onError()
182-
{
183-
/* Set the placeholder */
184-
holder.image.setImageResource(R.drawable.missing_image);
185-
holder.image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
186-
}
187-
188-
@Override
189-
public void onSuccess()
190-
{
191-
/* Get back the bitmap */
192-
Bitmap bitmap = ((BitmapDrawable) holder.image.getDrawable()).getBitmap(); // Ew!
193-
/* Get the generated palette */
194-
Palette palette = PaletteTransformation.getPalette(bitmap);
195-
196-
/* Get the vibrant color and a high-contrast text color */
197-
int vibrantColor = palette.getVibrantColor(defaultBackgroundColor);
198-
int textColor = ColorUtils.isColorDark(vibrantColor) ? textColorLight : textColorDark;
199-
200-
holder.image.setScaleType(ImageView.ScaleType.CENTER_CROP);
201-
holder.title.setBackgroundColor(vibrantColor);
202-
holder.title.setTextColor(textColor);
203-
}
204-
});
171+
PaletteTransformation paletteTransformation;
172+
173+
RequestCreator c = Picasso.with(context)
174+
.load(imagePath); /* Load from file */
175+
176+
final boolean showKeys = datasource.isShowKeyName();
177+
178+
if (showKeys)
179+
{
180+
paletteTransformation = PaletteTransformation.instance();
181+
c.transform(paletteTransformation); /* Generate the palette based on the image */
182+
}
183+
184+
c.resize(viewWidth, viewWidth) /* Resize to fit */
185+
.onlyScaleDown() /* But only scale down */
186+
.centerCrop() /* And respect the aspect ratio */
187+
.into(holder.image, new Callback.EmptyCallback() /* When done, use the palette */
188+
{
189+
@Override
190+
public void onError()
191+
{
192+
/* Set the placeholder */
193+
holder.image.setImageResource(R.drawable.missing_image);
194+
holder.image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
195+
}
196+
197+
@Override
198+
public void onSuccess()
199+
{
200+
holder.image.setScaleType(ImageView.ScaleType.CENTER_CROP);
201+
202+
if (showKeys)
203+
{
204+
/* Get back the bitmap */
205+
Bitmap bitmap = ((BitmapDrawable) holder.image.getDrawable()).getBitmap(); /* Ew! */
206+
207+
/* Get the generated palette */
208+
Palette palette = PaletteTransformation.getPalette(bitmap);
209+
210+
/* Get the vibrant color and a high-contrast text color */
211+
int vibrantColor = palette.getVibrantColor(defaultBackgroundColor);
212+
int textColor = ColorUtils.isColorDark(vibrantColor) ? textColorLight : textColorDark;
213+
holder.title.setBackgroundColor(vibrantColor);
214+
holder.title.setTextColor(textColor);
215+
}
216+
}
217+
});
205218
}
206219

207220
holder.title.setText(item.getName());
@@ -299,6 +312,7 @@ protected FilterResults performFiltering(CharSequence constraint)
299312

300313
final String filterPattern = constraint.toString();
301314

315+
/* If the filter is empty, restore original list */
302316
if (constraint.length() == 0)
303317
{
304318
filteredList.addAll(originalList);
@@ -307,6 +321,7 @@ protected FilterResults performFiltering(CharSequence constraint)
307321
{
308322
for (final BuntataNodeAdvanced item : originalList)
309323
{
324+
/* Check if this item has a child that matches */
310325
if (nodeManager.hasChildWithContent(item, filterPattern))
311326
{
312327
filteredList.add(item);

app/src/main/java/uk/ac/hutton/ics/buntata/database/manager/NodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public List<BuntataNodeAdvanced> getForParent(int parentId)
143143
{
144144
open();
145145

146-
Cursor cursor = database.rawQuery("SELECT * FROM nodes WHERE EXISTS (SELECT 1 FROM relationships WHERE relationships.child = nodes.id AND relationships.parent = ?)", new String[]{Integer.toString(parentId)});
146+
Cursor cursor = database.rawQuery("SELECT * FROM nodes WHERE EXISTS (SELECT 1 FROM relationships WHERE relationships.child = nodes.id AND relationships.parent = ?) ORDER BY nodes.name", new String[]{Integer.toString(parentId)});
147147
cursor.moveToFirst();
148148
while (!cursor.isAfterLast())
149149
{

app/src/main/java/uk/ac/hutton/ics/buntata/fragment/DatasourceFragment.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6262

6363
unbinder = ButterKnife.bind(this, view);
6464

65+
setRetainInstance(true);
66+
6567
if (getActivity() instanceof IntroActivity)
6668
text.setTextColor(ContextCompat.getColor(getActivity(), android.R.color.white));
6769

@@ -72,6 +74,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
7274
int valueInPixels = (int) getResources().getDimension(R.dimen.activity_vertical_margin) / 2;
7375
recyclerView.addItemDecoration(new GridSpacingItemDecoration(1, valueInPixels, valueInPixels, valueInPixels));
7476

77+
/* If this is part of the DatasourceActivity, then load the content here */
78+
if (getActivity() instanceof DatasourceActivity)
79+
updateStatus();
80+
7581
return view;
7682
}
7783

@@ -83,16 +89,6 @@ public void onDestroyView()
8389
unbinder.unbind();
8490
}
8591

86-
@Override
87-
public void onResume()
88-
{
89-
super.onResume();
90-
91-
/* If this is part of the DatasourceActivity, then load the content here */
92-
if (getActivity() instanceof DatasourceActivity)
93-
updateStatus();
94-
}
95-
9692
@Override
9793
public void setUserVisibleHint(boolean isVisibleToUser)
9894
{
@@ -111,8 +107,8 @@ private void updateStatus()
111107
// }
112108
// else
113109
// {
114-
networkWarning.setVisibility(View.GONE);
115-
requestData();
110+
networkWarning.setVisibility(View.GONE);
111+
requestData();
116112
// }
117113
}
118114

0 commit comments

Comments
 (0)