mirror of
https://github.com/FatttSnake/OxygenToolbox.git
synced 2026-04-06 01:11:27 +08:00
Initialized about page
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.fatapp.oxygentoolbox.ui.about;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -7,12 +8,10 @@ import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.util.ResourceUtil;
|
||||
|
||||
public class AboutFragment extends Fragment {
|
||||
|
||||
@@ -20,15 +19,18 @@ public class AboutFragment extends Fragment {
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
aboutViewModel = new ViewModelProvider(this).get(AboutViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_about, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_about);
|
||||
aboutViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
|
||||
TextView appVersion = root.findViewById(R.id.app_version);
|
||||
appVersion.setText(String.format(ResourceUtil.getAppLocale(), "%s(%d)", ResourceUtil.getAppVersionName(), ResourceUtil.getAppVersionCode()));
|
||||
|
||||
TextView openSource = root.findViewById(R.id.open_source);
|
||||
openSource.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(getActivity(), LibrariesActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,6 @@ public class SettingFragment extends PreferenceFragmentCompat {
|
||||
Preference aboutPreference = findPreference(ResourceUtil.getString(R.string.setting_about_oxygen_toolbox_key));
|
||||
if (aboutPreference != null) {
|
||||
aboutPreference.setOnPreferenceClickListener(preference -> {
|
||||
/*
|
||||
Intent intent = new Intent(getActivity(), LibrariesActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
*/
|
||||
Navigation.findNavController(requireView()).navigate(R.id.action_setting_to_about);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -5,6 +5,8 @@ import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
@@ -161,4 +163,24 @@ public final class ResourceUtil {
|
||||
public static float pxToDp(int px) {
|
||||
return px / getDisplayMetrics().density + 0.5f;
|
||||
}
|
||||
|
||||
public static String getAppVersionName() {
|
||||
try {
|
||||
PackageManager packageManager = sApp.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(sApp.getPackageName(), 0);
|
||||
return packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return "Null";
|
||||
}
|
||||
}
|
||||
|
||||
public static int getAppVersionCode() {
|
||||
try {
|
||||
PackageManager packageManager = sApp.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(sApp.getPackageName(), 0);
|
||||
return packageInfo.versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/libraries_page"
|
||||
android:layout_width="match_parent"
|
||||
android:background="?attr/app_background"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.about.LibrariesActivity">
|
||||
|
||||
|
||||
@@ -4,19 +4,59 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/app_background"
|
||||
tools:context=".ui.about.AboutFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_about"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="@dimen/about_app_icon_size"
|
||||
android:layout_height="@dimen/about_app_icon_size"
|
||||
android:layout_marginTop="@dimen/about_activity_margin_top"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/about_icon_text_margin"
|
||||
android:text="@string/app_full_name"
|
||||
android:textSize="@dimen/default_text_size"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/about_text_text_margin"
|
||||
android:text="@string/nav_header_subtitle"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/about_text_text_margin"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_desc" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/open_source"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/about_activity_margin_bottom"
|
||||
android:text="@string/setting_open_source"
|
||||
android:textColor="?attr/app_theme"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,7 +2,8 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/app_background">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/bottom_nav_view_pager"
|
||||
@@ -11,17 +12,17 @@
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_navigation_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:labelVisibilityMode="selected"
|
||||
app:itemTextColor="?attr/app_on_theme"
|
||||
app:itemIconTint="?attr/app_on_theme"
|
||||
android:background="?attr/app_theme"
|
||||
app:itemIconTint="?attr/app_on_theme"
|
||||
app:itemTextColor="?attr/app_on_theme"
|
||||
app:labelVisibilityMode="selected"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/app_background"
|
||||
android:padding="15dp"
|
||||
tools:context=".ui.theme.ThemeFragment">
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
android:title="@string/menu_setting"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@@ -1,12 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">氧工具</string>
|
||||
<string name="app_full_name">氧工具</string>
|
||||
<string name="app_desc">All in One</string>
|
||||
|
||||
<string name="navigation_drawer_open">打开导航抽屉</string>
|
||||
<string name="navigation_drawer_close">关闭导航抽屉</string>
|
||||
<string name="nav_header_title">氧工具</string>
|
||||
<string name="nav_header_subtitle">All in One</string>
|
||||
<string name="nav_header_desc">氧工具</string>
|
||||
<string name="action_settings">设置</string>
|
||||
|
||||
<string name="menu_home">主页</string>
|
||||
<string name="menu_home_tools">工具</string>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">氧工具</string>
|
||||
<string name="app_full_name">氧工具</string>
|
||||
<string name="app_desc">All in One</string>
|
||||
|
||||
<string name="navigation_drawer_open">打开导航抽屉</string>
|
||||
<string name="navigation_drawer_close">关闭导航抽屉</string>
|
||||
<string name="nav_header_title">氧工具</string>
|
||||
<string name="nav_header_subtitle">All in One</string>
|
||||
<string name="nav_header_desc">氧工具</string>
|
||||
<string name="action_settings">设置</string>
|
||||
|
||||
<string name="menu_home">主页</string>
|
||||
<string name="menu_home_tools">工具</string>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">氧工具</string>
|
||||
<string name="app_full_name">氧工具</string>
|
||||
<string name="app_desc">All in One</string>
|
||||
|
||||
<string name="navigation_drawer_open">打开导航抽屉</string>
|
||||
<string name="navigation_drawer_close">关闭导航抽屉</string>
|
||||
<string name="nav_header_title">氧工具</string>
|
||||
<string name="nav_header_subtitle">All in One</string>
|
||||
<string name="nav_header_desc">氧工具</string>
|
||||
<string name="action_settings">设置</string>
|
||||
|
||||
<string name="menu_home">主页</string>
|
||||
<string name="menu_home_tools">工具</string>
|
||||
|
||||
@@ -12,4 +12,10 @@
|
||||
<dimen name="library_item_card_inner_padding">16dp</dimen>
|
||||
<dimen name="library_item_card_divider_padding_vertical">8dp</dimen>
|
||||
<dimen name="library_item_card_divider_padding_horizontal">16dp</dimen>
|
||||
|
||||
<dimen name="about_activity_margin_top">50dp</dimen>
|
||||
<dimen name="about_activity_margin_bottom">30dp</dimen>
|
||||
<dimen name="about_app_icon_size">96dp</dimen>
|
||||
<dimen name="about_icon_text_margin">20dp</dimen>
|
||||
<dimen name="about_text_text_margin">4dp</dimen>
|
||||
</resources>
|
||||
@@ -1,12 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Oxygen</string>
|
||||
<string name="app_full_name">Oxygen Toolbox</string>
|
||||
<string name="app_desc">All in One</string>
|
||||
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="nav_header_title">Oxygen Toolbox</string>
|
||||
<string name="nav_header_subtitle">All in One</string>
|
||||
<string name="nav_header_desc">Oxygen Toolbox</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="nav_header_title" translatable="false">@string/app_full_name</string>
|
||||
<string name="nav_header_subtitle" translatable="false">@string/app_desc</string>
|
||||
<string name="nav_header_desc" translatable="false">@string/app_full_name</string>
|
||||
|
||||
<string name="menu_home">Home</string>
|
||||
<string name="menu_home_tools">Tools</string>
|
||||
@@ -70,7 +72,7 @@
|
||||
<item>dark</item>
|
||||
</string-array>
|
||||
<string name="setting_ui_mode_default_value" translatable="false">system</string>
|
||||
<string name="setting_open_source">OpenSource</string>
|
||||
<string name="setting_open_source">Open Source License</string>
|
||||
<string name="setting_search">Search</string>
|
||||
<string name="setting_about">About</string>
|
||||
<string name="setting_about_oxygen_toolbox">About OxygenToolbox</string>
|
||||
|
||||
@@ -26,4 +26,9 @@
|
||||
<item name="android:textSize">@dimen/default_text_size</item>
|
||||
<item name="android:textColor">?attr/app_text_theme</item>
|
||||
</style>
|
||||
|
||||
<style name="RoundImage">
|
||||
<item name="cornerFamily">rounded</item>
|
||||
<item name="cornerSize">64dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user