diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-07-12 03:31:28 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-07-12 03:31:28 +0000 |
commit | fcc34b45d4aeae95bd16c9d70f0a2db5109951f0 (patch) | |
tree | d8708a4ede38d34d4ae70b9860aa6fb1e18262a1 /app/src | |
parent | 68d3a7b09f42aef6c3ec1874af3c9dee4c3eef8c (diff) | |
download | infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.gz infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.bz2 infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.lz infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.xz infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.zst infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.zip |
Use a modal bottom sheet to display post selection instead of an alert dialog. Fixed some icons.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java | 58 | ||||
-rw-r--r-- | app/src/main/res/drawable-hdpi/ic_link.png | bin | 429 -> 0 bytes | |||
-rw-r--r-- | app/src/main/res/drawable-mdpi/ic_link.png | bin | 299 -> 0 bytes | |||
-rw-r--r-- | app/src/main/res/drawable-xhdpi/ic_link.png | bin | 476 -> 0 bytes | |||
-rw-r--r-- | app/src/main/res/drawable-xxhdpi/ic_link.png | bin | 832 -> 0 bytes | |||
-rw-r--r-- | app/src/main/res/drawable/ic_link.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_outline_check_circle_outline_24px.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_outline_settings_24px.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_outline_text_24px.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_outline_video_label_24px.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_main.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/layout/post_type_bottom_sheet.xml | 122 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 10 |
13 files changed, 210 insertions, 29 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index bdcfece5..f452cb66 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -15,7 +15,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBarDrawerToggle; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.view.GravityCompat; @@ -28,6 +27,7 @@ import com.bumptech.glide.request.RequestOptions; import com.ferfalk.simplesearchview.SimpleSearchView; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.floatingactionbutton.FloatingActionButton; import javax.inject.Inject; @@ -57,6 +57,13 @@ public class MainActivity extends AppCompatActivity { @BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout; @BindView(R.id.fab_main_activity) FloatingActionButton fab; + private LinearLayout textTypeLinearLayout; + private LinearLayout linkTypeLinearLayout; + private LinearLayout imageTypeLinearLayout; + private LinearLayout videoTypeLinearLayout; + + private BottomSheetDialog dialog; + private TextView mNameTextView; private TextView mKarmaTextView; private GifImageView mProfileImageView; @@ -95,6 +102,15 @@ public class MainActivity extends AppCompatActivity { ButterKnife.bind(this); + View dialogView = View.inflate(this, R.layout.post_type_bottom_sheet, null); + textTypeLinearLayout = dialogView.findViewById(R.id.text_type_linear_layout_post_type_bottom_sheet); + linkTypeLinearLayout = dialogView.findViewById(R.id.link_type_linear_layout_post_type_bottom_sheet); + imageTypeLinearLayout = dialogView.findViewById(R.id.image_type_linear_layout_post_type_bottom_sheet); + videoTypeLinearLayout = dialogView.findViewById(R.id.video_type_linear_layout_post_type_bottom_sheet); + + dialog = new BottomSheetDialog(this); + dialog.setContentView(dialogView); + ((Infinity) getApplication()).getmAppComponent().inject(this); Toolbar toolbar = findViewById(R.id.toolbar); @@ -221,27 +237,27 @@ public class MainActivity extends AppCompatActivity { }); } - fab.setOnClickListener(view -> { - new AlertDialog.Builder(this).setTitle(R.string.dialog_post_type) - .setItems(R.array.dialog_post_types_array, (dialog, which) -> { - Intent intent; - switch (which) { - case 0: - intent = new Intent(this, PostTextActivity.class); - break; - case 1: - intent = new Intent(this, PostLinkActivity.class); - break; - case 2: - Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); - return; - default: - Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); - return; - } + textTypeLinearLayout.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, PostTextActivity.class); + startActivity(intent); + dialog.dismiss(); + }); + linkTypeLinearLayout.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, PostLinkActivity.class); + startActivity(intent); + dialog.dismiss(); + }); + imageTypeLinearLayout.setOnClickListener(view -> { + Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + }); + videoTypeLinearLayout.setOnClickListener(view -> { + Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + }); - startActivity(intent); - }).show(); + fab.setOnClickListener(view -> { + dialog.show(); }); } diff --git a/app/src/main/res/drawable-hdpi/ic_link.png b/app/src/main/res/drawable-hdpi/ic_link.png Binary files differdeleted file mode 100644 index 151e101d..00000000 --- a/app/src/main/res/drawable-hdpi/ic_link.png +++ /dev/null diff --git a/app/src/main/res/drawable-mdpi/ic_link.png b/app/src/main/res/drawable-mdpi/ic_link.png Binary files differdeleted file mode 100644 index d407acb5..00000000 --- a/app/src/main/res/drawable-mdpi/ic_link.png +++ /dev/null diff --git a/app/src/main/res/drawable-xhdpi/ic_link.png b/app/src/main/res/drawable-xhdpi/ic_link.png Binary files differdeleted file mode 100644 index 34062296..00000000 --- a/app/src/main/res/drawable-xhdpi/ic_link.png +++ /dev/null diff --git a/app/src/main/res/drawable-xxhdpi/ic_link.png b/app/src/main/res/drawable-xxhdpi/ic_link.png Binary files differdeleted file mode 100644 index 9b2ad879..00000000 --- a/app/src/main/res/drawable-xxhdpi/ic_link.png +++ /dev/null diff --git a/app/src/main/res/drawable/ic_link.xml b/app/src/main/res/drawable/ic_link.xml new file mode 100644 index 00000000..bfe6b0c4 --- /dev/null +++ b/app/src/main/res/drawable/ic_link.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="#FF000000" + android:pathData="M17,7h-4v2h4c1.65,0 3,1.35 3,3s-1.35,3 -3,3h-4v2h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5zM11,15L7,15c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-2zM8,11h8v2L8,13z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_outline_check_circle_outline_24px.xml b/app/src/main/res/drawable/ic_outline_check_circle_outline_24px.xml new file mode 100644 index 00000000..eab33694 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_check_circle_outline_24px.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="#FF000000" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM16.59,7.58L10,14.17l-2.59,-2.58L6,13l4,4 8,-8z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_outline_settings_24px.xml b/app/src/main/res/drawable/ic_outline_settings_24px.xml new file mode 100644 index 00000000..e1fb6a23 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_settings_24px.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="#FF000000" + android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98 0,-0.34 -0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.09,-0.16 -0.26,-0.25 -0.44,-0.25 -0.06,0 -0.12,0.01 -0.17,0.03l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.06,-0.02 -0.12,-0.03 -0.18,-0.03 -0.17,0 -0.34,0.09 -0.43,0.25l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98 0,0.33 0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.09,0.16 0.26,0.25 0.44,0.25 0.06,0 0.12,-0.01 0.17,-0.03l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.06,0.02 0.12,0.03 0.18,0.03 0.17,0 0.34,-0.09 0.43,-0.25l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM17.45,11.27c0.04,0.31 0.05,0.52 0.05,0.73 0,0.21 -0.02,0.43 -0.05,0.73l-0.14,1.13 0.89,0.7 1.08,0.84 -0.7,1.21 -1.27,-0.51 -1.04,-0.42 -0.9,0.68c-0.43,0.32 -0.84,0.56 -1.25,0.73l-1.06,0.43 -0.16,1.13 -0.2,1.35h-1.4l-0.19,-1.35 -0.16,-1.13 -1.06,-0.43c-0.43,-0.18 -0.83,-0.41 -1.23,-0.71l-0.91,-0.7 -1.06,0.43 -1.27,0.51 -0.7,-1.21 1.08,-0.84 0.89,-0.7 -0.14,-1.13c-0.03,-0.31 -0.05,-0.54 -0.05,-0.74s0.02,-0.43 0.05,-0.73l0.14,-1.13 -0.89,-0.7 -1.08,-0.84 0.7,-1.21 1.27,0.51 1.04,0.42 0.9,-0.68c0.43,-0.32 0.84,-0.56 1.25,-0.73l1.06,-0.43 0.16,-1.13 0.2,-1.35h1.39l0.19,1.35 0.16,1.13 1.06,0.43c0.43,0.18 0.83,0.41 1.23,0.71l0.91,0.7 1.06,-0.43 1.27,-0.51 0.7,1.21 -1.07,0.85 -0.89,0.7 0.14,1.13zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_outline_text_24px.xml b/app/src/main/res/drawable/ic_outline_text_24px.xml new file mode 100644 index 00000000..6afe43f5 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_text_24px.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="#FF000000" + android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v18l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,16L6,16l-2,2L4,4h16v12zM7,9h2v2L7,11zM11,9h2v2h-2zM15,9h2v2h-2z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_outline_video_label_24px.xml b/app/src/main/res/drawable/ic_outline_video_label_24px.xml new file mode 100644 index 00000000..2c421e88 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_video_label_24px.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="#FF000000" + android:pathData="M21,3L3,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM21,16L3,16L3,5h18v11z"/> +</vector> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6c30dbc2..fc198172 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -72,7 +72,7 @@ android:layout_height="24dp" android:layout_gravity="center_vertical" android:layout_marginEnd="32dp" - android:src="@drawable/ic_outline_account_circle_24px" + android:src="@drawable/ic_outline_check_circle_outline_24px" android:tint="@color/primaryTextColor"/> <TextView @@ -103,7 +103,7 @@ android:layout_height="24dp" android:layout_gravity="center_vertical" android:layout_marginEnd="32dp" - android:src="@drawable/ic_outline_account_circle_24px" + android:src="@drawable/ic_outline_settings_24px" android:tint="@color/primaryTextColor"/> <TextView diff --git a/app/src/main/res/layout/post_type_bottom_sheet.xml b/app/src/main/res/layout/post_type_bottom_sheet.xml new file mode 100644 index 00000000..617c1aa3 --- /dev/null +++ b/app/src/main/res/layout/post_type_bottom_sheet.xml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:text="@string/dialog_post_type" + android:textSize="18sp" /> + + <LinearLayout + android:id="@+id/text_type_linear_layout_post_type_bottom_sheet" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" > + + <ImageView + android:layout_width="18dp" + android:layout_height="18dp" + android:layout_gravity="center_vertical" + android:layout_marginEnd="32dp" + android:src="@drawable/ic_outline_text_24px" + android:tint="@color/primaryTextColor" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/dialog_post_text" + android:textColor="@color/primaryTextColor" + android:textSize="18sp" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/link_type_linear_layout_post_type_bottom_sheet" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" > + + <ImageView + android:layout_width="18dp" + android:layout_height="18dp" + android:layout_gravity="center_vertical" + android:layout_marginEnd="32dp" + android:src="@drawable/ic_link" + android:tint="@color/primaryTextColor" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/dialog_post_link" + android:textColor="@color/primaryTextColor" + android:textSize="18sp" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/image_type_linear_layout_post_type_bottom_sheet" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" > + + <ImageView + android:layout_width="18dp" + android:layout_height="18dp" + android:layout_gravity="center_vertical" + android:layout_marginEnd="32dp" + android:src="@drawable/ic_menu_gallery" + android:tint="@color/primaryTextColor" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/dialog_post_image" + android:textColor="@color/primaryTextColor" + android:textSize="18sp" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/video_type_linear_layout_post_type_bottom_sheet" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" > + + <ImageView + android:layout_width="18dp" + android:layout_height="18dp" + android:layout_marginEnd="32dp" + android:layout_gravity="center_vertical" + android:src="@drawable/ic_outline_video_label_24px" + android:tint="@color/primaryTextColor" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/dialog_post_video" + android:textColor="@color/primaryTextColor" + android:textSize="18sp" /> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d2b3a8a8..4faecc7a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -104,10 +104,8 @@ <string name="users">Users</string> <string name="dialog_post_type">Post</string> - <string-array name="dialog_post_types_array"> - <item>Text</item> - <item>Link</item> - <item>Image</item> - <item>Video</item> - </string-array> + <string name="dialog_post_text">Text</string> + <string name="dialog_post_link">Link</string> + <string name="dialog_post_image">Image</string> + <string name="dialog_post_video">Video</string> </resources> |