Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sdex committed Aug 12, 2021
1 parent ffa5543 commit 2953ce6
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 41 deletions.
17 changes: 12 additions & 5 deletions app/src/main/java/com/sdex/activityrunner/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import kotlinx.android.synthetic.main.activity_about.*

class AboutActivity : BaseActivity() {

override fun getLayout(): Int {
return R.layout.activity_about
}
override fun getLayout() = R.layout.activity_about

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -31,8 +29,17 @@ class AboutActivity : BaseActivity() {
dialog.show(supportFragmentManager, DonateDialog.TAG)
}

feedback.setOnClickListener {
AppUtils.sendFeedback(this)
version.setOnClickListener {
val dialog = DonateDialog.newInstance()
dialog.show(supportFragmentManager, DonateDialog.TAG)
}

source_code.setOnClickListener {
IntentUtils.openBrowser(this, AppUtils.REPOSITORY)
}

issues_tracker.setOnClickListener {
IntentUtils.openBrowser(this, AppUtils.ISSUES_TRACKER)
}

openSource.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DonateDialog : BaseDialogFragment() {
.setTitle(R.string.about_donation)
.setMessage(R.string.donate_message)
.setPositiveButton(R.string.donate_action_text) { _, _ ->
AppUtils.openLink(activity, "https://www.buymeacoffee.com/sdex")
AppUtils.openLink(requireActivity(), "https://www.buymeacoffee.com/sdex")
}
.create()
}
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/com/sdex/commons/util/AppUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
public class AppUtils {

public static final String PP = "https://cdn.rawgit.com/sdex/docs/58d79c9/am_pp_2.html";
public static final String EMAIL = "[email protected]";
public static final String REPOSITORY = "https://github.com/sdex/ActivityManager";
public static final String ISSUES_TRACKER = REPOSITORY + "/issues";

public static void openLink(Context context, String url) {
try {
Expand All @@ -20,10 +21,6 @@ public static void openLink(Context context, String url) {
}
}

public static void sendFeedback(Context context) {
sendEmail(context, EMAIL, "ActivityManager app feedback", "");
}

public static void sendEmail(Context context, String address, String subject, String text) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
Expand Down
95 changes: 71 additions & 24 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/donate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
android:visibility="gone"
app:cardBackgroundColor="@color/card_background"
app:cardCornerRadius="1dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/donate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp">

Expand All @@ -60,20 +61,61 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/source_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
app:cardBackgroundColor="@color/card_background"
app:cardCornerRadius="1dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp">

<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/about_image_size"
android:layout_height="@dimen/about_image_size"
android:layout_margin="4dp"
android:padding="8dp"
android:textColor="@color/text_color_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_about_open_source"
app:tint="@color/icon_tint" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_source_code"
android:textColor="@color/text_color_primary"
app:layout_constraintBottom_toBottomOf="@+id/icon"
app:layout_constraintStart_toEndOf="@+id/icon"
app:layout_constraintTop_toTopOf="@+id/icon" />

</androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:id="@+id/issues_tracker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
app:cardBackgroundColor="@color/card_background"
app:cardCornerRadius="1dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp">

Expand All @@ -86,12 +128,13 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_about_feedback" />
app:srcCompat="@drawable/ic_about_open_source"
app:tint="@color/icon_tint" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_contact_email"
android:text="@string/about_issues_tracker"
android:textColor="@color/text_color_primary"
app:layout_constraintBottom_toTopOf="@+id/guideline_feedback"
app:layout_constraintStart_toEndOf="@+id/image_view_feedback" />
Expand All @@ -113,20 +156,20 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/openSource"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
app:cardBackgroundColor="@color/card_background"
app:cardCornerRadius="1dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/openSource"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp">

Expand All @@ -139,7 +182,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_about_open_source" />
app:srcCompat="@drawable/ic_about_open_source"
app:tint="@color/icon_tint" />

<TextView
android:layout_width="wrap_content"
Expand All @@ -152,20 +196,20 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/privacyPolicy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
app:cardBackgroundColor="@color/card_background"
app:cardCornerRadius="1dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/privacyPolicy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp">

Expand All @@ -178,7 +222,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_about_privacy_policy" />
app:srcCompat="@drawable/ic_about_privacy_policy"
app:tint="@color/icon_tint" />

<TextView
android:layout_width="wrap_content"
Expand All @@ -191,19 +236,20 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
app:cardBackgroundColor="@color/card_background"
app:cardCornerRadius="1dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp">

Expand All @@ -216,7 +262,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_about_version" />
app:srcCompat="@drawable/ic_about_version"
app:tint="@color/icon_tint" />

<TextView
android:layout_width="wrap_content"
Expand Down Expand Up @@ -244,7 +291,7 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<View
android:layout_width="match_parent"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<item
android:id="@+id/action_about"
android:title="@string/action_about"
android:visible="false"
app:showAsAction="ifRoom" />
app:showAsAction="never" />

</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<color name="text_color_primary">#fafafa</color>
<color name="text_color_secondary">@color/darker_gray</color>
<color name="background">#222222</color>
<color name="background_gray">#222222</color>
<color name="card_background">#2a2a2a</color>
<color name="icon_tint">#e5e5e5</color>
<color name="list_divider">#323232</color>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- about -->
<string name="about_donation">Поддержать разработку</string>
<string name="about_version">Версия</string>
<string name="about_contact_email">Связаться с автором</string>
<string name="about_issues_tracker">Связаться с автором</string>
<string name="about_feedback">Сообщить о проблеме, задать вопрос…</string>
<string name="about_open_source">Библиотеки с открытым кодом</string>
<string name="about_open_privacy_policy">Политика конфиденциальности</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<!-- about -->
<string name="about_donation">Підтримати розробку</string>
<string name="about_version">Версія</string>
<string name="about_contact_email">Зв\'язатися з автором</string>
<string name="about_issues_tracker">Зв\'язатися з автором</string>
<string name="about_open_source">Бібліотеки з відкритим кодом</string>

<string name="input_key">Введіть ключ</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@

<!-- about -->
<string name="about_donation">Support development</string>
<string name="about_source_code">Source code</string>
<string name="about_version">Version</string>
<string name="about_version_format" translatable="false">%1$s (%2$d)</string>
<string name="about_contact_email">Send feedback</string>
<string name="about_issues_tracker">Issues tracker</string>
<string name="about_feedback">Report a problem, aks a question…</string>
<string name="about_open_source">Open source libraries</string>
<string name="about_open_privacy_policy">Privacy policy</string>

<string name="donate_message">If you like the app, please consider making some cash donation</string>
<string name="donate_message">If you like the app, please consider making some donation</string>
<string name="donate_action_text">Donate</string>

<string name="input_key">Input key</string>
Expand Down

0 comments on commit 2953ce6

Please sign in to comment.