Skip to content

Commit

Permalink
feat: Redesign program info activity (1/3)
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Oct 14, 2024
1 parent 1221ebc commit 860ad15
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 153 deletions.
52 changes: 18 additions & 34 deletions app/src/main/java/com/besome/sketch/help/ProgramInfoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;

import com.besome.sketch.lib.base.BaseAppCompatActivity;
import com.besome.sketch.lib.ui.PropertyOneLineItem;
import com.besome.sketch.lib.ui.PropertyTwoLineItem;
import com.sketchware.remod.R;
import com.sketchware.remod.databinding.ProgramInfoBinding;

import a.a.a.GB;
import a.a.a.aB;
Expand All @@ -25,7 +20,7 @@
import a.a.a.wB;
import mod.hey.studios.util.Helper;

public class ProgramInfoActivity extends BaseAppCompatActivity implements OnClickListener {
public class ProgramInfoActivity extends BaseAppCompatActivity {

private static final int ITEM_SYSTEM_INFORMATION = 1;
private static final int ITEM_DOCS_LOG = 4;
Expand All @@ -35,7 +30,7 @@ public class ProgramInfoActivity extends BaseAppCompatActivity implements OnClic
private static final int ITEM_OPEN_SOURCE_LICENSES = 15;
private static final int ITEM_SUGGEST_IDEAS = 17;

private LinearLayout content;
private ProgramInfoBinding binding;

private void addTwoLineItem(int key, int name, int description) {
addTwoLineItem(key, getString(name), getString(description));
Expand All @@ -46,8 +41,8 @@ private void addTwoLineItem(int key, String name, String description) {
item.setKey(key);
item.setName(name);
item.setDesc(description);
content.addView(item);
item.setOnClickListener(this);
binding.content.addView(item);
item.setOnClickListener(this::handleItem);
}

private void addSingleLineItem(int key, int name) {
Expand All @@ -58,9 +53,9 @@ private void addSingleLineItem(int key, String name) {
PropertyOneLineItem item = new PropertyOneLineItem(this);
item.setKey(key);
item.setName(name);
content.addView(item);
binding.content.addView(item);
if (key == ITEM_SYSTEM_INFORMATION || key == ITEM_OPEN_SOURCE_LICENSES) {
item.setOnClickListener(this);
item.setOnClickListener(this::handleItem);
}
}

Expand All @@ -86,13 +81,8 @@ private void resetDialog() {
dialog.show();
}

@Override
public void onClick(View v) {
private void handleItem(View v) {
if (!mB.a()) {
if (v.getId() == R.id.btn_app_init) {
resetDialog();
}

int key;
if (v instanceof PropertyOneLineItem) {
key = ((PropertyOneLineItem) v).getKey();
Expand Down Expand Up @@ -123,25 +113,20 @@ public void onClick(View v) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

binding = ProgramInfoBinding.inflate(getLayoutInflater());
setContentView(R.layout.program_info);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
findViewById(R.id.layout_main_logo).setVisibility(View.GONE);
getSupportActionBar().setTitle(Helper.getResString(R.string.main_drawer_title_program_information));
toolbar.setNavigationOnClickListener(Helper.getBackPressedClickListener(this));
content = findViewById(R.id.content);

TextView version = findViewById(R.id.tv_sketch_ver);
version.setText(GB.e(getApplicationContext()));
Button resetSystem = findViewById(R.id.btn_app_init);
resetSystem.setOnClickListener(this);
Button checkForUpdates = findViewById(R.id.btn_app_upgrade);
checkForUpdates.setOnClickListener(view -> {

binding.toolbar.setTitle(Helper.getResString(R.string.main_drawer_title_program_information));
binding.toolbar.setNavigationOnClickListener(Helper.getBackPressedClickListener(this));

binding.appVersion.setText(GB.e(getApplicationContext()));
binding.btnReset.setOnClickListener(this::resetSketchware);
binding.btnUpgrade.setOnClickListener(v -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.link_github_release)));
startActivity(intent);
});

addTwoLineItem(ITEM_DOCS_LOG, R.string.program_information_title_docs, R.string.link_docs_url);
addTwoLineItem(ITEM_SUGGEST_IDEAS, R.string.program_information_title_suggest_ideas, R.string.link_ideas_url);
addSingleLineItem(ITEM_SOCIAL_NETWORK, R.string.title_community);
Expand All @@ -167,5 +152,4 @@ private void openUrl(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}

}
163 changes: 77 additions & 86 deletions app/src/main/res/layout/program_info.xml
Original file line number Diff line number Diff line change
@@ -1,111 +1,102 @@
<LinearLayout 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:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">

<include layout="@layout/toolbar" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationIcon="?attr/homeAsUpIndicator"
app:elevation="0dp" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginTop="16dp"
android:contentDescription="@null"
android:src="@drawable/sketch_app_icon" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/title_sketchware"
android:textAppearance="?attr/textAppearanceHeadlineSmall"
android:textColor="?attr/colorPrimary" />
android:layout_height="wrap_content">

<TextView
android:id="@+id/tv_sketch_ver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:gravity="center"
android:textColor="?attr/colorOnSurface"
android:textIsSelectable="true"
android:textSize="16sp"
tools:text="Version 1.0.0" />
<ImageView
android:id="@+id/app_icon"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:src="@drawable/sketch_app_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
android:alpha="0.87"
android:gravity="center"
android:text="Copyright ⓒ Sketchware. All Rights Reserved."
android:textSize="13sp" />

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="?attr/colorOutlineVariant" />
<TextView
android:id="@+id/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/title_sketchware"
android:textAppearance="?attr/textAppearanceHeadlineSmall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/app_icon"
app:layout_constraintTop_toTopOf="@id/app_icon" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<TextView
android:id="@+id/app_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:textAppearance="?attr/textAppearanceBodyLarge"
android:textColor="?attr/colorPrimary"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/app_name"
app:layout_constraintTop_toBottomOf="@id/app_name"
tools:text="Version 1.0.0" />

<Button
android:id="@+id/btn_app_init"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="8dp"
android:text="@string/program_information_button_reset_system"
android:textSize="@dimen/text_size_button_material" />
<TextView
android:id="@+id/app_copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="Copyright ⓒ Sketchware. All Rights Reserved."
android:textAppearance="?attr/textAppearanceBodyMedium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/app_name"
app:layout_constraintTop_toBottomOf="@id/app_version" />

<Button
android:id="@+id/btn_app_upgrade"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:padding="8dp"
android:text="@string/program_information_button_check_update"
android:textSize="@dimen/text_size_button_material" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/btn_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="20dp"
android:layout_marginTop="12dp"
android:text="@string/program_information_button_reset_system"
app:layout_constraintEnd_toStartOf="@id/btn_upgrade"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_copyright" />

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="?attr/colorOutlineVariant" />
<Button
android:id="@+id/btn_upgrade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:text="@string/program_information_button_check_update"
app:layout_constraintStart_toEndOf="@id/btn_upgrade"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_copyright" />

<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_reset" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</LinearLayout>
24 changes: 9 additions & 15 deletions app/src/main/res/layout/program_info_item.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_item"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="?attr/selectableItemBackground">
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"
android:minHeight="60dp"
android:gravity="center_vertical">

<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:alpha="0.87"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceBodyMedium" />

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_alignParentBottom="true"
android:background="?attr/colorOutlineVariant" />

</RelativeLayout>
</LinearLayout>
29 changes: 11 additions & 18 deletions app/src/main/res/layout/program_info_two_line_item.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_item"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="?attr/selectableItemBackground">
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"
android:minHeight="60dp"
android:gravity="center_vertical">

<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:alpha="0.87"
android:textAppearance="?attr/textAppearanceBodyMedium" />

<TextView
android:id="@+id/tv_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_name"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:alpha="0.6"
android:textAppearance="?attr/textAppearanceBodySmall" />
android:textAppearance="?attr/textAppearanceBodySmall"
android:textColor="?attr/colorOnSurfaceVariant" />

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_alignParentBottom="true"
android:background="?attr/colorOutlineVariant" />

</RelativeLayout>
</LinearLayout>

0 comments on commit 860ad15

Please sign in to comment.