some bugs fixes from firebase and readying for 2.0.0

This commit is contained in:
Kosh 2017-05-01 14:27:27 +08:00
parent 787d60311e
commit cbfaba5d86
11 changed files with 80 additions and 25 deletions

View File

@ -32,8 +32,8 @@ android {
applicationId "com.fastaccess.github"
minSdkVersion 21
targetSdkVersion 25
versionCode 195
versionName "1.9.5"
versionCode 200
versionName "2.0.0"
signingConfig signingConfigs.signing
buildConfigString "GITHUB_CLIENT_ID", (buildProperties.secrets['github_client_id'] | buildProperties.notThere['github_client_id']).string
buildConfigString "GITHUB_SECRET", (buildProperties.secrets['github_secret'] | buildProperties.notThere['github_secret']).string

View File

@ -229,11 +229,17 @@
<service
android:name=".provider.tasks.notification.NotificationSchedulerJobTask"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name=".provider.tasks.notification.ReadNotificationService"/>
<service android:name=".provider.tasks.git.GithubActionService"/>
<service android:name=".provider.tasks.git.ReactionService"/>
<service android:name=".provider.tasks.slack.SlackInvitationService"/>
<service
android:name=".provider.fcm.PushNotificationService">
<intent-filter>

View File

@ -194,7 +194,7 @@ public class Bundler {
bundle.writeToParcel(parcel, 0);
int size = parcel.dataSize();
Logger.e(size);
if (size > 800000) {
if (size > 500000) {
bundle.clear();
}
return get();

View File

@ -17,20 +17,21 @@ public class FileHelper {
@Nullable public static String getPath(@NonNull Context context, @NonNull Uri uri) {
String filePath = null;
String wholeID = DocumentsContract.getDocumentId(uri);
String id = wholeID.split(":")[1];
String[] column = {MediaStore.Images.Media.DATA};
String sel = MediaStore.Images.Media._ID + "=?";
try (Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
column, sel, new String[]{id}, null)) {
if (cursor != null) {
int columnIndex = cursor.getColumnIndex(column[0]);
if (cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
try {
String wholeID = DocumentsContract.getDocumentId(uri);
String id = wholeID.split(":")[1];
String[] column = {MediaStore.Images.Media.DATA};
String sel = MediaStore.Images.Media._ID + "=?";
try (Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
column, sel, new String[]{id}, null)) {
if (cursor != null) {
int columnIndex = cursor.getColumnIndex(column[0]);
if (cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
}
}
}
Logger.e(filePath);
} catch (Exception ignored) {}
return filePath;
}

View File

@ -23,7 +23,6 @@ import com.fastaccess.data.service.SearchService;
import com.fastaccess.data.service.SlackService;
import com.fastaccess.data.service.UserRestService;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.provider.rest.converters.GithubResponseConverter;
import com.fastaccess.provider.rest.interceptors.AuthenticationInterceptor;
@ -88,7 +87,6 @@ public class RestProvider {
Request request = requestBuilder.build();
return chain.proceed(request);
}
Logger.e(original.url());
return chain.proceed(original);
});
return client.build();

View File

@ -1,18 +1,26 @@
package com.fastaccess.provider.rest.converters;
import android.support.annotation.Nullable;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import static com.nostra13.universalimageloader.utils.IoUtils.DEFAULT_BUFFER_SIZE;
/**
* call that supports String & Gson and always uses json as its request body
*/
@ -27,15 +35,50 @@ public class GithubResponseConverter extends Converter.Factory {
return GsonConverterFactory.create(gson).responseBodyConverter(type, annotations, retrofit);
}
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit
retrofit) {
@Override public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations,
Annotation[] methodAnnotations, Retrofit retrofit) {
return GsonConverterFactory.create(gson).requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit);
}
private static class StringResponseConverter implements Converter<ResponseBody, String> {
@Override public String convert(ResponseBody value) throws IOException {
return value.string();
try {
return value.string();
} catch (OutOfMemoryError ignored) {
return getString(value.charStream());
}
}
@NonNull private String getString(@Nullable Reader reader) {
if (reader == null) return "";
StringWriter sw = new StringWriter();
try {
copy(reader, sw);
return sw.toString();
} catch (Exception ignored) {
return "";
}
}
private int copy(Reader input, Writer output) throws IOException {
long count = copyLarge(input, output);
if (count > Integer.MAX_VALUE) {
return -1;
}
return (int) count;
}
private long copyLarge(Reader input, Writer output) throws IOException {
char[] buffer = new char[DEFAULT_BUFFER_SIZE];
long count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
return count;
}
}
}

View File

@ -51,7 +51,11 @@ public class NotificationSchedulerJobTask extends JobService {
finishJob(job);
return true;
}
if (Login.getUser() != null) {
Login login = null;
try {
login = Login.getUser();
} catch (Exception ignored) {}
if (login != null) {
RestProvider.getNotificationService()
.getNotifications(ParseDateFormat.getLastWeekDate())
.subscribeOn(Schedulers.io())

View File

@ -124,8 +124,8 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
}
commentId = bundle.getLong(BundleConstant.EXTRA_FOUR);
String textToUpdate = bundle.getString(BundleConstant.EXTRA);
editText.setText(textToUpdate);
if (!InputHelper.isEmpty(textToUpdate)) {
editText.setText(String.format("%s ", textToUpdate));
editText.setSelection(InputHelper.toString(editText).length());
}
}

View File

@ -22,6 +22,7 @@ import java.io.File;
import butterknife.BindView;
import butterknife.OnClick;
import es.dmoral.toasty.Toasty;
/**
* Created by Kosh on 15 Apr 2017, 9:14 PM
@ -84,6 +85,8 @@ public class EditorLinkImageDialogFragment extends BaseDialogFragment<EditorLink
String path = FileHelper.getPath(getContext(), data.getData());
if (!InputHelper.isEmpty(path)) {
getPresenter().onSubmit(InputHelper.toString(title), new File(path));
} else {
Toasty.error(getContext(), getString(R.string.failed_selecting_image)).show();
}
}
}

View File

@ -38,8 +38,7 @@ public class ProgressDialogFragment extends DialogFragment {
progressDialog.setCancelable(getArguments().getBoolean("isCancelable"));
setCancelable(getArguments().getBoolean("isCancelable"));
if (getActivity() != null && !getActivity().isFinishing()) {
progressDialog.setOnShowListener(dialogInterface -> AnimHelper.revealDialog(progressDialog,
getResources().getInteger(android.R.integer.config_shortAnimTime)));
progressDialog.setOnShowListener(dialogInterface -> AnimHelper.revealDialog(progressDialog, 200));
}
return progressDialog;
}

View File

@ -395,4 +395,5 @@
<string name="join_slack_message" formatted="true">Would you like to join FastHub Slack group?\nInvitation link will be sent to %s.</string>
<string name="successfully_invited">Successfully invited</string>
<string name="reply">Reply</string>
<string name="failed_selecting_image">Failed to load image.</string>
</resources>