Skip to content

Commit

Permalink
android app: refactor the app (useless rn)
Browse files Browse the repository at this point in the history
commit is useless af, just wanted to make this for wishsing everyone an 🎄 happy and joyful christmas 🎅 hoho
  • Loading branch information
Toni500github committed Dec 24, 2024
1 parent d3acc62 commit 371d59d
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 74 deletions.
5 changes: 2 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Settings_testing"
android:theme="@style/Theme.MainActivity"
tools:targetApi="31">
<receiver
android:name=".widget.customfetch"
Expand All @@ -34,11 +34,10 @@
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,18 @@ import android.util.Log
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceFragmentCompat
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.nio.file.Files
import kotlin.io.path.Path


class SettingsActivity : AppCompatActivity() {
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.settings_activity)
if (savedInstanceState == null) {
supportFragmentManager
.beginTransaction()
.replace(R.id.settings, SettingsFragment())
.commit()
}
supportActionBar?.setDisplayHomeAsUpEnabled(true)
setContentView(R.layout.activity_main)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
val alert = AlertDialog.Builder(this)
Expand All @@ -45,7 +37,7 @@ class SettingsActivity : AppCompatActivity() {
}
.setIcon(R.drawable.icon_alert_yellow)

val view: View = layoutInflater.inflate(R.layout.grant_perm, null, false);
val view: View = layoutInflater.inflate(R.layout.grant_perm, null, false)
alert.setView(view)
alert.show()
}
Expand All @@ -63,12 +55,6 @@ class SettingsActivity : AppCompatActivity() {
.setIcon(android.R.drawable.ic_dialog_info)
.show()
}

class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.root_preferences, rootKey)
}
}
}

const val TAG: String = "AssetCopy"
Expand Down
6 changes: 6 additions & 0 deletions android/app/src/main/res/drawable/round_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#2D2D2D" /> <!-- Background color -->
<corners android:radius="16dp" /> <!-- Rounded corners radius -->
<stroke android:width="2dp" android:color="#BBBBBB" /> <!-- Border color and width -->
</shape>
77 changes: 77 additions & 0 deletions android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:background="#2D2D2D"
style="@style/Theme.MainActivity"
tools:context=".MainActivity">

<TextView
android:id="@+id/spacer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<LinearLayout
android:id="@+id/testConfigFile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/round_border"
android:padding="16dp"
android:layout_marginTop="32dp"
app:layout_constraintTop_toBottomOf="@id/spacer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test config file"
android:textColor="#FFFFFF"
android:textSize="16sp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select a config file to test"
android:textColor="#BBBBBB"
android:textSize="14sp"
android:layout_marginTop="8dp" />
</LinearLayout>

<LinearLayout
android:id="@+id/aboutMe"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/round_border"
android:padding="16dp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/testConfigFile"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About me"
android:textColor="#FFFFFF"
android:textSize="16sp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About me and customfetch"
android:textColor="#BBBBBB"
android:textSize="14sp"
android:layout_marginTop="8dp" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion android/app/src/main/res/layout/customfetch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/widget_root"
android:theme="@style/Theme.Settings_testing.AppWidgetContainer">
android:theme="@style/Theme.MainActivity.AppWidgetContainer">

<TextView
android:id="@+id/customfetch_text"
Expand Down
9 changes: 0 additions & 9 deletions android/app/src/main/res/layout/settings_activity.xml

This file was deleted.

2 changes: 1 addition & 1 deletion android/app/src/main/res/values-night-v31/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--
Having themes.xml for night-v31 because of the priority order of the resource qualifiers.
-->
<style name="Theme.Settings_testing.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
<style name="Theme.MainActivity.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="appWidgetRadius">@android:dimen/system_app_widget_background_radius</item>
<item name="appWidgetInnerRadius">@android:dimen/system_app_widget_inner_radius</item>
</style>
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Settings_testing" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.MainActivity" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand Down
5 changes: 5 additions & 0 deletions android/app/src/main/res/values-v31/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="main_500">@android:color/system_accent1_500</color>
<color name="main_dark_800">@android:color/system_accent1_800</color>
</resources>
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Having themes.xml for v31 variant because @android:dimen/system_app_widget_background_radius
and @android:dimen/system_app_widget_internal_padding requires API level 31
-->
<style name="Theme.Settings_testing.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
<style name="Theme.MainActivity.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="appWidgetRadius">@android:dimen/system_app_widget_background_radius</item>
<item name="appWidgetInnerRadius">@android:dimen/system_app_widget_inner_radius</item>
</style>
Expand Down
10 changes: 5 additions & 5 deletions android/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Settings_testing" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.MainActivity" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorPrimary">@color/main_500</item>
<item name="colorPrimaryVariant">@color/main_dark_800</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
Expand All @@ -14,7 +14,7 @@
<!-- Customize your theme here. -->
</style>

<style name="Theme.Settings_testing.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault">
<style name="Theme.MainActivity.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault">
<!-- Radius of the outer bound of widgets to make the rounded corners -->
<item name="appWidgetRadius">16dp</item>
<!--
Expand All @@ -24,7 +24,7 @@
<item name="appWidgetInnerRadius">8dp</item>
</style>

<style name="Theme.Settings_testing.AppWidgetContainer" parent="Theme.Settings_testing.AppWidgetContainerParent">
<style name="Theme.MainActivity.AppWidgetContainer" parent="Theme.MainActivity.AppWidgetContainerParent">
<!-- Apply padding to avoid the content of the widget colliding with the rounded corners -->
<item name="appWidgetPadding">16dp</item>
</style>
Expand Down
35 changes: 0 additions & 35 deletions android/app/src/main/res/xml/root_preferences.xml

This file was deleted.

0 comments on commit 371d59d

Please sign in to comment.