Skip to content

Commit

Permalink
Development (#269)
Browse files Browse the repository at this point in the history
* fix new on 1ramp section and fix user profile image cache invalidation (#264)

* Fix/image sharing crash (#265)

* fix image sharing from other apps crash

* fix notification subscription topic

* fix content create button apperance to non-allowed users (#268)
  • Loading branch information
bxute authored Jan 22, 2019
1 parent 0a5b87e commit f1760f1
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 78 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ android {
applicationId "com.hapramp"
minSdkVersion 16
targetSdkVersion 27
versionCode 114
versionName "1.1.2"
versionCode 116
versionName "1.1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
setProperty("archivesBaseName", "1ramp_" + versionCode + "_" + versionName)
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/hapramp/datastore/JSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,16 @@ public void parseCompetitionEligibilityResponse(String response) {
}

private void parseAndStoreEligibility(JSONObject jsonObject) throws JSONException {
if (jsonObject.has("is_competition_user")) {
if (jsonObject.get("is_competition_user") instanceof Boolean) {
boolean eligible = jsonObject.getBoolean("is_competition_user");
HaprampPreferenceManager.getInstance().setCompetitionCreateEligibility(eligible);
}else{
HaprampPreferenceManager.getInstance().setCompetitionCreateEligibility(false);
String username = jsonObject.optString("username", "");
String loggedInUser = HaprampPreferenceManager.getInstance().getCurrentSteemUsername();
if (username.equals(loggedInUser) && loggedInUser.length() > 0) {
if (jsonObject.has("is_competition_user")) {
if (jsonObject.get("is_competition_user") instanceof Boolean) {
boolean eligible = jsonObject.getBoolean("is_competition_user");
HaprampPreferenceManager.getInstance().setCompetitionCreateEligibility(eligible);
} else {
HaprampPreferenceManager.getInstance().setCompetitionCreateEligibility(false);
}
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/java/com/hapramp/datastore/SteemRequestBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ public static String getDelegationsListBody(String delegator) {
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_vesting_delegations\", \"params\":[\"" + delegator + "\",100], \"id\":1}";
}

public static String getRebloggedByBody(String author,String permlink) {
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_reblogged_by\", \"params\":[\""+author+"\",\""+permlink+"\"], \"id\":1}";
public static String getRebloggedByBody(String author, String permlink) {
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_reblogged_by\", \"params\":[\"" + author + "\",\"" + permlink + "\"], \"id\":1}";
}

public static String getResourceCreditBody(String username) {
Expand All @@ -16,19 +16,20 @@ public static String getResourceCreditBody(String username) {
}

public static String getSinglePostBody(String author, String permlink) {
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_content\", \"params\":[\"" + author + "\"," +
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_content\"," +
" \"params\":[\"" + author + "\"," +
" \"" + permlink + "\"], \"id\":1}";
}

public static String discussionsByCreated(String tag) {
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_discussions_by_created\"," +
" \"params\":[{\"tag\":\"" + tag + "\",\"limit\":8}], \"id\":1}";
return "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"database_api\"," +
"\"get_discussions_by_created\",[{\"tag\":\"" + tag + "\",\"limit\":\"50\"}]]}";
}

public static String discussionsByCreated(String tag, String start_author, String start_permlink) {
return "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_discussions_by_created\"," +
"\"params\":[{\"start_author\":\"" + start_author + "\",\"start_permlink\":\"" + start_permlink +
"\",\"tag\":\"" + tag + "\",\"limit\":8}], \"id\":1}";
return "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"database_api\"," +
"\"get_discussions_by_created\",[{\"tag\":\"" + tag + "\",\"start_author\":\"" + start_author +
"\",\"start_permlink\":\"" + start_permlink + "\",\"limit\":\"50\"}]]}";
}

public static String contentReplies(String author, String permlink) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/hapramp/main/HapRampMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class HapRampMain extends MultiDexApplication {

private static Context context;
private static String fp;
private static String sessionId;

public static String getFp() {
return fp;
Expand All @@ -26,6 +27,11 @@ public void onCreate() {
HapRampMain.context = getApplicationContext();
FirebaseApp.initializeApp(context);
fp = FingerprintManager.getCertificateSHA1Fingerprint(context);
sessionId = String.valueOf(System.currentTimeMillis());
}

public static String getSessionId(){
return sessionId;
}

public static Context getContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,12 @@ public void onSuccess(Void aVoid) {
});
}

/**
* subscribe to listen for particular competition.
*
* @param competition_id is the topic to target participants
*/
public static void subscribeForParticularCompetition(String competition_id) {
competition_id = "test_comp";
FirebaseMessaging.getInstance().subscribeToTopic(competition_id).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {

}
});
}

/**
* unsubscribe from listening for particular competition.
*
* @param competition_id is the topic to target participants
*/
public static void unsubscribeForParticularCompetition(String competition_id) {
FirebaseMessaging.getInstance().unsubscribeFromTopic(competition_id).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {

}
});
}

/**
* unsubscribe from listening to new competitions.
*/
public static void unsubscribeForNewCompetition() {
String topic = "competition";
String topic = "competitions";
FirebaseMessaging.getInstance().unsubscribeFromTopic(topic).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hapramp/steem/LocalConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class LocalConfig {
public static final String PARENT_PERMALINK = "hapramp";
public static final String APP_TAG = "1ramp/1.0";
public static final String APP_TAG = "1ramp/1.1.4";
public static final int BENEFICIARY_WEIGHT = 0; // 0% of payout
public static final String BENEFICIARY_ACCOUNT = "hapramp";
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ public void onResponse(Call<CompetitionEntryResponse> call, Response<Competition
showPublishingProgressDialog(false, "");
if (response.isSuccessful()) {
toast("Confirmed your entry!");
subscribeForNotification();
} else {
toast("Failed to confirm your entry!");
}
Expand All @@ -367,10 +366,6 @@ public void onFailure(Call<CompetitionEntryResponse> call, Throwable t) {
}
}

private void subscribeForNotification() {
NotificationSubscriber.subscribeForParticularCompetition(mCompetitionId);
}

private void closeEditor() {
showPublishingProgressDialog(false, "");
AnalyticsUtil.logEvent(AnalyticsParams.EVENT_CREATE_ARTICLE);
Expand Down
35 changes: 9 additions & 26 deletions app/src/main/java/com/hapramp/utils/FilePathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import android.annotation.TargetApi;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -55,8 +53,7 @@ public static String getPath(final Context context, final Uri uri) {
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id));
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
}
// MediaProvider
Expand Down Expand Up @@ -86,7 +83,6 @@ else if ("content".equalsIgnoreCase(uri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();

return getDataColumn(context, uri, null, null);
}
// File
Expand Down Expand Up @@ -126,28 +122,15 @@ public static boolean isDownloadsDocument(Uri uri) {
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
public static String getDataColumn(Context context, Uri uri,
String selection, String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {column};

public static String getDataColumn(Context context,
Uri uri,
String selection,
String[] selectionArgs) {
try {
cursor = context.getContentResolver().query(uri, projection,
selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
String col = cursor.getString(index);
if (col != null) {
return col;
} else {
returnPathAferSavingFile(context, uri);
}
}
returnPathAferSavingFile(context, uri);
}
finally {
if (cursor != null)
cursor.close();
catch (Exception e) {
e.printStackTrace();
}
return nopath;
}
Expand All @@ -174,7 +157,7 @@ private static String returnPathAferSavingFile(Context context, Uri uri) {
try {
InputStream inputStream = context.getContentResolver().openInputStream(uri);
String filename = System.currentTimeMillis() + "_image.png";
File file = new File(context.getFilesDir(),filename);
File file = new File(context.getFilesDir(), filename);
FileOutputStream output = new FileOutputStream(file);
if (inputStream != null) {
byte[] buffer = new byte[4 * 1024]; // or other buffer size
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/hapramp/utils/ImageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.signature.ObjectKey;
import com.crashlytics.android.Crashlytics;
import com.hapramp.R;
import com.hapramp.main.HapRampMain;

/**
* Created by Ankit on 12/17/2017.
Expand Down Expand Up @@ -175,7 +178,8 @@ public static void loadCircularImage(final Context context, final ImageView imag
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.drawable.circular_image_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.diskCacheStrategy(DiskCacheStrategy.DATA)
.signature(new ObjectKey(HapRampMain.getSessionId()))
.priority(Priority.HIGH);
Glide.with(context)
.asBitmap()
Expand Down

0 comments on commit f1760f1

Please sign in to comment.