Skip to content

Commit

Permalink
Add activity to add gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
nning committed Apr 20, 2017
1 parent 4b2788e commit aeca84a
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 11 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".GalleryAddActivity"
android:label="@string/add_gallery"
android:theme="@android:style/Theme.Holo.Light.Dialog">
</activity>
</application>

</manifest>
29 changes: 29 additions & 0 deletions app/src/main/java/net/orgizm/imgshr/GalleryAddActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.orgizm.imgshr;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class GalleryAddActivity extends Activity
{
private TextView slug;
private Preferences preferences;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery_add_activity);

slug = (TextView) findViewById(R.id.slug);
preferences = new Preferences(getApplicationContext());
}

public void addGalleryCallback(View view) {
preferences.setLastSlugs(new Gallery(slug.getText().toString()));
Toast.makeText(getApplicationContext(), R.string.gallery_saved, Toast.LENGTH_SHORT).show();
finish();
}
}
6 changes: 2 additions & 4 deletions app/src/main/java/net/orgizm/imgshr/GalleryListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ protected void registerAddButtonHandler() {
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
galleriesList.add(new Gallery("bar"));
adapter.notifyItemChanged(galleriesList.size() - 1);

preferences.setLastSlugs(galleriesList);
Intent intent = new Intent(getApplicationContext(), GalleryAddActivity.class);
startActivity(intent);
}
});
}
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/java/net/orgizm/imgshr/ShareActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class ShareActivity extends Activity

private Preferences preferences;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
Expand Down Expand Up @@ -85,10 +84,7 @@ public void onCreate(Bundle savedInstanceState)

if (newSlug != null) {
preferences.setLastSlugs(new Gallery(newSlug));

Toast toast = Toast.makeText(context, getString(R.string.saved_slug), Toast.LENGTH_LONG);
toast.show();

Toast.makeText(context, getString(R.string.gallery_saved), Toast.LENGTH_LONG).show();
finish();
}
}
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/res/layout/gallery_add_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
>

<EditText
android:id="@+id/slug"
android:layout_width="0dp"
android:layout_height="50dp"
android:hint="@string/slug_hint"
android:inputType="text"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_toStartOf="@+id/button"
android:layout_toLeftOf="@+id/button"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
/>

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text="@string/save_button"
android:onClick="addGalleryCallback"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
/>
</RelativeLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/gallery_list_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
android:id="@+id/list"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
android:layout_height="wrap_content"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>

Expand All @@ -58,6 +58,7 @@
app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/ic_add_white_24dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:clickable="true"
app:backgroundTint="@android:color/holo_orange_dark"
app:fabSize="normal" />
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/share_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
android:hint="@string/slug_hint"
android:inputType="text"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/button"
android:layout_toStartOf="@+id/button"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingLeft="8dp"
Expand All @@ -27,6 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text="@string/upload_button"
android:onClick="uploadImageCallback"
android:paddingTop="2dp"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<string name="upload_button">Upload</string>
<string name="uploading">Uploading%1$s</string>
<string name="certificate_invalid">Certificate invalid!</string>
<string name="saved_slug">Saved slug!</string>
<string name="gallery_saved">Saved gallery!</string>
<string name="delete_from_list">Delete from list</string>
<string name="gallery_deleted">Gallery deleted!</string>
<string name="open_url">Open URL</string>
<string name="save_button">Save</string>
<string name="add_gallery">Add gallery</string>
</resources>

0 comments on commit aeca84a

Please sign in to comment.