Skip to content

Commit

Permalink
Development (#271)
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)

* fix image rotation issue in participation page (#270)

* fix travis build failure
  • Loading branch information
bxute authored Jan 22, 2019
1 parent f1760f1 commit b49071a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.hapramp.utils.ConnectionUtils;
import com.hapramp.utils.Constants;
import com.hapramp.utils.GoogleImageFilePathReader;
import com.hapramp.utils.ImageRotationHandler;
import com.hapramp.utils.MomentsUtils;
import com.hapramp.utils.PostHashTagPreprocessor;
import com.hapramp.views.editor.LinkInsertDialog;
Expand All @@ -51,7 +52,7 @@

import static xute.markdeditor.Styles.TextComponentStyle.NORMAL;

public class CreateArticleActivity extends AppCompatActivity implements SteemPostCreator.SteemPostCreatorCallback, EditorControlBar.EditorControlListener, DraftsHelper.DraftsHelperCallback {
public class CreateArticleActivity extends AppCompatActivity implements SteemPostCreator.SteemPostCreatorCallback, EditorControlBar.EditorControlListener, DraftsHelper.DraftsHelperCallback, ImageRotationHandler.ImageRotationOperationListner {
public static final String EXTRA_KEY_DRAFT_ID = "draftId";
public static final String EXTRA_KEY_DRAFT_JSON = "draftJson";
private static final int REQUEST_IMAGE_SELECTOR = 119;
Expand Down Expand Up @@ -100,6 +101,8 @@ public class CreateArticleActivity extends AppCompatActivity implements SteemPos
private boolean leftActivityWithPurpose = false;

private boolean shouldSaveOrUpdateDraft = true;
private ImageRotationHandler imageRotationHandler;
private Handler handler;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -112,7 +115,10 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void init() {
handler = new Handler();
draftsHelper = new DraftsHelper();
imageRotationHandler = new ImageRotationHandler(this);
imageRotationHandler.setImageRotationOperationListner(this);
draftsHelper.setDraftsHelperCallback(this);
progressDialog = new ProgressDialog(this);
articleCategoryView.initCategory();
Expand Down Expand Up @@ -332,14 +338,6 @@ private boolean checkValidSaveOption(DraftModel draftModel) {
return false;
}

private void updateDraft() {
DraftModel draftModel = markDEditor.getDraft();
String draftTitle = articleTitleEt.getText().toString();
draftModel.setDraftTitle(draftTitle);
draftModel.setDraftId(mDraftId);
draftsHelper.updateBlogDraft(draftModel);
}

private void closeEditor() {
showProgressDialog(false, "");
AnalyticsUtil.logEvent(AnalyticsParams.EVENT_CREATE_ARTICLE);
Expand All @@ -351,6 +349,14 @@ public void run() {
}, 1000);
}

private void updateDraft() {
DraftModel draftModel = markDEditor.getDraft();
String draftTitle = articleTitleEt.getText().toString();
draftModel.setDraftTitle(draftTitle);
draftModel.setDraftId(mDraftId);
draftsHelper.updateBlogDraft(draftModel);
}

private void toast(String s) {
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
}
Expand Down Expand Up @@ -390,25 +396,11 @@ private void handleImageResult(final Intent intent) {
@Override
public void run() {
final String filePath = GoogleImageFilePathReader.getImageFilePath(CreateArticleActivity.this, intent);
handler.post(new Runnable() {
@Override
public void run() {
addImage(filePath);
}
});
imageRotationHandler.checkOrientationAndFixImage(filePath, 0);
}
}.start();
}

public void addImage(String filePath) {
try {
markDEditor.insertImage(filePath);
}
catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void onBackPressed() {
showExistAlert();
Expand Down Expand Up @@ -527,4 +519,23 @@ public void onDraftUpdated(boolean success) {
public void onDraftDeleted(boolean success) {

}

@Override
public void onImageRotationFixed(final String filePath, boolean fileShouldBeDeleted, long uid) {
handler.post(new Runnable() {
@Override
public void run() {
addImage(filePath);
}
});
}

public void addImage(String filePath) {
try {
markDEditor.insertImage(filePath);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
import com.hapramp.api.URLS;
import com.hapramp.models.CompetitionEntryConfirmationBody;
import com.hapramp.models.CompetitionEntryResponse;
import com.hapramp.notification.NotificationSubscriber;
import com.hapramp.preferences.HaprampPreferenceManager;
import com.hapramp.steem.PermlinkGenerator;
import com.hapramp.steem.SteemPostCreator;
import com.hapramp.utils.ConnectionUtils;
import com.hapramp.utils.Constants;
import com.hapramp.utils.GoogleImageFilePathReader;
import com.hapramp.utils.ImageRotationHandler;
import com.hapramp.utils.MomentsUtils;
import com.hapramp.utils.PostHashTagPreprocessor;
import com.hapramp.views.editor.LinkInsertDialog;
Expand All @@ -61,7 +61,7 @@

import static xute.markdeditor.Styles.TextComponentStyle.NORMAL;

public class ParticipateEditorActivity extends AppCompatActivity implements EditorControlBar.EditorControlListener, SteemPostCreator.SteemPostCreatorCallback {
public class ParticipateEditorActivity extends AppCompatActivity implements EditorControlBar.EditorControlListener, SteemPostCreator.SteemPostCreatorCallback, ImageRotationHandler.ImageRotationOperationListner {

public static final String EXTRA_COMPETITION_ID = "competition_id";
public static final String EXTRA_COMPETITION_TITLE = "competition_title";
Expand Down Expand Up @@ -112,6 +112,8 @@ public class ParticipateEditorActivity extends AppCompatActivity implements Edit
private String mCompetitionHashtag;
private String mCompetitionId;
private String mCompetitionTitle;
private ImageRotationHandler imageRotationHandler;
private Handler handler;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -134,7 +136,10 @@ private void collectCompetitionExtras() {
}

private void init() {
handler = new Handler();
progressDialog = new ProgressDialog(this);
imageRotationHandler = new ImageRotationHandler(this);
imageRotationHandler.setImageRotationOperationListner(this);
articleCategoryView.initCategory();
setContestInfo();
editorControlBar.setEditorControlListener(this);
Expand Down Expand Up @@ -429,25 +434,15 @@ private void openGallery() {
}

private void handleImageResult(final Intent intent) {
final Handler handler = new Handler();
new Thread() {
@Override
public void run() {
final String filePath = GoogleImageFilePathReader.getImageFilePath(ParticipateEditorActivity.this, intent);
handler.post(new Runnable() {
@Override
public void run() {
addImage(filePath);
}
});
imageRotationHandler.checkOrientationAndFixImage(filePath, 0);
}
}.start();
}

public void addImage(String filePath) {
markDEditor.insertImage(filePath);
}

@Override
public void onInsertImageClicked() {
openGallery();
Expand All @@ -473,4 +468,18 @@ public void onLinkAdded(String text, String link) {
public void onPointerCaptureChanged(boolean hasCapture) {

}

@Override
public void onImageRotationFixed(final String filePath, boolean fileShouldBeDeleted, long uid) {
handler.post(new Runnable() {
@Override
public void run() {
addImage(filePath);
}
});
}

public void addImage(String filePath) {
markDEditor.insertImage(filePath);
}
}
17 changes: 16 additions & 1 deletion app/src/main/java/com/hapramp/utils/FilePathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -126,11 +127,25 @@ public static String getDataColumn(Context context,
Uri uri,
String selection,
String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {column};
try {
returnPathAferSavingFile(context, uri);
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);
}
}
}
catch (Exception e) {
e.printStackTrace();
returnPathAferSavingFile(context, uri);
}
return nopath;
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/hapramp/utils/ImageRotationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.util.Log;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand Down

0 comments on commit b49071a

Please sign in to comment.