-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#289 π sources - Introduce bottom sheet dialog
- Loading branch information
1 parent
f828c71
commit f706cc1
Showing
6 changed files
with
202 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...in/java/it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPicker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package it.niedermann.nextcloud.deck.ui.card.attachments.picker; | ||
|
||
import android.content.Context; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; | ||
|
||
import it.niedermann.nextcloud.deck.databinding.DialogAttachmentPickerBinding; | ||
|
||
public class CardAttachmentPicker extends BottomSheetDialogFragment { | ||
|
||
private DialogAttachmentPickerBinding binding; | ||
private CardAttachmentPickerListener listener; | ||
|
||
public CardAttachmentPicker() { | ||
|
||
} | ||
|
||
@Override | ||
public void onAttach(@NonNull Context context) { | ||
super.onAttach(context); | ||
|
||
if (getParentFragment() instanceof CardAttachmentPickerListener) { | ||
this.listener = (CardAttachmentPickerListener) getParentFragment(); | ||
} else { | ||
throw new IllegalArgumentException("Caller must implement " + CardAttachmentPickerListener.class.getSimpleName()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
binding = DialogAttachmentPickerBinding.inflate(inflater, container, false); | ||
return binding.getRoot(); | ||
} | ||
|
||
@Override | ||
public void onActivityCreated(@Nullable Bundle savedInstanceState) { | ||
super.onActivityCreated(savedInstanceState); | ||
binding.pickCamera.setOnClickListener((v) -> listener.pickCamera()); | ||
binding.pickContact.setOnClickListener((v) -> listener.pickContact()); | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||
binding.pickFile.setOnClickListener((v) -> listener.pickFile()); | ||
} else { | ||
binding.pickFile.setVisibility(View.GONE); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPickerListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package it.niedermann.nextcloud.deck.ui.card.attachments.picker; | ||
|
||
import android.os.Build; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
public interface CardAttachmentPickerListener { | ||
|
||
void pickCamera(); | ||
void pickContact(); | ||
@RequiresApi(api = Build.VERSION_CODES.KITKAT) | ||
void pickFile(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<vector android:autoMirrored="true" android:height="24dp" | ||
android:tint="#757575" android:viewportHeight="24" | ||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/bottom_sheet" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:padding="@dimen/spacer_3x" | ||
app:behavior_hideable="false" | ||
app:behavior_peekHeight="90dp" | ||
app:justifyContent="space_around" | ||
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> | ||
|
||
<LinearLayout | ||
android:id="@+id/pickCamera" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:layout_width="36dp" | ||
android:layout_height="36dp" | ||
android:contentDescription="@null" | ||
android:src="@drawable/ic_baseline_photo_camera_24" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/spacer_1x" | ||
android:text="@string/simple_camera" | ||
android:textAppearance="?attr/textAppearanceCaption" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/pickContact" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:layout_width="36dp" | ||
android:layout_height="36dp" | ||
android:contentDescription="@null" | ||
android:src="@drawable/ic_baseline_contact_mail_24" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/spacer_1x" | ||
android:text="@string/simple_contact" | ||
android:textAppearance="?attr/textAppearanceCaption" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/pickFile" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:layout_width="36dp" | ||
android:layout_height="36dp" | ||
android:contentDescription="@null" | ||
android:src="@drawable/ic_attach_file_grey600_24dp" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/spacer_1x" | ||
android:text="@string/simple_file" | ||
android:textAppearance="?attr/textAppearanceCaption" /> | ||
</LinearLayout> | ||
</com.google.android.flexbox.FlexboxLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters