Skip to content

Commit

Permalink
profile modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
SaeedDev94 committed Mar 1, 2024
1 parent cc0f2b8 commit 0c509b8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import io.github.saeeddev94.xray.database.XrayDatabase
import io.github.saeeddev94.xray.databinding.ActivityProfileBinding
import io.github.saeeddev94.xray.helper.FileHelper
import XrayCore.XrayCore
import android.view.Menu
import android.view.MenuItem
import com.blacksquircle.ui.editorkit.plugin.autoindent.autoIndentation
import com.blacksquircle.ui.editorkit.plugin.base.PluginSupplier
import com.blacksquircle.ui.editorkit.plugin.delimiters.highlightDelimiters
Expand All @@ -33,7 +35,6 @@ class ProfileActivity : AppCompatActivity() {
setContentView(binding.root)
setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
binding.profileSave.setOnClickListener { save() }
if (isNew()) {
resolved(Profile())
} else {
Expand All @@ -46,6 +47,19 @@ class ProfileActivity : AppCompatActivity() {
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_profile, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.saveProfile -> save()
else -> finish()
}
return true
}

private fun isNew() = id == 0L

private fun resolved(value: Profile) {
Expand Down
45 changes: 22 additions & 23 deletions app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,35 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profileName"
android:labelFor="@id/profileName" />
<EditText
android:id="@+id/profileName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:autofillHints="" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profileConfig"
android:labelFor="@id/profileConfig" />
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profileName"
android:labelFor="@id/profileName" />
<EditText
android:id="@+id/profileName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:autofillHints="" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profileConfig"
android:labelFor="@id/profileConfig" />
</LinearLayout>
<com.blacksquircle.ui.editorkit.widget.TextProcessor
android:id="@+id/profileConfig"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:autofillHints="" />
<Button
android:id="@+id/profileSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profileSave"
android:layout_marginTop="12dp" />
android:background="@null" />
</LinearLayout>
</ScrollView>
</LinearLayout>
9 changes: 9 additions & 0 deletions app/src/main/res/menu/menu_profile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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
android:id="@+id/saveProfile"
android:title="@string/saveProfile"
android:icon="@drawable/baseline_done"
app:showAsAction="ifRoom" />
</menu>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<string name="editProfile">Edit Profile</string>
<string name="profileName">Name</string>
<string name="profileConfig">Config</string>
<string name="profileSave">Save</string>
<string name="editIcon">Edit Icon</string>
<string name="deleteIcon">Delete Icon</string>
<string name="downloadIcon">Download Icon</string>
Expand All @@ -32,6 +31,7 @@
<string name="appIcon">App Icon</string>
<string name="saveExcludedApps">Save Excluded Apps</string>
<string name="saveSettings">Save Settings</string>
<string name="saveProfile">Save Profile</string>

<!-- Basic Settings -->
<string name="socksAddress">Socks Address</string>
Expand Down

0 comments on commit 0c509b8

Please sign in to comment.