Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkorossy authored Jul 4, 2018
2 parents a4eed83 + 28d659c commit b227f64
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 27 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

**2018-07-04**

New version: 27.1.1.2 (based on v27.1.1)

- No support preferences related changes in the support library.
- RingtonePreference bug fixes(#164, #165, #167).

**2018-05-11**

New version: 27.1.1.1 (based on v27.1.1)
Expand Down
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ implementation 'com.android.support:preference-v14:27.1.1'
```
And **add** this single line to your gradle file:
```gradle
implementation 'com.takisoft.fix:preference-v7:27.1.1.1'
implementation 'com.takisoft.fix:preference-v7:27.1.1.2'
```
> Notice the versioning: the first three numbers are *always* the same as the latest official library while the last number is for own updates. I try to keep it up-to-date but if, for whatever reasons, I wouldn't notice the new support library versions, just issue a ticket.
Expand Down Expand Up @@ -92,18 +92,18 @@ Now you can enjoy using the support preferences API without losing all your hair
There are additional preferences not part of the official support library, but decided to add them to some extra libraries. You can add all of them to your project using

```gradle
implementation 'com.takisoft.fix:preference-v7-extras:27.1.1.1'
implementation 'com.takisoft.fix:preference-v7-extras:27.1.1.2'
```

or one or more groups:

Preference | Dependency | Preview
-|-|-
[`RingtonePreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#ringtonepreference) | `compile 'com.takisoft.fix:preference-v7-ringtone:27.1.1.1'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/ringtone_api26.png)
[`DatePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#datepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.1'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/datepicker_api26.png)
[`TimePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#timepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.1'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/timepicker_api26.png)
[`ColorPickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#colorpickerpreference) | `compile 'com.takisoft.fix:preference-v7-colorpicker:27.1.1.1'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/colorpicker_api26_fixed.png)
[`SimpleMenuPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#simplemenupreference) | `compile 'com.takisoft.fix:preference-v7-simplemenu:27.1.1.1'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/simplemenu_api26.png)
[`RingtonePreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#ringtonepreference) | `compile 'com.takisoft.fix:preference-v7-ringtone:27.1.1.2'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/ringtone_api26.png)
[`DatePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#datepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.2'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/datepicker_api26.png)
[`TimePickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#timepickerpreference) | `compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.2'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/timepicker_api26.png)
[`ColorPickerPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#colorpickerpreference) | `compile 'com.takisoft.fix:preference-v7-colorpicker:27.1.1.2'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/colorpicker_api26_fixed.png)
[`SimpleMenuPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#simplemenupreference) | `compile 'com.takisoft.fix:preference-v7-simplemenu:27.1.1.2'` | ![API 26](https://raw.githubusercontent.com/Gericop/Android-Support-Preference-V7-Fix/master/images/simplemenu_api26.png)

---

Expand Down Expand Up @@ -149,7 +149,7 @@ The original implementation uses `?attr/textAppearanceSmall` as the message styl
---

## Version
The current stable version is **27.1.1.1**.
The current stable version is **27.1.1.2**.

## Notes #
This demo / bugfix is set to work on API level 14+.
Expand All @@ -168,19 +168,12 @@ API 15 | API 21 | API 26

### Changelog

**2018-05-11**
**2018-07-04**

New version: 27.1.1.1 (based on v27.1.1)
New version: 27.1.1.2 (based on v27.1.1)

- No support preferences related changes in the support library.
- Bug fixes (#153, #149, #155, #152).

**2018-04-10**

New version: 27.1.1.0 (based on v27.1.1)

- No support preferences related changes in the support library.
- Some bug fixes (see #147 for more info).
- RingtonePreference bug fixes(#164, #165, #167).

> For older changelogs, check out the [CHANGELOG](CHANGELOG.md) file.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project.ext.sdkVersion = 27
project.ext.supportLibraryVersion = '27.1.1'
project.ext.supportLibraryVersionPrefix = '27.1.1'
project.ext.supportLibraryVersionSuffix = ''
project.ext.fixLibraryVersion = '1'
project.ext.fixLibraryVersion = '2'

project.ext.extrasLibraryVersionSuffix = ''

Expand All @@ -16,7 +16,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.2.0-beta02'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Apr 03 22:42:27 PDT 2018
#Wed Jun 27 20:46:56 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MergeCursor;
Expand All @@ -30,10 +31,16 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.MimeTypeMap;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.CursorAdapter;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;

import com.takisoft.fix.support.v7.preference.ringtone.R;
Expand All @@ -46,7 +53,9 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.zip.Inflater;

import static android.app.Activity.RESULT_OK;

Expand Down Expand Up @@ -105,8 +114,6 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {

createCursor(ringtonePreference.getRingtone());

String colTitle = cursor.getColumnName(RingtoneManager.TITLE_COLUMN_INDEX);

final Context context = getContext();

final int ringtoneType = ringtonePreference.getRingtoneType();
Expand All @@ -119,9 +126,16 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
} else {
defaultUri = null;
}

String[] titles = new String[cursor.getCount()];
if (cursor.moveToFirst()){
do{
titles[cursor.getPosition()] = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
}while(cursor.moveToNext());
}

builder
.setSingleChoiceItems(cursor, selectedIndex, colTitle, new DialogInterface.OnClickListener() {
.setSingleChoiceItems(buildAdapter(context, cursor), selectedIndex, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i < cursor.getCount()) {
Expand Down Expand Up @@ -292,8 +306,7 @@ protected Cursor doInBackground(Uri... params) {
protected void onPostExecute(final Cursor newCursor) {
if (newCursor != null) {
final ListView listView = ((AlertDialog) getDialog()).getListView();
final CursorAdapter adapter = ((CursorAdapter) ((HeaderViewListAdapter) listView.getAdapter()).getWrappedAdapter());
adapter.changeCursor(newCursor);
listView.setAdapter(buildAdapter(context, newCursor));

listView.setItemChecked(selectedIndex, true);
listView.setSelection(selectedIndex);
Expand Down Expand Up @@ -532,6 +545,20 @@ public static String[] splitFileName(String mimeType, String displayName) {
return new String[]{name, ext};
}

private CheckedItemAdapter buildAdapter (Context context, Cursor cursor){
String[] titles = new String[cursor.getCount()];
if (cursor.moveToFirst()){
do{
titles[cursor.getPosition()] = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
}while(cursor.moveToNext());
}

final TypedArray a = context.obtainStyledAttributes(null, android.support.v7.appcompat.R.styleable.AlertDialog,
android.support.v7.appcompat.R.attr.alertDialogStyle, 0);
int layout = a.getResourceId(android.support.v7.appcompat.R.styleable.AlertDialog_singleChoiceItemLayout, 0);
return new CheckedItemAdapter(context, layout, android.R.id.text1, titles);
}

/**
* Creates a {@link android.media.MediaScannerConnection} to scan a ringtone file and add its
* information to the internal database.
Expand Down Expand Up @@ -579,4 +606,21 @@ private Uri take() throws InterruptedException {
return mQueue.take();
}
}

private static class CheckedItemAdapter extends ArrayAdapter<CharSequence> {
public CheckedItemAdapter(Context context, int resource, int textViewResourceId,
CharSequence[] objects) {
super(context, resource, textViewResourceId, objects);
}

@Override
public boolean hasStableIds() {
return true;
}

@Override
public long getItemId(int position) {
return position;
}
}
}

0 comments on commit b227f64

Please sign in to comment.