-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: app type filter flag in analytics
- Loading branch information
Showing
7 changed files
with
216 additions
and
7 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
70 changes: 70 additions & 0 deletions
70
app/src/main/java/app/simple/inure/dialogs/analytics/AnalyticsSort.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,70 @@ | ||
package app.simple.inure.dialogs.analytics | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.FragmentManager | ||
import app.simple.inure.R | ||
import app.simple.inure.constants.SortConstant | ||
import app.simple.inure.extensions.fragments.ScopedBottomSheetFragment | ||
import app.simple.inure.preferences.AnalyticsPreferences | ||
import com.google.android.material.chip.ChipGroup | ||
|
||
class AnalyticsSort : ScopedBottomSheetFragment() { | ||
|
||
private lateinit var applicationTypeChipGroup: ChipGroup | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
val view = inflater.inflate(R.layout.dialog_sort_analytics, container, false) | ||
|
||
applicationTypeChipGroup = view.findViewById(R.id.application_type_chip_group) | ||
|
||
return view | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
setApplicationType() | ||
|
||
applicationTypeChipGroup.setOnCheckedStateChangeListener { _, checkedIds -> | ||
for (id in checkedIds) { | ||
when (id) { | ||
R.id.both -> { | ||
AnalyticsPreferences.setApplicationType(SortConstant.BOTH) | ||
} | ||
R.id.system -> { | ||
AnalyticsPreferences.setApplicationType(SortConstant.SYSTEM) | ||
} | ||
R.id.user -> { | ||
AnalyticsPreferences.setApplicationType(SortConstant.USER) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun setApplicationType() { | ||
when (AnalyticsPreferences.getApplicationType()) { | ||
SortConstant.BOTH -> applicationTypeChipGroup.check(R.id.both) | ||
SortConstant.SYSTEM -> applicationTypeChipGroup.check(R.id.system) | ||
SortConstant.USER -> applicationTypeChipGroup.check(R.id.user) | ||
} | ||
} | ||
|
||
companion object { | ||
const val TAG = "AnalyticsSort" | ||
|
||
fun newInstance(): AnalyticsSort { | ||
val args = Bundle() | ||
val fragment = AnalyticsSort() | ||
fragment.arguments = args | ||
return fragment | ||
} | ||
|
||
fun FragmentManager.showAnalyticsSort() { | ||
newInstance().show(this, TAG) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:clipChildren="false" | ||
android:clipToPadding="false"> | ||
|
||
<app.simple.inure.decorations.corners.DynamicCornerLinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:backgroundTint="@android:color/transparent" | ||
android:clipChildren="false" | ||
android:clipToPadding="false" | ||
android:layout_margin="@dimen/dialog_padding" | ||
android:orientation="vertical" | ||
android:padding="@dimen/dialog_padding"> | ||
|
||
<app.simple.inure.decorations.typeface.TypeFaceTextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/application_type" | ||
android:textSize="@dimen/preferences_title_text_size" | ||
android:layout_marginTop="5dp" | ||
app:appFontStyle="bold" | ||
app:textColorStyle="primary" /> | ||
|
||
<com.google.android.material.chip.ChipGroup | ||
android:id="@+id/application_type_chip_group" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:chipSpacingHorizontal="5dp" | ||
app:chipSpacingVertical="@dimen/chip_vertical_spacing" | ||
app:selectionRequired="true" | ||
app:singleSelection="true"> | ||
|
||
<app.simple.inure.decorations.views.Chip | ||
android:id="@+id/both" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/both" /> | ||
|
||
<app.simple.inure.decorations.views.Chip | ||
android:id="@+id/system" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/system" /> | ||
|
||
<app.simple.inure.decorations.views.Chip | ||
android:id="@+id/user" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/user" /> | ||
|
||
</com.google.android.material.chip.ChipGroup> | ||
|
||
</app.simple.inure.decorations.corners.DynamicCornerLinearLayout> | ||
</FrameLayout> |
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