replace button with borderless image button + ripple effect + click binding

This commit is contained in:
AndyScherzinger 2018-06-06 11:22:34 +02:00 committed by tobiasKaminsky
parent 5e50b6cf66
commit 41528ab5ad
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
3 changed files with 56 additions and 19 deletions

View file

@ -39,7 +39,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@ -76,6 +76,7 @@ import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
public class FileDetailActivitiesFragment extends Fragment implements ActivityListInterface, VersionListInterface.View {
@ -118,9 +119,6 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
@BindView(android.R.id.list)
public RecyclerView recyclerView;
@BindView(R.id.submitComment)
public Button submitComment;
@BindView(R.id.commentInputField)
public TextInputEditText commentInput;
@ -129,9 +127,11 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
@BindString(R.string.activities_no_results_message)
public String noResultsMessage;
private boolean restoreFileVersionSupported;
private String userId;
private FileOperationsHelper operationsHelper;
private VersionListInterface.CommentCallback callback;
public static FileDetailActivitiesFragment newInstance(OCFile file, Account account) {
FileDetailActivitiesFragment fragment = new FileDetailActivitiesFragment();
@ -165,16 +165,14 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
fetchAndSetData(null);
swipeListRefreshLayout.setOnRefreshListener(
() -> onRefreshListLayout(swipeListRefreshLayout));
swipeEmptyListRefreshLayout.setOnRefreshListener(
() -> onRefreshListLayout(swipeEmptyListRefreshLayout));
swipeListRefreshLayout.setOnRefreshListener(() -> onRefreshListLayout(swipeListRefreshLayout));
swipeEmptyListRefreshLayout.setOnRefreshListener(() -> onRefreshListLayout(swipeEmptyListRefreshLayout));
AccountManager accountManager = AccountManager.get(getContext());
userId = accountManager.getUserData(account,
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
submitComment.setOnClickListener((l) -> submitComment(new VersionListInterface.CommentCallback() {
callback = new VersionListInterface.CommentCallback() {
@Override
public void onSuccess() {
@ -186,16 +184,17 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
public void onError(int error) {
Snackbar.make(recyclerView, error, Snackbar.LENGTH_LONG).show();
}
}));
};
return view;
}
private void submitComment(VersionListInterface.CommentCallback callback) {
String message = commentInput.getText().toString();
new RestoreFileVersionTask.SubmitCommentTask(message, userId, file.getLocalId(), callback, ownCloudClient)
.execute();
@OnClick(R.id.submitComment)
public void submitComment() {
if (commentInput.getText().toString().trim().length() > 0) {
new RestoreFileVersionTask.SubmitCommentTask(commentInput.getText().toString(), userId, file.getLocalId(),
callback, ownCloudClient).execute();
}
}
private void onRefreshListLayout(SwipeRefreshLayout refreshLayout) {

View file

@ -0,0 +1,25 @@
<!--
@author Google LLC
Copyright (C) 2018 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#757575"
android:pathData="M2,21L23,12L2,3V10L17,12L2,14V21Z" />
</vector>

View file

@ -26,20 +26,33 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/zero"
android:layout_marginLeft="@dimen/standard_padding"
android:layout_marginRight="@dimen/zero"
android:layout_marginStart="@dimen/standard_padding"
android:orientation="horizontal">
<android.support.design.widget.TextInputEditText
android:id="@+id/commentInputField"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/new_comment"/>
android:hint="@string/new_comment"
android:paddingTop="@dimen/standard_padding" />
<Button
<ImageButton
android:id="@+id/submitComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="→"/>
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/common_send"
android:paddingBottom="@dimen/standard_padding"
android:paddingEnd="@dimen/standard_padding"
android:paddingLeft="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
android:paddingStart="@dimen/standard_padding"
android:paddingTop="@dimen/standard_padding"
android:src="@drawable/ic_send" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout