Add a clear message when no image is present on the upload activity
Fixes #14
This commit is contained in:
parent
726aad0e1d
commit
1ca02df079
3 changed files with 89 additions and 1 deletions
|
@ -40,7 +40,9 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -104,6 +106,12 @@ public class UploadActivity extends AppCompatActivity {
|
|||
deletedDays.add(SEVEN);
|
||||
deletedDays.add(THIRTY);
|
||||
deletedDays.add(YEAR);
|
||||
|
||||
|
||||
final LinearLayout infosLayout = (LinearLayout) findViewById(R.id.info_layout);
|
||||
FrameLayout dataLayout = (FrameLayout) findViewById(R.id.data_layout);
|
||||
dataLayout.setVisibility(View.GONE);
|
||||
|
||||
ImageView imView = (ImageView) findViewById(R.id.thumbnail_main);
|
||||
imView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -166,6 +174,9 @@ public class UploadActivity extends AppCompatActivity {
|
|||
allLoaded = false;
|
||||
}
|
||||
uploadBt.setEnabled(allLoaded);
|
||||
|
||||
infosLayout.setVisibility(View.GONE);
|
||||
dataLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (selectedServer < urls.size()) {
|
||||
|
@ -325,6 +336,13 @@ public class UploadActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
infosLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestFile();
|
||||
}
|
||||
});
|
||||
|
||||
//have we receive image from share or do you need to ask it to the user if we haven't ask for it before (screen rotation)
|
||||
Intent receiveIntent = getIntent();
|
||||
if((receiveIntent == null || receiveIntent.getType() == null || !receiveIntent.getType().contains("image/")) && uris.isEmpty()) {
|
||||
|
@ -337,12 +355,16 @@ public class UploadActivity extends AppCompatActivity {
|
|||
uris.add(imUri);
|
||||
adapter.addUri(this,imUri);
|
||||
uploadBt.setEnabled(false);
|
||||
infosLayout.setVisibility(View.GONE);
|
||||
dataLayout.setVisibility(View.VISIBLE);
|
||||
} else if(receiveIntent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
|
||||
ArrayList<Uri> imUris = receiveIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
||||
if(imUris != null) {
|
||||
uris.addAll(imUris);
|
||||
adapter.addUris(this,imUris,true);
|
||||
uploadBt.setEnabled(false);
|
||||
infosLayout.setVisibility(View.GONE);
|
||||
dataLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -507,6 +529,13 @@ public class UploadActivity extends AppCompatActivity {
|
|||
if (bt.isEnabled() && uris.size() == 0) {
|
||||
bt.setEnabled(false);
|
||||
}
|
||||
if(uris.size() == 0) {
|
||||
LinearLayout infosLayout = (LinearLayout) findViewById(R.id.info_layout);
|
||||
infosLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
FrameLayout dataLayout = (FrameLayout) findViewById(R.id.data_layout);
|
||||
dataLayout.setVisibility(View.GONE);
|
||||
}
|
||||
updateSpanCount();
|
||||
}
|
||||
|
||||
|
@ -519,6 +548,11 @@ public class UploadActivity extends AppCompatActivity {
|
|||
Button bt = (Button) findViewById(R.id.upload_button);
|
||||
bt.setEnabled(false);
|
||||
updateSpanCount();
|
||||
LinearLayout infosLayout = (LinearLayout) findViewById(R.id.info_layout);
|
||||
infosLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
FrameLayout dataLayout = (FrameLayout) findViewById(R.id.data_layout);
|
||||
dataLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void requestFile() {
|
||||
|
@ -539,7 +573,8 @@ public class UploadActivity extends AppCompatActivity {
|
|||
boolean hasAddUri = false;
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
clip = returnIntent.getClipData();
|
||||
|
||||
LinearLayout infosLayout = (LinearLayout) findViewById(R.id.info_layout);
|
||||
FrameLayout dataLayout = (FrameLayout) findViewById(R.id.data_layout);
|
||||
if(clip == null) {
|
||||
Uri imageUri = returnIntent.getData();
|
||||
if(imageUri == null)
|
||||
|
@ -548,6 +583,9 @@ public class UploadActivity extends AppCompatActivity {
|
|||
hasAddUri = true;
|
||||
updateSpanCount();
|
||||
adapter.addUri(this,imageUri);
|
||||
|
||||
infosLayout.setVisibility(View.GONE);
|
||||
dataLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
for(int i = 0; clip != null && i < clip.getItemCount(); i++) {
|
||||
Uri imageUri = clip.getItemAt(i).getUri();
|
||||
|
@ -558,6 +596,9 @@ public class UploadActivity extends AppCompatActivity {
|
|||
updateSpanCount();
|
||||
adapter.addUri(this, imageUri);
|
||||
|
||||
infosLayout.setVisibility(View.GONE);
|
||||
dataLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,31 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/info_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@+id/spinners_layout"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
>
|
||||
<ImageView
|
||||
android:src="@android:drawable/ic_menu_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:text="@string/add_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/data_layout"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@+id/spinners_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -70,7 +70,30 @@
|
|||
android:id="@+id/servers_spinner"
|
||||
android:layout_marginTop="25dp"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:id="@+id/info_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@id/servers_spinner"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
>
|
||||
<ImageView
|
||||
android:src="@android:drawable/ic_menu_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:text="@string/add_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/data_layout"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@id/servers_spinner"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue