Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New PR #205

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
}
debug {
buildConfigField "String", "BASE_URL", "\"http://yellr.mycodespace.net\""
// buildConfigField "String", "BASE_URL", "\"https://yellr.net\""
//buildConfigField "String", "BASE_URL", "\"https://yellr.net\""
debuggable true
buildConfigField "String", "SPOOF_LOCATION", "\"1\""
buildConfigField "int", "UPDATE_RATE", "30"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;

import com.squareup.picasso.Picasso;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -64,6 +67,7 @@ public class ViewPostFragment extends Fragment {
Button reportButton;
public String mediatype;

ImageView imageContainer;
LinearLayout videoViewPostVideo;
public VideoView videoViewPostVideoInner;
private SeekBar vseekbar;
Expand Down Expand Up @@ -95,6 +99,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
this.videoViewPostVideo = (LinearLayout) view.findViewById(R.id.frag_view_post_video);
this.videoViewPostVideoInner = (VideoView) view.findViewById(R.id.frag_view_post_video_inner);
this.audioContainer = (LinearLayout) view.findViewById(R.id.audio_container);
this.imageContainer = (ImageView)view.findViewById(R.id.frag_view_post_image);

Intent intent = getActivity().getIntent();

Expand All @@ -117,15 +122,44 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
post.media_objects[0].media_type_name = intent.getStringExtra(ViewPostFragment.ARG_POST_MEDIA_OBJECT_MEDIA_TYPE);

this.mediatype = post.media_objects[0].media_type_name;

Log.d("ViewPostFragment.OnCreateView.MediaType", this.mediatype);

//hide video/audio view
if (this.mediatype.equals("text")) {

this.videoViewPostVideo.setVisibility(View.GONE);
this.audioContainer.setVisibility(View.GONE);
this.imageContainer.setVisibility(View.GONE);

}

if (this.mediatype.equals("image")) {

this.videoViewPostVideo.setVisibility(View.GONE);
this.audioContainer.setVisibility(View.GONE);
this.imageContainer.setVisibility(View.VISIBLE);

try {

String url = BuildConfig.BASE_URL + "/media/" + post.media_objects[0].file_name; //YellrUtils.getPreviewImageName(post.media_objects[0].file_name);

Log.d("ViewPostFragment.OnCreateView - Image URL", url);

this.imageContainer.setVisibility(View.VISIBLE);

Picasso.with(getActivity().getApplicationContext())
.load(url)
.into(this.imageContainer);

} catch (Exception e) {
Log.d("ViewPostFragment.OnCreateView", "ERROR: " + e.toString());
}

} else if (this.mediatype.equals("audio")) {

this.videoViewPostVideo.setVisibility(View.GONE);
this.imageContainer.setVisibility(View.GONE);
this.audioContainer.setVisibility(View.VISIBLE);

media_pause = (ImageButton) view.findViewById(R.id.media_pause);
Expand Down Expand Up @@ -157,6 +191,7 @@ public void onClick(View v) {

this.videoViewPostVideo.setVisibility(View.VISIBLE);
this.audioContainer.setVisibility(View.GONE);
this.imageContainer.setVisibility(View.GONE);

vmedia_pause = (ImageButton) view.findViewById(R.id.vmedia_pause);
vmedia_play = (ImageButton) view.findViewById(R.id.vmedia_play);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import android.widget.Toast;
Expand All @@ -28,7 +31,9 @@
import org.apache.http.protocol.HttpContext;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -129,6 +134,42 @@ private void handleActionGetPublishPost(int assignmentId,
//mediaType = "image";
//Log.d("PublishPostIntentService.Case", "Image");
mediaFilename = imageFilename;
Log.d("PublishPostIntentService.Case", imageFilename);

Bitmap fileToUploadBitmap = BitmapFactory.decodeFile(mediaFilename);
double scaleToResizeAspectRatio = (double)fileToUploadBitmap.getWidth() / (double)fileToUploadBitmap.getHeight();
int desiredHeight = 600;
int desiredWidth = (int) (desiredHeight*scaleToResizeAspectRatio);

Log.d("PublishPostIntentService.Case.AspectRatio - ", String.valueOf(scaleToResizeAspectRatio));
Log.d("PublishPostIntentService.Case.AspectRatio - ", String.valueOf(fileToUploadBitmap.getWidth()));
Log.d("PublishPostIntentService.Case.AspectRatio - ", String.valueOf(fileToUploadBitmap.getHeight()));

Bitmap outFile = Bitmap.createScaledBitmap(fileToUploadBitmap, desiredWidth, desiredHeight, false);

File outputDir = getApplicationContext().getCacheDir(); // context being the Activity pointer
try {

File outputFile = File.createTempFile("fileToUploadYellr", "jpg", outputDir);
File file = new File(outputFile.getAbsolutePath());
FileOutputStream fOut;

try {
fOut = new FileOutputStream(file);
outFile.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
fOut.close();
fileToUploadBitmap.recycle();
outFile.recycle();

mediaFilename = outputFile.getAbsolutePath();

} catch (Exception e) {}

} catch (IOException e) {
e.printStackTrace();
}

mediaText = "";
mediaCaption = text;
break;
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/fragment_view_post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@
<ImageView
android:id="@+id/frag_view_post_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="120dp"
android:gravity="center_vertical"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:layout_marginTop="0dp"
android:paddingRight="15dp"
android:paddingLeft="15dp"
android:paddingRight="10dp"
/>

<LinearLayout
Expand Down