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

feat:Implemented Install Keyboard Page #163

Merged
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/src/main/java/be/scri/fragments/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AboutFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
): View {
binding = FragmentAboutBinding.inflate(inflater, container, false)
val callback =
requireActivity().onBackPressedDispatcher.addCallback(this) {
Expand Down
49 changes: 0 additions & 49 deletions app/src/main/java/be/scri/fragments/MainFragment.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package be.scri.fragments

import android.content.Context
import android.content.Context.INPUT_METHOD_SERVICE
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
Expand All @@ -10,14 +9,12 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatDelegate
import androidx.fragment.app.Fragment
import be.scri.R
import be.scri.activities.MainActivity
import be.scri.databinding.FragmentMainBinding
import be.scri.dialogs.ConfirmationAdvancedDialog

class MainFragment : Fragment() {
private var _binding: FragmentMainBinding? = null
Expand All @@ -38,23 +35,6 @@ class MainFragment : Fragment() {

(requireActivity() as MainActivity).unsetActionBarLayoutMargin()
applyUserDarkModePreference()
if (!isKeyboardEnabled()) {
ConfirmationAdvancedDialog(
requireActivity(),
messageId = R.string.redirection_note,
positive = R.string.ok,
negative = 0,
) { success ->
if (success) {
Intent(Settings.ACTION_INPUT_METHOD_SETTINGS).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(this)
}
} else {
requireActivity().finish()
}
}
}
val callback =
requireActivity().onBackPressedDispatcher.addCallback(this) {
getParentFragmentManager().popBackStack()
Expand Down Expand Up @@ -92,42 +72,13 @@ class MainFragment : Fragment() {
}
}

override fun onResume() {
super.onResume()
if (!isKeyboardEnabled()) {
ConfirmationAdvancedDialog(
requireActivity(),
messageId = R.string.redirection_note,
positive = R.string.ok,
negative = 0,
) { success ->
if (success) {
Intent(Settings.ACTION_INPUT_METHOD_SETTINGS).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(this)
}
} else {
requireActivity().finish()
}
}
}
}

private fun openKeyboardSettings() {
Intent(Settings.ACTION_INPUT_METHOD_SETTINGS).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(this)
}
}

private fun isKeyboardEnabled(): Boolean {
val inputMethodManager = requireActivity().getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
val enabledKeyboards = inputMethodManager.enabledInputMethodList
return enabledKeyboards.any {
it.packageName == requireContext().packageName
}
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/be/scri/services/EnglishKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import be.scri.databinding.KeyboardViewCommandOptionsBinding
import be.scri.databinding.KeyboardViewKeyboardBinding
import be.scri.helpers.MyKeyboard
import be.scri.helpers.MyKeyboard.Companion.KEYCODE_ENTER
import be.scri.services.ItalianKeyboardIME.ScribeState
import be.scri.views.MyKeyboardView

class EnglishKeyboardIME : SimpleKeyboardIME() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/be/scri/views/MyKeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class MyKeyboardView

val wasDarkened = mBackgroundColor != mBackgroundColor.darkenColor()
mToolbarHolder?.apply {
keyboardBinding?.apply {
keyboardBinding.apply {
topKeyboardDivider.beGoneIf(wasDarkened)
topKeyboardDivider.background = ColorDrawable(strokeColor)

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/rounded_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/corner_polygon_color" />
<corners android:radius="12dp" />
</shape>
19 changes: 12 additions & 7 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/settings_constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -54,13 +52,20 @@
android:layout_height="wrap_content">

<Button
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:id="@+id/btnInstall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@color/corner_polygon_color"
android:layout_width= "600dp"
android:layout_height="80dp"
android:layout_marginStart="13dp"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/app_text_color"
android:background="@drawable/rounded_button"
android:padding="10dp"
android:text="@string/app.installation.title" />
android:textAllCaps="false"
android:text="@string/app.settings.button_install_keyboards" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/keyboard_view_keyboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
android:layout_marginEnd="@dimen/tiny_margin"
android:background="@drawable/cmd_bar_background_right_rounded"
android:contentDescription="@string/command_bar"
android:textAlignment="textStart"
app:layout_constraintBottom_toBottomOf="@+id/command_field"
app:layout_constraintEnd_toEndOf="@+id/command_field"
app:layout_constraintHorizontal_bias="0"
Expand Down