Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {
dependencies {
val room_version = "2.5.0"

implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
// Jetpack
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
Expand Down
Binary file removed app/libs/shareapi.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ import com.haodustudio.DailyNotes.view.customView.freeLayout.objects.BitmapObjec
import com.haodustudio.DailyNotes.view.customView.freeLayout.objects.TextObject
import com.haodustudio.DailyNotes.viewModel.viewModels.GlobalViewModel
import com.permissionx.guolindev.PermissionX
import com.xtc.shareapi.share.communication.SendMessageToXTC
import com.xtc.shareapi.share.manager.ShareMessageManager
import com.xtc.shareapi.share.shareobject.XTCImageObject
import com.xtc.shareapi.share.shareobject.XTCShareMessage
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -106,7 +102,6 @@ class FreeMakeNote : DialogActivity(noShot = true, canDis = true) {
private fun handleIntentExtras() {
noteId = intent.getLongExtra("noteId", -1L)
isEditMode = intent.getBooleanExtra("editMode", false)
val shareMode = intent.getBooleanExtra("share", false)

setTheme(if (isEditMode) R.style.DialogActivityTheme else R.style.DialogActivityTheme2)

Expand All @@ -115,15 +110,6 @@ class FreeMakeNote : DialogActivity(noShot = true, canDis = true) {
finish()
return
}

if (shareMode) {
appViewModel.getNoteFromIdLiveData(noteId).observe(this) {
if (it != null && this.note == null) {
this.note = it
loadNoteContent(it, shareAfterLoad = true)
}
}
}
}

private fun setupUI() {
Expand All @@ -144,16 +130,13 @@ class FreeMakeNote : DialogActivity(noShot = true, canDis = true) {
}
}

private fun loadNoteContent(noteToLoad: Note, shareAfterLoad: Boolean = false) {
private fun loadNoteContent(noteToLoad: Note) {
try {
loadFreeObjects(noteToLoad.data["noteFolder"])
binding.freeLayout.addPaper(noteToLoad.data["pageSize"]?.toInt() ?: 0)
currentBackgroundColorId = noteToLoad.data["backgroundColor"]?.toInt() ?: 12
val colorRes = BaseApplication.idToTextColor[currentBackgroundColorId] ?: R.color.white
binding.backgroundColorRoot.setBackgroundColor(ContextCompat.getColor(this, colorRes))
if (shareAfterLoad) {
shareNoteAsImage()
}
} catch (e: Exception) {
e.printStackTrace()
makeToast("加载失败")
Expand Down Expand Up @@ -402,21 +385,4 @@ class FreeMakeNote : DialogActivity(noShot = true, canDis = true) {
e.printStackTrace()
}
}

private fun shareNoteAsImage() {
binding.viewToShot.postDelayed({
try {
val shareImage = BitmapUtils.viewConversionBitmap(binding.viewToShot)
val xtcImageObject = XTCImageObject().apply { setBitmap(shareImage) }
val xtcShareMessage = XTCShareMessage().apply { shareObject = xtcImageObject }
val request = SendMessageToXTC.Request().apply {
message = xtcShareMessage
flag = 1
}
ShareMessageManager(this).sendRequestToXTC(request, BaseApplication.APP_ID)
} catch (e: Exception) {
e.printStackTrace()
}
}, 800)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,5 @@ class NoteOption : DialogActivity(noShot = true) {
startActivity(mIntent)
finish()
}

binding.share.setOnClickListener {
val mIntent: Intent = when (type) {
NOTE_TYPE_V1 -> {
Intent(this, NoteViewer::class.java)
}
else -> {
Intent(this, FreeMakeNote::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
}
}
}
mIntent.putExtra("noteId", noteId)
mIntent.putExtra("share", true)
startActivity(mIntent)
finish()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import com.haodustudio.DailyNotes.view.adapters.FixLinearLayoutManager
import com.haodustudio.DailyNotes.view.adapters.ImageAdapter
import com.haodustudio.DailyNotes.view.adapters.RecordAdapter
import com.haodustudio.DailyNotes.viewModel.viewModels.GlobalViewModel
import com.xtc.shareapi.share.communication.SendMessageToXTC
import com.xtc.shareapi.share.manager.ShareMessageManager
import com.xtc.shareapi.share.shareobject.XTCImageObject
import com.xtc.shareapi.share.shareobject.XTCShareMessage
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -76,7 +72,6 @@ class NoteViewer : BaseActivity() {
binding.stickerLayout.setCanEdit(false)

val noteId = intent.getLongExtra("noteId", -1L)
val shareMode = intent.getBooleanExtra("share", false)
isEditing = intent.getBooleanExtra("editMode", false)

if (noteId == -1L) {
Expand All @@ -87,13 +82,13 @@ class NoteViewer : BaseActivity() {

appViewModel.getNoteFromIdLiveData(noteId).observe(this) { updatedNote ->
noteData = updatedNote
updateUI(updatedNote, shareMode)
updateUI(updatedNote)
}

setupListeners()
}

private fun updateUI(note: Note, shareMode: Boolean) {
private fun updateUI(note: Note) {
try {
updateTittle(note.yy, note.mm, note.dd)
updateMood(note.mood)
Expand All @@ -103,12 +98,6 @@ class NoteViewer : BaseActivity() {
updateImage(note.data["imagePaths"]!!.toArray(), note.data["videoPaths"]!!.toArray())
updateRecord(note.data["recordPaths"]!!.toArray())
loadSticker(note)

if (shareMode) {
imageAdapter.setOnAllDoneListener {
shotToShare()
}
}
} catch (e: Exception) {
makeToast("Failed to load note data")
e.printStackTrace()
Expand Down Expand Up @@ -260,22 +249,4 @@ class NoteViewer : BaseActivity() {
}
}

private fun shotToShare() {
lifecycleScope.launch {
delay(800)
try {
val shareImage = BitmapUtils.viewConversionBitmap(binding.viewForShot)
val xtcImageObject = XTCImageObject().apply { setBitmap(shareImage) }
val xtcShareMessage = XTCShareMessage().apply { shareObject = xtcImageObject }
val request = SendMessageToXTC.Request().apply {
message = xtcShareMessage
flag = 1
}
ShareMessageManager(this@NoteViewer).sendRequestToXTC(request, BaseApplication.APP_ID)
} catch (e: Exception) {
e.printStackTrace()
withContext(Dispatchers.Main) { makeToast("分享失败") }
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.haodustudio.DailyNotes.databinding.ActivityViewImageBinding
import com.haodustudio.DailyNotes.helper.makeToast
import com.haodustudio.DailyNotes.utils.BitmapUtils
import com.haodustudio.DailyNotes.view.activities.base.BaseActivity
import com.xtc.shareapi.share.utils.BitmapUtil.getScreenWidth


class ViewImage : BaseActivity() {
Expand Down
Binary file removed app/src/main/res/drawable/ic_note_opt_share.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions app/src/main/res/drawable/ic_privacy_dialog_user.xml

This file was deleted.

29 changes: 0 additions & 29 deletions app/src/main/res/layout/activity_note_option.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@
android:src="@drawable/ic_note_opt_edit" />
</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:id="@+id/share"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:src="@drawable/ic_note_opt_share" />
</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:id="@+id/delete"
android:layout_width="60dp"
Expand Down Expand Up @@ -87,18 +70,6 @@
app:layout_constraintStart_toStartOf="@+id/edit"
app:layout_constraintTop_toBottomOf="@+id/edit" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="分享"
android:textColor="#FFF"
android:textSize="12dp"
app:layout_constraintEnd_toEndOf="@+id/share"
app:layout_constraintStart_toStartOf="@+id/share"
app:layout_constraintTop_toBottomOf="@+id/share" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
Loading