Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#289 📎 sources - Introduce bottom sheet dialog #555

Merged
merged 39 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f706cc1
#289 📎 sources - Introduce bottom sheet dialog
stefan-niedermann Jun 24, 2020
7b8f51f
First steps for retrieving contacts and camera images
stefan-niedermann Jun 24, 2020
a8d8a55
Refactor permissions process
stefan-niedermann Jun 26, 2020
4db96f4
Merge branch 'master' into 289-upload-sources
stefan-niedermann Jul 4, 2020
8326794
Merge branch 'master' into 289-upload-sources
stefan-niedermann Jul 8, 2020
10421aa
Merge branch 'master' into 289-upload-sources
stefan-niedermann Oct 29, 2020
34b73be
Adjust to targetSdk 30
stefan-niedermann Oct 29, 2020
8bf5224
Restore default path for switch-case
stefan-niedermann Oct 29, 2020
9929931
#289 📎 Add more sources to upload attachments
stefan-niedermann Oct 29, 2020
d773e16
#289 📎 Add more sources to upload attachments
stefan-niedermann Oct 29, 2020
704273e
#289 📎 Add more sources to upload attachments
stefan-niedermann Oct 29, 2020
fbf96fa
#289 📎 Add more sources to upload attachments
stefan-niedermann Oct 29, 2020
1417c6b
#289 📎 Add more sources to upload attachments
stefan-niedermann Oct 29, 2020
3c7d4f6
#289 📎 Add more sources to upload attachments
stefan-niedermann Oct 29, 2020
8f433ce
Update minSdk to Kitkat
stefan-niedermann Oct 30, 2020
b5d1096
Merge branch 'master' into 289-upload-sources
stefan-niedermann Oct 30, 2020
6d3289d
Fix impor
stefan-niedermann Oct 30, 2020
96ffc2b
Use java.time classes to format camera picking filename
stefan-niedermann Oct 30, 2020
78f476e
Use CameraX
stefan-niedermann Oct 31, 2020
0a58eee
Better permission handling for CameraX
stefan-niedermann Oct 31, 2020
e62ccdb
Make actual image capturing work
stefan-niedermann Oct 31, 2020
db3eacf
don't manually set minSdk
stefan-niedermann Oct 31, 2020
56fea2a
Minor improvements
stefan-niedermann Oct 31, 2020
a2aee6d
Use FLAG_ACTIVITY_SINGLE_TOP instead of FLAG_ACTIVITY_NEW_TASK for Ta…
stefan-niedermann Nov 1, 2020
a6839a0
Use FLAG_ACTIVITY_SINGLE_TOP instead of FLAG_ACTIVITY_NEW_TASK for Ta…
stefan-niedermann Nov 1, 2020
7ebc173
Allow to toggle camera & flashlight
stefan-niedermann Nov 1, 2020
1878160
Merge branch 'master' into 289-upload-sources
stefan-niedermann Nov 1, 2020
572fb47
Lower targetSdk to 29 because of https://github.com/nextcloud/Android…
stefan-niedermann Nov 1, 2020
e646639
Do not continue with contacts picker if camera permissions haven't be…
stefan-niedermann Nov 1, 2020
35ff744
Minor refactoring
stefan-niedermann Nov 1, 2020
f05402c
Minor refactoring
stefan-niedermann Nov 1, 2020
ad41b1d
Fix crash on Android 4.4
stefan-niedermann Nov 1, 2020
1ebcfa9
Hide camera button on Android < 5
stefan-niedermann Nov 1, 2020
68d56e6
Make sure that without branding the icons are still white
stefan-niedermann Nov 1, 2020
d68058c
Remove not needed dependency
stefan-niedermann Nov 1, 2020
611bbce
Correctly recognize mime type of captured image
stefan-niedermann Nov 1, 2020
c36ef84
Fix position of added attachments
stefan-niedermann Nov 1, 2020
7eb093c
Minor stuff
stefan-niedermann Nov 1, 2020
ea7895c
Use LiveData for empty content view
stefan-niedermann Nov 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
compileSdkVersion 29
defaultConfig {
applicationId "it.niedermann.nextcloud.deck"
minSdkVersion 19
targetSdkVersion 30
targetSdkVersion 29
versionCode 1011001
versionName "1.11.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -67,6 +67,10 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

implementation "androidx.camera:camera-camera2:1.0.0-beta11"
implementation "androidx.camera:camera-lifecycle:1.0.0-beta11"
implementation "androidx.camera:camera-view:1.0.0-alpha18"

// Markdown
implementation 'com.yydcdut:markdown-processor:0.1.3'
implementation 'com.yydcdut:rxmarkdown-wrapper:0.1.3'
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera.any" />

<uses-sdk tools:overrideLibrary="androidx.camera.core, androidx.camera.camera2, androidx.camera.lifecycle, androidx.camera.view" />

<application
android:name="it.niedermann.nextcloud.deck.DeckApplication"
Expand Down Expand Up @@ -49,6 +55,11 @@
android:parentActivityName=".ui.MainActivity"
android:windowSoftInputMode="stateHidden" />

<activity
android:name=".ui.takephoto.TakePhotoActivity"
android:theme="@style/TakePhotoTheme"
android:windowSoftInputMode="stateHidden" />

<activity
android:name=".ui.sharetarget.ShareTargetActivity"
android:label="@string/share_add_to_card"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import androidx.annotation.Nullable;
import androidx.core.app.ActivityOptionsCompat;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
Expand All @@ -28,6 +30,7 @@
import it.niedermann.nextcloud.deck.ui.branding.Branded;
import it.niedermann.nextcloud.deck.util.MimeTypeUtil;

import static androidx.lifecycle.Transformations.distinctUntilChanged;
import static androidx.recyclerview.widget.RecyclerView.NO_ID;
import static it.niedermann.nextcloud.deck.util.AttachmentUtil.openAttachmentInBrowser;

Expand All @@ -37,6 +40,9 @@ public class CardAttachmentAdapter extends RecyclerView.Adapter<AttachmentViewHo
public static final int VIEW_TYPE_DEFAULT = 2;
public static final int VIEW_TYPE_IMAGE = 1;

@NonNull
private MutableLiveData<Boolean> isEmpty = new MutableLiveData<>(true);
@NonNull
private final MenuInflater menuInflater;
@ColorInt
private int mainColor;
Expand All @@ -45,9 +51,9 @@ public class CardAttachmentAdapter extends RecyclerView.Adapter<AttachmentViewHo
private Long cardRemoteId = null;
private final long cardLocalId;
@NonNull
FragmentManager fragmentManager;
private final FragmentManager fragmentManager;
@NonNull
private List<Attachment> attachments = new ArrayList<>();
private final List<Attachment> attachments = new ArrayList<>();
@NonNull
private final AttachmentClickedListener attachmentClickedListener;

Expand Down Expand Up @@ -126,22 +132,41 @@ public int getItemCount() {
return attachments.size();
}

private void updateIsEmpty() {
this.isEmpty.postValue(getItemCount() <= 0);
}

@NonNull
public LiveData<Boolean> isEmpty() {
return distinctUntilChanged(this.isEmpty);
}

public void setAttachments(@NonNull List<Attachment> attachments, @Nullable Long cardRemoteId) {
this.cardRemoteId = cardRemoteId;
this.attachments.clear();
this.attachments.addAll(attachments);
notifyDataSetChanged();
this.updateIsEmpty();
}

public void addAttachment(Attachment a) {
this.attachments.add(a);
this.attachments.add(0, a);
notifyItemInserted(this.attachments.size());
this.updateIsEmpty();
}

public void removeAttachment(Attachment a) {
final int index = this.attachments.indexOf(a);
this.attachments.remove(a);
notifyItemRemoved(index);
this.updateIsEmpty();
}

public void replaceAttachment(Attachment toReplace, Attachment with) {
final int index = this.attachments.indexOf(toReplace);
this.attachments.remove(toReplace);
this.attachments.add(index, with);
notifyItemChanged(index);
}

@Override
Expand Down
Loading