Use a modal bottom sheet to display post selection instead of an alert dialog. Fixed some icons.

This commit is contained in:
Alex Ning 2019-07-12 11:31:28 +08:00
parent 68d3a7b09f
commit fcc34b45d4
18 changed files with 217 additions and 38 deletions

View File

@ -35,11 +35,9 @@
<map>
<entry key="assetSourceType" value="FILE" />
<entry key="color" value="ffffff" />
<entry key="height" value="20" />
<entry key="outputName" value="ic_outline_share_20px" />
<entry key="outputName" value="ic_outline_check_circle_outline_24px" />
<entry key="overrideSize" value="true" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-share-20px.svg" />
<entry key="width" value="20" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-check_circle_outline-24px.svg" />
</map>
</option>
</PersistentState>

Binary file not shown.

View File

@ -33,8 +33,8 @@ repositories {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.google.android.material:material:1.1.0-alpha08'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'

View File

@ -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();
});
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
@ -31,6 +31,6 @@ task clean(type: Delete) {
}
ext {
roomVersion = '2.1.0-rc01'
archLifecycleVersion = '2.2.0-alpha01'
roomVersion = '2.2.0-alpha01'
archLifecycleVersion = '2.2.0-alpha02'
}