Skip to content

Commit

Permalink
Make it compatible with Android 2.3
Browse files Browse the repository at this point in the history
This will set minSdkVersion to 9 and make it work on GingerBread.
  • Loading branch information
zhaozihanzzh committed Feb 11, 2019
1 parent 1175381 commit c715551
Show file tree
Hide file tree
Showing 40 changed files with 1,794 additions and 106 deletions.
4 changes: 1 addition & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "com.majeur.materialicons"
minSdkVersion 14
minSdkVersion 9
targetSdkVersion 22
versionCode 3
versionName "1.2"
Expand All @@ -25,6 +25,4 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'net.rdrei.android.dirchooser:library:2.1@aar'
compile 'com.afollestad:material-dialogs:0.7.6.0'
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/majeur/materialicons/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.ArrayList;
import java.util.List;
import android.os.*;

public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder> {

Expand Down Expand Up @@ -92,7 +93,7 @@ public ViewHolder(View itemView, ItemsClickListener listener) {
view = (CardView) itemView;
titleView = (TextView) itemView.findViewById(R.id.name);
iconView = (SVGView) itemView.findViewById(R.id.icon);
iconView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (Build.VERSION.SDK_INT > 10) iconView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

mListener = listener;

Expand Down
56 changes: 20 additions & 36 deletions app/src/main/java/com/majeur/materialicons/AsyncDataRetriever.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
package com.majeur.materialicons;

import android.content.Context;
import android.content.res.AssetManager;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;

import com.afollestad.materialdialogs.MaterialDialog;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.app.*;
import android.content.*;
import android.content.res.*;
import android.util.*;
import android.widget.*;
import java.io.*;
import java.util.*;
import org.json.*;

/**
* This class is used to retrieve icons and keep local copies up to date.
Expand All @@ -30,7 +19,7 @@
* On the server files are in the same folder, to get download url, we just need the file name, then
* we format it with the "folder" url.
*/
public class AsyncDataRetriever extends AsyncTask<Void, String, AsyncDataRetriever.Result> {
public class AsyncDataRetriever extends AsyncTaskICS<Void, String, AsyncDataRetriever.Result> {

private static final String TAG = "DataAsyncTask";

Expand All @@ -41,7 +30,7 @@ public class AsyncDataRetriever extends AsyncTask<Void, String, AsyncDataRetriev
private static final String JSON_ARG_NAME = "name";

private Context mContext;
private MaterialDialog mDialog;
private ProgressDialog mDialog;
private OnDataLoadedListener mListener;

private File mIconsDirectory;
Expand All @@ -58,21 +47,15 @@ static final class Result {
mContext = context;
mListener = loadedListener;

mDialog = new MaterialDialog.Builder(context)
.progressIndeterminateStyle(false)
.progress(true, 0)
.content("")
.cancelable(false)
.positiveText(android.R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
super.onPositive(dialog);
cancel(false); // Cancel but don't interrupt, we still want already downloaded icons
}
})
.build();

mDialog = new ProgressDialog(context);
mDialog.setCancelable(false);
mDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,Resources.getSystem().getString(android.R.string.cancel),new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
cancel(false); // Cancel but don't interrupt, we still want already downloaded icons
}
});

mIconsDirectory = new File(context.getFilesDir().getAbsolutePath() + MainActivity.ICONS_PATH);
if (!mIconsDirectory.exists())
// Create local icons directory
Expand All @@ -83,6 +66,7 @@ public void onPositive(MaterialDialog dialog) {
protected void onPreExecute() {
super.onPreExecute();
mDialog.show();

}

@Override
Expand Down
Loading

0 comments on commit c715551

Please sign in to comment.