Skip to content

Commit 041fea5

Browse files
author
Bene0202
committed
Final UI-Update Benedikt
1 parent aa8d610 commit 041fea5

12 files changed

Lines changed: 39 additions & 41 deletions

File tree

app/src/main/java/com/nlinterface/activities/BarcodeSettingsActivity.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.viewpager2.widget.ViewPager2
1212
import com.nlinterface.R
1313
import com.nlinterface.adapters.BarcodeSettingsFragmentAdapter
1414
import com.nlinterface.databinding.ActivityBarcodeSettingsBinding
15+
import com.nlinterface.fragments.BarcodeScannerScreen
1516
import com.nlinterface.fragments.BarcodeSettingsScreen1
1617
import com.nlinterface.fragments.BarcodeSettingsScreen2
1718
import com.nlinterface.fragments.BarcodeSettingsScreen3
@@ -377,12 +378,15 @@ class BarcodeSettingsActivity : AppCompatActivity() {
377378
val currentFragment = fragmentAdapter.getCurrentFragment(currentPosition)
378379
when (currentPosition) {
379380
0 -> {
380-
(currentFragment as BarcodeSettingsScreen1).onSwipeUp()
381+
(currentFragment as BarcodeScannerScreen).onSwipeUp()
381382
}
382383
1 -> {
383-
(currentFragment as BarcodeSettingsScreen2).onSwipeUp()
384+
(currentFragment as BarcodeSettingsScreen1).onSwipeUp()
384385
}
385386
2 -> {
387+
(currentFragment as BarcodeSettingsScreen2).onSwipeUp()
388+
}
389+
3 -> {
386390
(currentFragment as BarcodeSettingsScreen3).onSwipeUp()
387391
}
388392
}
@@ -392,13 +396,16 @@ class BarcodeSettingsActivity : AppCompatActivity() {
392396
val currentFragment = fragmentAdapter.getCurrentFragment(currentPosition)
393397
when (currentPosition) {
394398
0 -> {
395-
(currentFragment as BarcodeSettingsScreen1).onSwipeDown()
399+
(currentFragment as BarcodeScannerScreen).onSwipeUp()
396400
}
397401
1 -> {
398-
(currentFragment as BarcodeSettingsScreen2).onSwipeDown()
402+
(currentFragment as BarcodeSettingsScreen1).onSwipeUp()
399403
}
400404
2 -> {
401-
(currentFragment as BarcodeSettingsScreen3).onSwipeDown()
405+
(currentFragment as BarcodeSettingsScreen2).onSwipeUp()
406+
}
407+
3 -> {
408+
(currentFragment as BarcodeSettingsScreen3).onSwipeUp()
402409
}
403410
}
404411
}

app/src/main/java/com/nlinterface/adapters/BarcodeSettingsFragmentAdapter.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.nlinterface.adapters
33
import androidx.fragment.app.Fragment
44
import androidx.fragment.app.FragmentActivity
55
import androidx.viewpager2.adapter.FragmentStateAdapter
6+
import com.nlinterface.fragments.BarcodeScannerScreen
67
import com.nlinterface.fragments.BarcodeSettingsScreen1
78
import com.nlinterface.fragments.BarcodeSettingsScreen2
89
import com.nlinterface.fragments.BarcodeSettingsScreen3
@@ -21,6 +22,7 @@ class BarcodeSettingsFragmentAdapter(
2122
}
2223

2324
init {
25+
fragmentList.add(BarcodeScannerScreen())
2426
fragmentList.add(BarcodeSettingsScreen1())
2527
fragmentList.add(BarcodeSettingsScreen2())
2628
fragmentList.add(BarcodeSettingsScreen3())

app/src/main/java/com/nlinterface/fragments/BarcodeScannerScreen.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import android.view.View
1010
import android.view.ViewGroup
1111
import androidx.fragment.app.Fragment
1212
import androidx.lifecycle.ViewModelProvider
13-
import androidx.navigation.fragment.findNavController
1413
import com.nlinterface.R
15-
import com.nlinterface.activities.BarcodeSettingsActivity
1614
import com.nlinterface.activities.VoiceOnlyActivity
1715
import com.nlinterface.utility.STTInputType
1816
import com.nlinterface.utility.SwipeAction
@@ -61,33 +59,32 @@ class BarcodeScannerScreen : Fragment(), SwipeAction {
6159
* Starts the barcode scanner.
6260
*/
6361
override fun onSwipeLeft() {
64-
activity?.stopService(barcodeService)
65-
Log.i("Scanner", "Stopping the Barcode Scanning Service")
62+
6663
}
6764

6865
/**
6966
* Stops the barcode scanner.
7067
*/
7168
override fun onSwipeRight() {
72-
if (activity?.checkCallingOrSelfPermission( Manifest.permission.CAMERA ) ==
73-
PackageManager.PERMISSION_GRANTED) {
74-
activity?.startService(barcodeService)
75-
}
69+
7670
}
7771

7872
/**
7973
* Navigates to the barcode scanner settings.
8074
*/
8175
override fun onSwipeUp() {
82-
val intent = Intent(activity, BarcodeSettingsActivity::class.java)
83-
startActivity(intent)
76+
if (activity?.checkCallingOrSelfPermission( Manifest.permission.CAMERA ) ==
77+
PackageManager.PERMISSION_GRANTED) {
78+
activity?.startService(barcodeService)
79+
}
8480
}
8581

8682
/**
8783
* Navigates to the second screen of the main activity.
8884
*/
8985
override fun onSwipeDown() {
90-
findNavController().navigate(R.id.BarcodeScanner_to_Main2)
86+
activity?.stopService(barcodeService)
87+
Log.i("Scanner", "Stopping the Barcode Scanning Service")
9188
}
9289

9390
/**

app/src/main/java/com/nlinterface/fragments/MainScreen2.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
99
import androidx.lifecycle.ViewModelProvider
1010
import androidx.navigation.fragment.findNavController
1111
import com.nlinterface.R
12+
import com.nlinterface.activities.BarcodeSettingsActivity
1213
import com.nlinterface.activities.PlaceDetailsActivity
1314
import com.nlinterface.activities.VoiceOnlyActivity
1415
import com.nlinterface.utility.STTInputType
@@ -70,7 +71,8 @@ class MainScreen2 : Fragment(), SwipeAction {
7071
* (It is included in the navigational framework for simplification purposes.)
7172
*/
7273
override fun onSwipeUp() {
73-
findNavController().navigate(R.id.Main2_to_BarcodeScanner)
74+
val intent = Intent(activity,BarcodeSettingsActivity::class.java)
75+
startActivity(intent)
7476
}
7577
/**
7678
*

app/src/main/java/com/nlinterface/fragments/SettingsScreen1.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import android.widget.Button
99
import androidx.fragment.app.Fragment
1010
import androidx.lifecycle.ViewModelProvider
1111
import com.nlinterface.R
12-
import com.nlinterface.activities.BarcodeSettingsActivity
1312
import com.nlinterface.activities.VoiceOnlyActivity
1413
import com.nlinterface.utility.GlobalParameters
1514
import com.nlinterface.utility.STTInputType
@@ -84,11 +83,9 @@ class SettingsScreen1 : Fragment(), SwipeAction {
8483
}
8584

8685
/**
87-
* Navigates to the barcode settings activitiy.
86+
*
8887
*/
8988
override fun onSwipeDown() {
90-
val intent = Intent(activity, BarcodeSettingsActivity::class.java)
91-
startActivity(intent)
9289
}
9390

9491
/**

app/src/main/res/layout/barcode_scanner.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
android:id="@+id/option_top"
9797
android:layout_width="200dp"
9898
android:layout_height="wrap_content"
99-
android:text="@string/main_menu"
99+
android:text="@string/start_the_barcode_scanner"
100100
android:backgroundTint="?colorPrimary"
101101
android:textColor="?android:textColorPrimary"
102102
app:autoSizeMaxTextSize="100sp"
@@ -114,7 +114,7 @@
114114
android:id="@+id/option_bottom"
115115
android:layout_width="200dp"
116116
android:layout_height="wrap_content"
117-
android:text="@string/barcode_scanner_settings"
117+
android:text="@string/stop_the_barcode_scanner"
118118
android:backgroundTint="?colorPrimary"
119119
android:textColor="?android:textColorPrimary"
120120
app:autoSizeMaxTextSize="100sp"
@@ -133,7 +133,7 @@
133133
android:id="@+id/option_left"
134134
android:layout_width="130dp"
135135
android:layout_height="wrap_content"
136-
android:text="@string/stop_the_barcode_scanner"
136+
android:text="@string/nothing_to_the_left"
137137
android:backgroundTint="?colorPrimary"
138138
android:textColor="?android:textColorPrimary"
139139
app:autoSizeMaxTextSize="100sp"
@@ -153,7 +153,7 @@
153153
android:id="@+id/option_right"
154154
android:layout_width="130dp"
155155
android:layout_height="wrap_content"
156-
android:text="@string/start_the_barcode_scanner"
156+
android:text="@string/barcode_scanner_settings"
157157
android:backgroundTint="?colorPrimary"
158158
android:textColor="?android:textColorPrimary"
159159
app:autoSizeMaxTextSize="100sp"

app/src/main/res/layout/barcode_scanner_settings_screen1.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
android:id="@+id/option_left"
135135
android:layout_width="130dp"
136136
android:layout_height="wrap_content"
137-
android:text="@string/more_options"
137+
android:text="@string/barcode_scanner"
138138
android:backgroundTint="?colorPrimary"
139139
android:textColor="?android:textColorPrimary"
140140
app:autoSizeMaxTextSize="100sp"

app/src/main/res/layout/barcode_scanner_settings_screen3.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
android:id="@+id/option_right"
154154
android:layout_width="130dp"
155155
android:layout_height="wrap_content"
156-
android:text="@string/more_options"
156+
android:text="@string/nothing_to_the_right"
157157
android:backgroundTint="?colorPrimary"
158158
android:textColor="?android:textColorPrimary"
159159
app:autoSizeMaxTextSize="100sp"

app/src/main/res/layout/settings_screen1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
android:id="@+id/option_bottom"
115115
android:layout_width="200dp"
116116
android:layout_height="wrap_content"
117-
android:text="@string/barcode_scanner_settings"
117+
android:text="@string/placeholder"
118118
android:backgroundTint="?colorPrimary"
119119
android:textColor="?android:textColorPrimary"
120120
app:autoSizeMaxTextSize="100sp"
@@ -133,7 +133,7 @@
133133
android:id="@+id/option_left"
134134
android:layout_width="130dp"
135135
android:layout_height="wrap_content"
136-
android:text="@string/more_settings"
136+
android:text="@string/nothing_to_the_left"
137137
android:backgroundTint="?colorPrimary"
138138
android:textColor="?android:textColorPrimary"
139139
app:autoSizeMaxTextSize="100sp"

app/src/main/res/navigation/main_nav.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,7 @@
2222
<action
2323
android:id="@+id/Main2_to_Main1"
2424
app:destination="@id/Main1"/>
25-
<action
26-
android:id="@+id/Main2_to_BarcodeScanner"
27-
app:destination="@id/BarcodeScanner"/>
2825
</fragment>
2926

30-
<fragment
31-
android:id="@+id/BarcodeScanner"
32-
android:name="com.nlinterface.fragments.BarcodeScannerScreen"
33-
android:label="BarcodeScanner"
34-
tools:layout="@layout/barcode_scanner">
35-
<action
36-
android:id="@+id/BarcodeScanner_to_Main2"
37-
app:destination="@id/Main2"/>
38-
</fragment>
27+
3928
</navigation>

0 commit comments

Comments
 (0)