mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Improved the naming of constant variables to "SCREAMING_SNAKE_CASE," which is our default naming convention for constants.
* Fixed some other ktlint issues.
This commit is contained in:
parent
6721be1764
commit
8527e2070d
@ -12,6 +12,7 @@ ktlint_standard_function-signature = disabled
|
||||
ktlint_standard_blank-line-before-declaration = disabled
|
||||
ktlint_standard_string-template-indent = disabled
|
||||
ktlint_standard_multiline-expression-wrapping = disabled
|
||||
ktlint_standard_package-name = disabled
|
||||
|
||||
[{*.sht,*.html,*.shtm,*.shtml,*.htm}]
|
||||
indent_style=space
|
||||
|
@ -19,118 +19,119 @@ package org.kiwix.kiwixmobile
|
||||
|
||||
// @LargeTest
|
||||
// @RunWith(AndroidJUnit4.class)
|
||||
class ZimTest { /*
|
||||
Temporary Disabled
|
||||
@Inject
|
||||
Context context;
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<KiwixMainActivity> mActivityTestRule = new ActivityTestRule<>(
|
||||
KiwixMainActivity.class, false, false);
|
||||
|
||||
@Before public void setUp() {
|
||||
TestComponent component = DaggerTestComponent.builder().applicationModule
|
||||
(new ApplicationModule(
|
||||
(CoreApp) getInstrumentation().getTargetContext().getApplicationContext())).build();
|
||||
|
||||
((CoreApp) getInstrumentation().getTargetContext().getApplicationContext()).setCoreComponent(component);
|
||||
|
||||
component.inject(this);
|
||||
new ZimContentProvider().setupDagger();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zimTest() {
|
||||
Intent intent = new Intent();
|
||||
File file = new File(context.getFilesDir(), "test.zim");
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
intent.setData(Uri.fromFile(file));
|
||||
|
||||
mActivityTestRule.launchActivity(intent);
|
||||
|
||||
try {
|
||||
onView(withId(R.id.menu_home)).perform(click());
|
||||
} catch (NoMatchingViewException e) {
|
||||
openContextualActionModeOverflowMenu();
|
||||
onView(withText("Home")).perform(click());
|
||||
}
|
||||
onWebView().withElement(findElement(Locator.LINK_TEXT, "A Fool for You"));
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open(Gravity.RIGHT));
|
||||
|
||||
ViewInteraction textView = onView(
|
||||
allOf(withId(R.id.titleText), withText("Summary"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.right_drawer_list),
|
||||
0),
|
||||
0),
|
||||
isDisplayed()));
|
||||
textView.check(matches(withText("Summary")));
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close(Gravity.RIGHT));
|
||||
|
||||
onWebView().withElement(findElement(Locator.LINK_TEXT, "A Fool for You")).perform(webClick());
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open(Gravity.RIGHT));
|
||||
|
||||
ViewInteraction textView2 = onView(
|
||||
allOf(withId(R.id.titleText), withText("A Fool for You"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.right_drawer_list),
|
||||
0),
|
||||
0),
|
||||
isDisplayed()));
|
||||
textView2.check(matches(withText("A Fool for You")));
|
||||
|
||||
ViewInteraction textView3 = onView(
|
||||
allOf(withId(R.id.titleText), withText("Personnel"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.right_drawer_list),
|
||||
1),
|
||||
0),
|
||||
isDisplayed()));
|
||||
textView3.check(matches(withText("Personnel")));
|
||||
|
||||
ViewInteraction textView4 = onView(
|
||||
allOf(withId(R.id.titleText), withText("Covers"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
withId(R.id.right_drawer_list),
|
||||
2),
|
||||
0),
|
||||
isDisplayed()));
|
||||
textView4.check(matches(withText("Covers")));
|
||||
|
||||
openContextualActionModeOverflowMenu();
|
||||
|
||||
onView(withText("Help"))
|
||||
.perform(click());
|
||||
}
|
||||
|
||||
private static Matcher<View> childAtPosition(
|
||||
final Matcher<View> parentMatcher, final int position) {
|
||||
|
||||
return new TypeSafeMatcher<View>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Child at position " + position + " in parent ");
|
||||
parentMatcher.describeTo(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(View view) {
|
||||
ViewParent parent = view.getParent();
|
||||
return parent instanceof ViewGroup && parentMatcher.matches(parent)
|
||||
&& view.equals(((ViewGroup) parent).getChildAt(position));
|
||||
}
|
||||
};
|
||||
}
|
||||
*/
|
||||
class ZimTest {
|
||||
//
|
||||
// Temporary Disabled
|
||||
// @Inject
|
||||
// Context context;
|
||||
//
|
||||
// @Rule
|
||||
// public ActivityTestRule<KiwixMainActivity> mActivityTestRule = new ActivityTestRule<>(
|
||||
// KiwixMainActivity.class, false, false);
|
||||
//
|
||||
// @Before public void setUp() {
|
||||
// TestComponent component = DaggerTestComponent.builder().applicationModule
|
||||
// (new ApplicationModule(
|
||||
// (CoreApp) getInstrumentation().getTargetContext().getApplicationContext())).build();
|
||||
//
|
||||
// ((CoreApp) getInstrumentation().getTargetContext().getApplicationContext()).setCoreComponent(component);
|
||||
//
|
||||
// component.inject(this);
|
||||
// new ZimContentProvider().setupDagger();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void zimTest() {
|
||||
// Intent intent = new Intent();
|
||||
// File file = new File(context.getFilesDir(), "test.zim");
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// intent.setData(Uri.fromFile(file));
|
||||
//
|
||||
// mActivityTestRule.launchActivity(intent);
|
||||
//
|
||||
// try {
|
||||
// onView(withId(R.id.menu_home)).perform(click());
|
||||
// } catch (NoMatchingViewException e) {
|
||||
// openContextualActionModeOverflowMenu();
|
||||
// onView(withText("Home")).perform(click());
|
||||
// }
|
||||
// onWebView().withElement(findElement(Locator.LINK_TEXT, "A Fool for You"));
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open(Gravity.RIGHT));
|
||||
//
|
||||
// ViewInteraction textView = onView(
|
||||
// allOf(withId(R.id.titleText), withText("Summary"),
|
||||
// childAtPosition(
|
||||
// childAtPosition(
|
||||
// withId(R.id.right_drawer_list),
|
||||
// 0),
|
||||
// 0),
|
||||
// isDisplayed()));
|
||||
// textView.check(matches(withText("Summary")));
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.close(Gravity.RIGHT));
|
||||
//
|
||||
// onWebView().withElement(findElement(Locator.LINK_TEXT, "A Fool for You")).perform(webClick());
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open(Gravity.RIGHT));
|
||||
//
|
||||
// ViewInteraction textView2 = onView(
|
||||
// allOf(withId(R.id.titleText), withText("A Fool for You"),
|
||||
// childAtPosition(
|
||||
// childAtPosition(
|
||||
// withId(R.id.right_drawer_list),
|
||||
// 0),
|
||||
// 0),
|
||||
// isDisplayed()));
|
||||
// textView2.check(matches(withText("A Fool for You")));
|
||||
//
|
||||
// ViewInteraction textView3 = onView(
|
||||
// allOf(withId(R.id.titleText), withText("Personnel"),
|
||||
// childAtPosition(
|
||||
// childAtPosition(
|
||||
// withId(R.id.right_drawer_list),
|
||||
// 1),
|
||||
// 0),
|
||||
// isDisplayed()));
|
||||
// textView3.check(matches(withText("Personnel")));
|
||||
//
|
||||
// ViewInteraction textView4 = onView(
|
||||
// allOf(withId(R.id.titleText), withText("Covers"),
|
||||
// childAtPosition(
|
||||
// childAtPosition(
|
||||
// withId(R.id.right_drawer_list),
|
||||
// 2),
|
||||
// 0),
|
||||
// isDisplayed()));
|
||||
// textView4.check(matches(withText("Covers")));
|
||||
//
|
||||
// openContextualActionModeOverflowMenu();
|
||||
//
|
||||
// onView(withText("Help"))
|
||||
// .perform(click());
|
||||
// }
|
||||
//
|
||||
// private static Matcher<View> childAtPosition(
|
||||
// final Matcher<View> parentMatcher, final int position) {
|
||||
//
|
||||
// return new TypeSafeMatcher<View>() {
|
||||
// @Override
|
||||
// public void describeTo(Description description) {
|
||||
// description.appendText("Child at position " + position + " in parent ");
|
||||
// parentMatcher.describeTo(description);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean matchesSafely(View view) {
|
||||
// ViewParent parent = view.getParent();
|
||||
// return parent instanceof ViewGroup && parentMatcher.matches(parent)
|
||||
// && view.equals(((ViewGroup) parent).getChildAt(position));
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ import javax.inject.Singleton
|
||||
object TestUtils {
|
||||
private const val TAG = "TESTUTILS"
|
||||
|
||||
@JvmField var TEST_PAUSE_MS = 3000
|
||||
var TEST_PAUSE_MS_FOR_SEARCH_TEST = 1000
|
||||
var TEST_PAUSE_MS_FOR_DOWNLOAD_TEST = 10000
|
||||
const val TEST_PAUSE_MS = 3000
|
||||
const val TEST_PAUSE_MS_FOR_SEARCH_TEST = 1000
|
||||
const val TEST_PAUSE_MS_FOR_DOWNLOAD_TEST = 10000
|
||||
const val RETRY_COUNT_FOR_FLAKY_TEST = 3
|
||||
|
||||
/*
|
||||
|
@ -40,9 +40,9 @@ import javax.inject.Inject
|
||||
|
||||
class IntroFragment : BaseFragment(), IntroContract.View, FragmentActivityExtensions {
|
||||
companion object {
|
||||
private const val timerDelay: Long = 0
|
||||
private const val timerPeriod: Long = 2000
|
||||
private const val animationDuration: Long = 800
|
||||
private const val TIMER_DELAY: Long = 0
|
||||
private const val TIMER_PERIOD: Long = 2000
|
||||
private const val ANIMATION_DURATION: Long = 800
|
||||
}
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
@ -83,8 +83,8 @@ class IntroFragment : BaseFragment(), IntroContract.View, FragmentActivityExtens
|
||||
}
|
||||
}
|
||||
},
|
||||
timerDelay,
|
||||
timerPeriod
|
||||
TIMER_DELAY,
|
||||
TIMER_PERIOD
|
||||
)
|
||||
views.forEach {
|
||||
it.setOnClickListener { dismissAutoRotate() }
|
||||
@ -123,7 +123,7 @@ class IntroFragment : BaseFragment(), IntroContract.View, FragmentActivityExtens
|
||||
val airplane = views[1].findViewById<ImageView>(R.id.airplane) ?: return
|
||||
airplane.isVisible = position == 1
|
||||
if (position == 1) {
|
||||
airplane.animate().translationX(airplane.width.toFloat()).duration = animationDuration
|
||||
airplane.animate().translationX(airplane.width.toFloat()).duration = ANIMATION_DURATION
|
||||
} else {
|
||||
airplane.animate().translationX(-airplane.width.toFloat())
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ data class BookmarkEntity(
|
||||
@Id var id: Long = 0,
|
||||
val zimId: String,
|
||||
var zimName: String,
|
||||
var zimFilePath: String?, // keep this to handle previously saved bookmarks
|
||||
// keep this to handle previously saved bookmarks
|
||||
var zimFilePath: String?,
|
||||
@Convert(converter = ZimSourceConverter::class, dbType = String::class)
|
||||
var zimReaderSource: ZimReaderSource?,
|
||||
var bookmarkUrl: String,
|
||||
@ -39,7 +40,8 @@ data class BookmarkEntity(
|
||||
item.databaseId,
|
||||
item.zimId,
|
||||
item.zimName,
|
||||
null, // pass null for new bookmarks
|
||||
// pass null for new bookmarks
|
||||
null,
|
||||
item.zimReaderSource,
|
||||
item.bookmarkUrl,
|
||||
item.title,
|
||||
|
@ -28,7 +28,8 @@ data class HistoryEntity(
|
||||
@Id var id: Long = 0L,
|
||||
val zimId: String,
|
||||
val zimName: String,
|
||||
val zimFilePath: String?, // keep this to handle previously saved history
|
||||
// keep this to handle previously saved history
|
||||
val zimFilePath: String?,
|
||||
@Convert(converter = ZimSourceConverter::class, dbType = String::class)
|
||||
var zimReaderSource: ZimReaderSource?,
|
||||
val favicon: String?,
|
||||
@ -41,7 +42,8 @@ data class HistoryEntity(
|
||||
historyItem.databaseId,
|
||||
historyItem.zimId,
|
||||
historyItem.zimName,
|
||||
null, // pass null for new history items
|
||||
// pass null for new history items
|
||||
null,
|
||||
historyItem.zimReaderSource,
|
||||
historyItem.favicon,
|
||||
historyItem.historyUrl,
|
||||
|
@ -28,7 +28,8 @@ import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
|
||||
data class NotesEntity(
|
||||
@Id var id: Long = 0L,
|
||||
val zimId: String,
|
||||
var zimFilePath: String?, // keep this to handle previously saved notes
|
||||
// keep this to handle previously saved notes
|
||||
var zimFilePath: String?,
|
||||
@Convert(converter = ZimSourceConverter::class, dbType = String::class)
|
||||
var zimReaderSource: ZimReaderSource?,
|
||||
val zimUrl: String,
|
||||
@ -39,7 +40,8 @@ data class NotesEntity(
|
||||
constructor(item: NoteListItem) : this(
|
||||
id = item.databaseId,
|
||||
zimId = item.zimId,
|
||||
zimFilePath = null, // pass null for new notes
|
||||
// pass null for new notes
|
||||
zimFilePath = null,
|
||||
zimReaderSource = item.zimReaderSource,
|
||||
zimUrl = item.zimUrl,
|
||||
noteTitle = item.title,
|
||||
|
@ -30,7 +30,8 @@ data class NotesRoomEntity(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Long = 0L,
|
||||
val zimId: String,
|
||||
var zimFilePath: String?, // keep this to handle previously saved notes
|
||||
// keep this to handle previously saved notes
|
||||
var zimFilePath: String?,
|
||||
@TypeConverters(ZimSourceRoomConverter::class)
|
||||
var zimReaderSource: ZimReaderSource?,
|
||||
val zimUrl: String,
|
||||
|
@ -143,22 +143,22 @@ open class ErrorActivity : BaseActivity() {
|
||||
// List of supported email apps
|
||||
private val supportedEmailPackages =
|
||||
listOf(
|
||||
"com.google.android.gm", // Gmail
|
||||
"com.zoho.mail", // Zoho Mail
|
||||
"com.microsoft.office.outlook", // Outlook
|
||||
"com.yahoo.mobile.client.android.mail", // Yahoo Mail
|
||||
"me.bluemail.mail", // BlueMail
|
||||
"ch.protonmail.android", // ProtonMail
|
||||
"com.fsck.k9", // K-9 Mail
|
||||
"com.maildroid", // Maildroid
|
||||
"org.kman.AquaMail", // Aqua Mail
|
||||
"com.edison.android.mail", // Edison Mail
|
||||
"com.readdle.spark", // Spark
|
||||
"com.gmx.mobile.android.mail", // GMX Mail
|
||||
"com.fastmail", // FastMail
|
||||
"ru.mail.mailapp", // Mail.ru
|
||||
"ru.yandex.mail", // Yandex.Mail
|
||||
"de.tutao.tutanota" // Tutanota
|
||||
"com.google.android.gm",
|
||||
"com.zoho.mail",
|
||||
"com.microsoft.office.outlook",
|
||||
"com.yahoo.mobile.client.android.mail",
|
||||
"me.bluemail.mail",
|
||||
"ch.protonmail.android",
|
||||
"com.fsck.k9",
|
||||
"com.maildroid",
|
||||
"org.kman.AquaMail",
|
||||
"com.edison.android.mail",
|
||||
"com.readdle.spark",
|
||||
"com.gmx.mobile.android.mail",
|
||||
"com.fastmail",
|
||||
"ru.mail.mailapp",
|
||||
"ru.yandex.mail",
|
||||
"de.tutao.tutanota"
|
||||
)
|
||||
|
||||
private val sendEmailLauncher =
|
||||
|
@ -67,7 +67,6 @@ import javax.inject.Inject
|
||||
* Notes are saved as text files at location: "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
||||
*/
|
||||
|
||||
// constant
|
||||
const val DISABLE_ICON_ITEM_ALPHA = 130
|
||||
const val ENABLE_ICON_ITEM_ALPHA = 255
|
||||
|
||||
|
@ -30,5 +30,7 @@ data class BookmarkState(
|
||||
) : PageState<LibkiwixBookmarkItem>() {
|
||||
override val visiblePageItems: List<PageRelated> = filteredPageItems
|
||||
|
||||
override fun copyWithNewItems(newItems: List<LibkiwixBookmarkItem>): PageState<LibkiwixBookmarkItem> = copy(pageItems = newItems)
|
||||
override fun copyWithNewItems(
|
||||
newItems: List<LibkiwixBookmarkItem>
|
||||
): PageState<LibkiwixBookmarkItem> = copy(pageItems = newItems)
|
||||
}
|
||||
|
@ -48,7 +48,9 @@ class LanguageUtils(private val context: Context) {
|
||||
.map { locale -> locale.trim { it <= ' ' } }
|
||||
}
|
||||
|
||||
private fun sortWithCollator(languageCodesFromAssets: MutableList<LanguageContainer>): MutableList<LanguageContainer> {
|
||||
private fun sortWithCollator(
|
||||
languageCodesFromAssets: MutableList<LanguageContainer>
|
||||
): MutableList<LanguageContainer> {
|
||||
val localeCollator =
|
||||
Collator.getInstance(context.locale).apply { strength = Collator.SECONDARY }
|
||||
languageCodesFromAssets.sortWith(
|
||||
|
@ -42,10 +42,11 @@ object NetworkUtils {
|
||||
* check if network of type WIFI is connected
|
||||
*
|
||||
* @return true if WIFI is connected
|
||||
*
|
||||
* TODO method isWiFi should be renamed to isWifiConnected to
|
||||
* express the state which is checked
|
||||
* (postponed to refactoring deprecated android.net.* usage)
|
||||
*/
|
||||
// TODO method isWiFi should be renamed to isWifiConnected to
|
||||
// express the state which is checked
|
||||
// (postponed to refactoring deprecated android.net.* usage)
|
||||
fun isWiFi(context: Context): Boolean {
|
||||
val connectivity =
|
||||
context
|
||||
|
@ -37,87 +37,86 @@ import org.kiwix.kiwixmobile.core.extensions.getAttribute
|
||||
import org.kiwix.kiwixmobile.core.utils.StyleUtils.fromHtml
|
||||
import javax.inject.Inject
|
||||
|
||||
class AlertDialogShower @Inject constructor(private val activity: Activity) :
|
||||
DialogShower {
|
||||
companion object {
|
||||
const val externalLinkLeftMargin = 10
|
||||
const val externalLinkRightMargin = 10
|
||||
const val externalLinkTopMargin = 10
|
||||
const val externalLinkBottomMargin = 0
|
||||
}
|
||||
class AlertDialogShower @Inject constructor(private val activity: Activity) : DialogShower {
|
||||
companion object {
|
||||
const val EXTERNAL_LINK_LEFT_MARGIN = 10
|
||||
const val EXTERNAL_LINK_RIGHT_MARGIN = 10
|
||||
const val EXTERNAL_LINK_TOP_MARGIN = 10
|
||||
const val EXTERNAL_LINK_BOTTOM_MARGIN = 0
|
||||
}
|
||||
|
||||
override fun show(dialog: KiwixDialog, vararg clickListeners: () -> Unit, uri: Uri?) =
|
||||
create(dialog, *clickListeners, uri = uri).show()
|
||||
override fun show(dialog: KiwixDialog, vararg clickListeners: () -> Unit, uri: Uri?) =
|
||||
create(dialog, *clickListeners, uri = uri).show()
|
||||
|
||||
override fun create(dialog: KiwixDialog, vararg clickListeners: () -> Unit, uri: Uri?): Dialog {
|
||||
return AlertDialog.Builder(activity)
|
||||
.apply {
|
||||
dialog.title?.let(this::setTitle)
|
||||
dialog.icon?.let(this::setIcon)
|
||||
override fun create(dialog: KiwixDialog, vararg clickListeners: () -> Unit, uri: Uri?): Dialog {
|
||||
return AlertDialog.Builder(activity)
|
||||
.apply {
|
||||
dialog.title?.let(this::setTitle)
|
||||
dialog.icon?.let(this::setIcon)
|
||||
|
||||
dialog.message?.let { setMessage(activity.getString(it, *bodyArguments(dialog))) }
|
||||
setPositiveButton(dialog.positiveMessage) { _, _ ->
|
||||
clickListeners.getOrNull(0)
|
||||
dialog.message?.let { setMessage(activity.getString(it, *bodyArguments(dialog))) }
|
||||
setPositiveButton(dialog.positiveMessage) { _, _ ->
|
||||
clickListeners.getOrNull(0)
|
||||
?.invoke()
|
||||
}
|
||||
dialog.negativeMessage?.let {
|
||||
setNegativeButton(it) { _, _ ->
|
||||
clickListeners.getOrNull(1)
|
||||
?.invoke()
|
||||
}
|
||||
dialog.negativeMessage?.let {
|
||||
setNegativeButton(it) { _, _ ->
|
||||
clickListeners.getOrNull(1)
|
||||
?.invoke()
|
||||
}
|
||||
}
|
||||
dialog.neutralMessage?.let {
|
||||
setNeutralButton(it) { _, _ ->
|
||||
clickListeners.getOrNull(2)
|
||||
?.invoke()
|
||||
}
|
||||
}
|
||||
uri?.let {
|
||||
val frameLayout = FrameLayout(activity.baseContext)
|
||||
|
||||
val textView = TextView(activity.baseContext).apply {
|
||||
layoutParams = getFrameLayoutParams()
|
||||
gravity = Gravity.CENTER
|
||||
minHeight = resources.getDimensionPixelSize(R.dimen.material_minimum_height_and_width)
|
||||
setLinkTextColor(activity.getAttribute(attr.colorPrimary))
|
||||
setOnLongClickListener {
|
||||
val clipboard =
|
||||
ContextCompat.getSystemService(activity.baseContext, ClipboardManager::class.java)
|
||||
val clip = ClipData.newPlainText("External Url", "$uri")
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
Toast.makeText(
|
||||
activity.baseContext,
|
||||
R.string.external_link_copied_message,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
true
|
||||
}
|
||||
@SuppressLint("SetTextI18n")
|
||||
text = "</br><a href=$uri> <b>$uri</b>".fromHtml()
|
||||
}
|
||||
frameLayout.addView(textView)
|
||||
setView(frameLayout)
|
||||
}
|
||||
dialog.getView?.let { setView(it()) }
|
||||
setCancelable(dialog.cancelable)
|
||||
}
|
||||
.create()
|
||||
}
|
||||
dialog.neutralMessage?.let {
|
||||
setNeutralButton(it) { _, _ ->
|
||||
clickListeners.getOrNull(2)
|
||||
?.invoke()
|
||||
}
|
||||
}
|
||||
uri?.let {
|
||||
val frameLayout = FrameLayout(activity.baseContext)
|
||||
|
||||
private fun getFrameLayoutParams() = FrameLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
topMargin = externalLinkTopMargin
|
||||
bottomMargin = externalLinkBottomMargin
|
||||
leftMargin = externalLinkLeftMargin
|
||||
rightMargin = externalLinkRightMargin
|
||||
}
|
||||
|
||||
private fun bodyArguments(dialog: KiwixDialog) =
|
||||
if (dialog is HasBodyFormatArgs) {
|
||||
dialog.args.toTypedArray()
|
||||
} else {
|
||||
emptyArray()
|
||||
val textView = TextView(activity.baseContext).apply {
|
||||
layoutParams = getFrameLayoutParams()
|
||||
gravity = Gravity.CENTER
|
||||
minHeight = resources.getDimensionPixelSize(R.dimen.material_minimum_height_and_width)
|
||||
setLinkTextColor(activity.getAttribute(attr.colorPrimary))
|
||||
setOnLongClickListener {
|
||||
val clipboard =
|
||||
ContextCompat.getSystemService(activity.baseContext, ClipboardManager::class.java)
|
||||
val clip = ClipData.newPlainText("External Url", "$uri")
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
Toast.makeText(
|
||||
activity.baseContext,
|
||||
R.string.external_link_copied_message,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
true
|
||||
}
|
||||
@SuppressLint("SetTextI18n")
|
||||
text = "</br><a href=$uri> <b>$uri</b>".fromHtml()
|
||||
}
|
||||
frameLayout.addView(textView)
|
||||
setView(frameLayout)
|
||||
}
|
||||
dialog.getView?.let { setView(it()) }
|
||||
setCancelable(dialog.cancelable)
|
||||
}
|
||||
.create()
|
||||
}
|
||||
|
||||
private fun getFrameLayoutParams() = FrameLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
topMargin = EXTERNAL_LINK_TOP_MARGIN
|
||||
bottomMargin = EXTERNAL_LINK_BOTTOM_MARGIN
|
||||
leftMargin = EXTERNAL_LINK_LEFT_MARGIN
|
||||
rightMargin = EXTERNAL_LINK_RIGHT_MARGIN
|
||||
}
|
||||
|
||||
private fun bodyArguments(dialog: KiwixDialog) =
|
||||
if (dialog is HasBodyFormatArgs) {
|
||||
dialog.args.toTypedArray()
|
||||
} else {
|
||||
emptyArray()
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,11 @@ import java.lang.System.currentTimeMillis
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/** Authored by s-ayush2903 on 19 June 2020 */
|
||||
|
||||
/** A class for writing logs to the file in the device */
|
||||
/**
|
||||
* Authored by s-ayush2903 on 19 June 2020
|
||||
*
|
||||
* A class for writing logs to the file in the device
|
||||
*/
|
||||
@Singleton
|
||||
class FileLogger @Inject constructor() {
|
||||
fun writeLogFile(context: Context, shouldWriteDeviceLogs: Boolean = true): File {
|
||||
|
Loading…
x
Reference in New Issue
Block a user