diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackActivity.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackActivity.java
deleted file mode 100644
index 6f891d15..00000000
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackActivity.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package pl.szczodrzynski.edziennik.ui.modules.feedback;
-
-import android.os.Bundle;
-import android.view.MenuItem;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.databinding.DataBindingUtil;
-
-import pl.szczodrzynski.edziennik.App;
-import pl.szczodrzynski.edziennik.R;
-import pl.szczodrzynski.edziennik.databinding.ActivityFeedbackBinding;
-import pl.szczodrzynski.edziennik.utils.Themes;
-
-public class FeedbackActivity extends AppCompatActivity {
-
- private static final String TAG = "FeedbackActivity";
- private App app;
- private ActivityFeedbackBinding b;
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setTheme(Themes.INSTANCE.getAppTheme());
- b = DataBindingUtil.inflate(getLayoutInflater(), R.layout.activity_feedback, null, false);
- setContentView(b.getRoot());
- app = (App) getApplication();
-
- setSupportActionBar(b.toolbar);
- if (getSupportActionBar() != null)
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
-
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) // Press Back Icon
- {
- finish();
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- }
-}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackActivity.kt
new file mode 100644
index 00000000..fb751e3a
--- /dev/null
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackActivity.kt
@@ -0,0 +1,25 @@
+package pl.szczodrzynski.edziennik.ui.modules.feedback
+
+import android.os.Bundle
+import android.view.MenuItem
+import androidx.appcompat.app.AppCompatActivity
+import pl.szczodrzynski.edziennik.R
+import pl.szczodrzynski.edziennik.utils.Themes.appTheme
+
+class FeedbackActivity : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setTheme(appTheme)
+ setContentView(R.layout.activity_feedback)
+
+ val transaction = supportFragmentManager.beginTransaction()
+ transaction.replace(R.id.feedbackFragment, FeedbackFragment())
+ transaction.commitAllowingStateLoss()
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ if (item.itemId == android.R.id.home)
+ finish()
+ return super.onOptionsItemSelected(item)
+ }
+}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackFragment.kt
index de921aab..63f7500f 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackFragment.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/feedback/FeedbackFragment.kt
@@ -12,6 +12,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.PopupMenu
import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import coil.Coil
import coil.api.load
@@ -22,15 +23,26 @@ import kotlinx.coroutines.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
-import pl.szczodrzynski.edziennik.*
+import pl.szczodrzynski.edziennik.App
+import pl.szczodrzynski.edziennik.R
+import pl.szczodrzynski.edziennik.crc16
import pl.szczodrzynski.edziennik.data.api.events.FeedbackMessageEvent
import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi
import pl.szczodrzynski.edziennik.data.db.entity.FeedbackMessage
import pl.szczodrzynski.edziennik.databinding.FragmentFeedbackBinding
-import pl.szczodrzynski.edziennik.utils.Themes
+import pl.szczodrzynski.edziennik.onClick
import pl.szczodrzynski.edziennik.utils.Utils
import pl.szczodrzynski.edziennik.utils.Utils.openUrl
import java.util.*
+import kotlin.collections.List
+import kotlin.collections.any
+import kotlin.collections.filter
+import kotlin.collections.firstOrNull
+import kotlin.collections.forEach
+import kotlin.collections.forEachIndexed
+import kotlin.collections.isNotEmpty
+import kotlin.collections.mutableMapOf
+import kotlin.collections.set
import kotlin.coroutines.CoroutineContext
class FeedbackFragment : Fragment(), CoroutineScope {
@@ -39,7 +51,7 @@ class FeedbackFragment : Fragment(), CoroutineScope {
}
private lateinit var app: App
- private lateinit var activity: MainActivity
+ private lateinit var activity: AppCompatActivity
private lateinit var b: FragmentFeedbackBinding
private val job: Job = Job()
@@ -54,11 +66,10 @@ class FeedbackFragment : Fragment(), CoroutineScope {
private var receiver: BroadcastReceiver? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- activity = (getActivity() as MainActivity?) ?: return null
+ activity = (getActivity() as AppCompatActivity?) ?: return null
if (context == null)
return null
app = activity.application as App
- context!!.theme.applyStyle(Themes.appTheme, true)
// activity, context and profile is valid
b = FragmentFeedbackBinding.inflate(inflater)
// prevent doubled received messages on enter
@@ -239,7 +250,7 @@ class FeedbackFragment : Fragment(), CoroutineScope {
}
launch {
- val message = api.runCatching(activity.errorSnackbar) {
+ val message = api.runCatching(activity) {
val message = api.sendFeedbackMessage(
senderName = App.profile.accountName ?: App.profile.studentNameLong,
targetDeviceId = if (isDev) currentDeviceId else null,
diff --git a/app/src/main/res/layout/activity_feedback.xml b/app/src/main/res/layout/activity_feedback.xml
index 503b0e60..c48ce575 100644
--- a/app/src/main/res/layout/activity_feedback.xml
+++ b/app/src/main/res/layout/activity_feedback.xml
@@ -1,150 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+