-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
270 changed files
with
9,692 additions
and
3,272 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
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
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
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
55 changes: 55 additions & 0 deletions
55
app/src/main/java/org/thoughtcrime/securesms/color/ViewColorSet.kt
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,55 @@ | ||
package org.thoughtcrime.securesms.color | ||
|
||
import android.content.Context | ||
import android.os.Parcelable | ||
import androidx.annotation.ColorInt | ||
import androidx.annotation.ColorRes | ||
import androidx.core.content.ContextCompat | ||
import kotlinx.parcelize.Parcelize | ||
import org.thoughtcrime.securesms.R | ||
|
||
/** | ||
* Represents a set of colors to be applied to the foreground and background of a view. | ||
* | ||
* Supports mixing color ints and color resource ids. | ||
*/ | ||
@Parcelize | ||
data class ViewColorSet( | ||
val foreground: ViewColor, | ||
val background: ViewColor | ||
) : Parcelable { | ||
companion object { | ||
val PRIMARY = ViewColorSet( | ||
foreground = ViewColor.ColorResource(R.color.signal_colorOnPrimary), | ||
background = ViewColor.ColorResource(R.color.signal_colorPrimary) | ||
) | ||
|
||
fun forCustomColor(@ColorInt customColor: Int): ViewColorSet { | ||
return ViewColorSet( | ||
foreground = ViewColor.ColorResource(R.color.signal_colorOnCustom), | ||
background = ViewColor.ColorValue(customColor) | ||
) | ||
} | ||
} | ||
|
||
@Parcelize | ||
sealed class ViewColor : Parcelable { | ||
|
||
@ColorInt | ||
abstract fun resolve(context: Context): Int | ||
|
||
@Parcelize | ||
data class ColorValue(@ColorInt val colorInt: Int) : ViewColor() { | ||
override fun resolve(context: Context): Int { | ||
return colorInt | ||
} | ||
} | ||
|
||
@Parcelize | ||
data class ColorResource(@ColorRes val colorRes: Int) : ViewColor() { | ||
override fun resolve(context: Context): Int { | ||
return ContextCompat.getColor(context, colorRes) | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/org/thoughtcrime/securesms/components/DialogFragmentDisplayManager.kt
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,35 @@ | ||
package org.thoughtcrime.securesms.components | ||
|
||
import androidx.fragment.app.DialogFragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
|
||
/** | ||
* Manages the lifecycle of displaying a dialog fragment. Will automatically close and nullify the reference | ||
* if the bound lifecycle is destroyed, and handles repeat calls to show such that no more than one dialog is | ||
* displayed. | ||
*/ | ||
class DialogFragmentDisplayManager(private val builder: () -> DialogFragment) : DefaultLifecycleObserver { | ||
|
||
private var dialogFragment: DialogFragment? = null | ||
|
||
fun show(lifecycleOwner: LifecycleOwner, fragmentManager: FragmentManager, tag: String? = null) { | ||
val fragment = dialogFragment ?: builder() | ||
if (fragment.dialog?.isShowing != true) { | ||
fragment.show(fragmentManager, tag) | ||
dialogFragment = fragment | ||
lifecycleOwner.lifecycle.addObserver(this) | ||
} | ||
} | ||
|
||
fun hide() { | ||
dialogFragment?.dismissNow() | ||
dialogFragment = null | ||
} | ||
|
||
override fun onDestroy(owner: LifecycleOwner) { | ||
owner.lifecycle.removeObserver(this) | ||
hide() | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
app/src/main/java/org/thoughtcrime/securesms/components/ProgressCardDialogFragment.kt
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,20 @@ | ||
package org.thoughtcrime.securesms.components | ||
|
||
import android.app.Dialog | ||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import androidx.fragment.app.DialogFragment | ||
import org.thoughtcrime.securesms.R | ||
|
||
/** | ||
* Displays a small progress spinner in a card view, as a non-cancellable dialog fragment. | ||
*/ | ||
class ProgressCardDialogFragment : DialogFragment(R.layout.progress_card_dialog) { | ||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
isCancelable = false | ||
return super.onCreateDialog(savedInstanceState).apply { | ||
this.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | ||
} | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.