Skip to content

Commit

Permalink
upload update
Browse files Browse the repository at this point in the history
ui update
checkboxes for Flickr and 500px added.
  • Loading branch information
lyg830 committed Nov 28, 2013
1 parent 7069ff2 commit 172cb88
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 12 deletions.
36 changes: 34 additions & 2 deletions res/layout/fragment_image_upload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@
android:layout_alignLeft="@+id/tv_title"
android:layout_below="@id/tv_title"
android:ems="10"
android:lines="1"
android:gravity="center_vertical|top"
android:inputType="textMultiLine"
android:scrollHorizontally="false" >
android:scrollHorizontally="false"
android:textAppearance="?android:attr/textAppearanceSmall" >

<requestFocus />
</EditText>
Expand All @@ -81,9 +83,11 @@
android:layout_alignLeft="@+id/tv_description"
android:layout_below="@+id/tv_description"
android:ems="10"
android:lines="1"
android:gravity="center_vertical|top"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
android:scrollHorizontally="false"
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/tv_location"
Expand All @@ -95,6 +99,34 @@
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/tv_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_location"
android:layout_below="@+id/tv_location"
android:layout_marginTop="8dp"
android:text="Upload to:"
android:textAppearance="?android:attr/textAppearanceSmall" />

<CheckBox
android:id="@+id/cb_flickr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_upload"
android:layout_below="@+id/tv_upload"
android:text="Flickr"
android:textAppearance="?android:attr/textAppearanceSmall" />

<CheckBox
android:id="@+id/cb_500px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/cb_flickr"
android:layout_below="@+id/cb_flickr"
android:text="500px"
android:textAppearance="?android:attr/textAppearanceSmall" />

</RelativeLayout>

</RelativeLayout>
46 changes: 36 additions & 10 deletions src/com/example/mobileseenit/ImageUploadFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.mobileseenit;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
Expand All @@ -19,10 +18,12 @@
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.aetrion.flickr.Flickr;
import com.aetrion.flickr.uploader.UploadMetaData;
Expand All @@ -41,6 +42,8 @@ public class ImageUploadFragment extends Fragment implements OnClickListener {
private EditText title;
private EditText description;
private TextView tv_location;
private CheckBox cb_flickr;
private CheckBox cb_500px;
private Flickr f;

static ImageUploadFragment newInstance(byte[] image, double[] loc, String path){
Expand Down Expand Up @@ -71,6 +74,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
title = (EditText) rootView.findViewById(R.id.et_title);
description = (EditText) rootView.findViewById(R.id.et_decription);
tv_location = (TextView) rootView.findViewById(R.id.tv_location);
cb_flickr = (CheckBox) rootView.findViewById(R.id.cb_flickr);
cb_500px = (CheckBox) rootView.findViewById(R.id.cb_500px);
back.setOnClickListener(this);
upload.setOnClickListener(this);
Bundle args = this.getArguments();
Expand Down Expand Up @@ -110,16 +115,37 @@ public void onClick(View view) {
}
else if(view==upload){
Log.i("upload", "upload");
f = ((MainActivity)this.getActivity()).getFlickr();
UploadMetaData uploadMetaData = new UploadMetaData();
uploadMetaData.setTitle(title.getText().toString());
uploadMetaData.setDescription(description.getText().toString());
FlickrUploadTask t = new FlickrUploadTask(f,data,uploadMetaData,this.getActivity());
t.execute("");
InputMethodManager imm = (InputMethodManager)this.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(title.getWindowToken(), 0);
listener.onSwitchToCapture();
if(!cb_flickr.isChecked()&&!cb_500px.isChecked()){
Toast.makeText(this.getActivity(), "Please select Flickr and/or 500px to upload to.",
Toast.LENGTH_LONG).show();
}
else{
if(cb_flickr.isChecked()){
uploadToFlickr();
}
if(cb_500px.isChecked()){
uploadTo500px();
}
InputMethodManager imm = (InputMethodManager)this.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(title.getWindowToken(), 0);
listener.onSwitchToCapture();
}

}
}
private void uploadToFlickr(){
f = ((MainActivity)this.getActivity()).getFlickr();
UploadMetaData uploadMetaData = new UploadMetaData();
uploadMetaData.setTitle(title.getText().toString());
uploadMetaData.setDescription(description.getText().toString());
FlickrUploadTask t = new FlickrUploadTask(f,data,uploadMetaData,this.getActivity());
t.execute("");
}
private void uploadTo500px(){

//Place your uploadTo500px code here.


}

}

0 comments on commit 172cb88

Please sign in to comment.