-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from codeDamon/dev-branch
Added Settings Page
- Loading branch information
Showing
183 changed files
with
350 additions
and
3,366 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
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
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/vob/scanit/ui/activities/SettingsActivity.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,21 @@ | ||
package com.vob.scanit.ui.activities | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.vob.scanit.R | ||
import com.vob.scanit.ui.fragments.SettingsFragment | ||
|
||
class SettingsActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setTheme(R.style.SettingsTheme) | ||
setContentView(R.layout.activity_settings) | ||
|
||
if (savedInstanceState == null) { | ||
supportFragmentManager | ||
.beginTransaction() | ||
.replace(R.id.settings, SettingsFragment()) | ||
.commit() | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/src/main/java/com/vob/scanit/ui/fragments/SettingsFragment.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,58 @@ | ||
package com.vob.scanit.ui.fragments | ||
|
||
import android.content.pm.PackageInfo | ||
import android.content.pm.PackageManager | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.annotation.RequiresApi | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import androidx.core.content.res.ResourcesCompat | ||
import androidx.preference.Preference | ||
import androidx.preference.PreferenceFragmentCompat | ||
import androidx.preference.SwitchPreferenceCompat | ||
import com.vob.scanit.R | ||
|
||
class SettingsFragment : PreferenceFragmentCompat(), Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { | ||
|
||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
setPreferencesFromResource(R.xml.root_preferences, rootKey) | ||
|
||
findPreference<Preference>("privacy")?.onPreferenceClickListener = this | ||
findPreference<Preference>("licence")?.onPreferenceClickListener = this | ||
|
||
val pref = findPreference<SwitchPreferenceCompat>("theme_toggle") | ||
if (pref != null) { | ||
pref.onPreferenceChangeListener = this | ||
} | ||
} | ||
|
||
override fun onPreferenceClick(preference: Preference?): Boolean { | ||
|
||
if (preference != null) { | ||
when (preference.key) { | ||
"privacy" -> { | ||
Toast.makeText(context, "Privacy Policy", Toast.LENGTH_SHORT).show() | ||
//TODO | ||
} | ||
"licence" -> { | ||
Toast.makeText(context, "Open source licences", Toast.LENGTH_SHORT).show() | ||
//TODO | ||
} | ||
} | ||
} | ||
return true | ||
} | ||
|
||
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { | ||
if (preference is SwitchPreferenceCompat) { | ||
if (preference.key == "theme_toggle") { | ||
if (preference.isChecked) | ||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) | ||
else | ||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) | ||
} | ||
} | ||
return true | ||
} | ||
} |
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,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout 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:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".ui.activities.SettingsActivity"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="?android:attr/actionBarSize" | ||
android:id="@+id/appBarLayout"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/main_toolbar" | ||
android:background="@color/colorPrimaryDark" | ||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:title="@string/settings" | ||
> | ||
</androidx.appcompat.widget.Toolbar> | ||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<FrameLayout | ||
android:id="@+id/settings" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_below="@+id/appBarLayout" /> | ||
|
||
</RelativeLayout> |
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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
<item | ||
<!--<item | ||
android:id="@+id/search_item" | ||
android:icon="@drawable/ic_baseline_search_24" | ||
app:showAsAction="always" | ||
/> | ||
android:title="Search" /> | ||
<item | ||
android:id="@+id/about_item" | ||
android:title="About" | ||
app:showAsAction="never" | ||
/>--> | ||
<item | ||
android:id="@+id/settings_item" | ||
android:title="@string/settings" | ||
app:showAsAction="never" | ||
/> | ||
</menu> |
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#ED744A</color> | ||
<color name="colorPrimaryDark">#F87D52</color> | ||
<color name="colorAccent">#009688</color> | ||
<color name="NavyBlue">#141d26</color> | ||
<color name="Red">#FF0000</color> | ||
<color name="colorBackground">#121212</color> | ||
</resources> |
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,28 @@ | ||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<PreferenceCategory app:title="General" | ||
app:iconSpaceReserved="false"> | ||
|
||
<SwitchPreferenceCompat | ||
app:iconSpaceReserved="false" | ||
app:key="theme_toggle" | ||
app:summaryOn="Dark" | ||
app:summaryOff="Light" | ||
app:title="Theme" /> | ||
|
||
</PreferenceCategory> | ||
<PreferenceCategory app:title="About" | ||
app:iconSpaceReserved="false"> | ||
|
||
<Preference app:title="Open-source licences" | ||
app:key="licence" | ||
app:summary="Licence details for open-source software" | ||
app:iconSpaceReserved="false" /> | ||
|
||
<Preference app:title="Privacy Policy" | ||
app:key="privacy" | ||
app:summary="Read Privacy Policy" | ||
app:iconSpaceReserved="false" /> | ||
|
||
</PreferenceCategory> | ||
</PreferenceScreen> |
Binary file not shown.
Empty file.
Binary file removed
BIN
-226 KB
monscanner/build/intermediates/compile_library_classes_jar/debug/classes.jar
Binary file not shown.
Binary file not shown.
Oops, something went wrong.