mirror of
https://github.com/FatttSnake/OxygenToolbox.git
synced 2026-04-06 07:01:26 +08:00
Added launch page switch, LibrariesActivity, setting fragment to about fragment action.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'com.mikepenz.aboutlibraries.plugin'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -13,38 +14,93 @@ android {
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// Required when setting minSdkVersion to 20 or lower
|
||||
multiDexEnabled true
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
Properties buildPro = buildSign()
|
||||
storeFile file(buildPro['storeFile'])
|
||||
storePassword buildPro['storePassword']
|
||||
keyAlias buildPro['keyAlias']
|
||||
keyPassword buildPro['keyPassword']
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
signingConfig signingConfigs.release
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
zipAlignEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.all {
|
||||
variant ->
|
||||
variant.outputs.all {
|
||||
output -> outputFileName = new File(variant.name, "OxygenToolbox" + "_" + defaultConfig.versionName + "-" + defaultConfig.versionCode + "_" + buildType.name + ".apk")
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
// Flag to enable support for the new language APIs
|
||||
coreLibraryDesugaringEnabled true
|
||||
// Sets Java compatibility to Java 8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
namespace 'com.fatapp.oxygentoolbox'
|
||||
}
|
||||
|
||||
def buildSign() {
|
||||
Properties buildProperties = new Properties()
|
||||
buildProperties.load(new FileInputStream(file("../keystore.properties")))
|
||||
return buildProperties
|
||||
}
|
||||
|
||||
aboutLibraries {
|
||||
registerAndroidTasks = false
|
||||
outputFileName = "dependencies.json"
|
||||
exclusionPatterns = [
|
||||
~'androidx.*',
|
||||
~'org.jetbrains.*',
|
||||
~"com.google.android.*",
|
||||
~"com.google.guava:listenablefuture"
|
||||
]
|
||||
}
|
||||
|
||||
task exportLibrariesToJson(group: 'build', description: 'Generate libraries definitions json file', type: com.mikepenz.aboutlibraries.plugin.AboutLibrariesTask, dependsOn:'collectDependencies') {
|
||||
resultDirectory = project.file('src/main/res/raw/')
|
||||
variant = 'release'
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
def assembleTask = tasks.findByName("assembleDebug")
|
||||
assembleTask.dependsOn(exportLibrariesToJson)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
//noinspection GradleDependency
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
|
||||
implementation 'androidx.core:core-splashscreen:1.0.0-rc01'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,11 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.OxygenToolbox.Default">
|
||||
<activity
|
||||
android:name=".ui.about.LibrariesActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/setting_open_source"
|
||||
android:theme="@style/Theme.OxygenToolbox.Default" />
|
||||
<activity
|
||||
android:name=".SplashActivity"
|
||||
android:exported="true"
|
||||
|
||||
@@ -29,17 +29,7 @@ public class App extends Application {
|
||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
|
||||
ResourceUtil.init(App.this);
|
||||
SharedPreferencesUtils.init(App.this);
|
||||
String locale = SharedPreferencesUtils.getLocale();
|
||||
String language;
|
||||
String country;
|
||||
if (!locale.equals("default")) {
|
||||
language = locale.substring(0, locale.indexOf("_"));
|
||||
country = locale.substring(locale.indexOf("_") + 1);
|
||||
} else {
|
||||
language = ResourceUtil.getSystemLocale().get(0).getLanguage();
|
||||
country = ResourceUtil.getSystemLocale().get(0).getCountry();
|
||||
}
|
||||
setAppLanguage(getApplicationContext(), new Locale(language, country));
|
||||
setAppLanguage(getApplicationContext(), SharedPreferencesUtils.getLanguage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,7 +100,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.fatapp.oxygentoolbox.ui.about;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.ui.about.util.LibrariesAdapter;
|
||||
import com.fatapp.oxygentoolbox.util.DependenciesJson;
|
||||
import com.fatapp.oxygentoolbox.util.MultiLanguageUtils;
|
||||
import com.fatapp.oxygentoolbox.util.ResourceUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LibrariesActivity extends AppCompatActivity {
|
||||
private Toolbar toolbar;
|
||||
private ConstraintLayout librariesPage;
|
||||
private RecyclerView librariesRecyclerView;
|
||||
private SearchView searchView;
|
||||
|
||||
private LibrariesAdapter librariesAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_libraries);
|
||||
|
||||
initView();
|
||||
initLayout();
|
||||
loadLibraries();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
librariesPage = findViewById(R.id.libraries_page);
|
||||
librariesRecyclerView = findViewById(R.id.libraries_recycler_view);
|
||||
}
|
||||
|
||||
private void initLayout() {
|
||||
librariesPage.setPadding(0, ResourceUtil.getStatusBarHeight(getWindow(), getApplicationContext()), 0, 0);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(R.string.setting_open_source);
|
||||
}
|
||||
|
||||
private void loadLibraries() {
|
||||
StringBuilder dependenciesJson = new StringBuilder();
|
||||
try {
|
||||
InputStream inputStream = ResourceUtil.getResources().openRawResource(R.raw.dependencies);
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
String str;
|
||||
while ((str = bufferedReader.readLine()) != null) {
|
||||
dependenciesJson.append(str);
|
||||
}
|
||||
DependenciesJson dependencies = new Gson().fromJson(dependenciesJson.toString(), new TypeToken<DependenciesJson>() {
|
||||
}.getType());
|
||||
librariesRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
librariesAdapter = new LibrariesAdapter(this, dependencies);
|
||||
librariesRecyclerView.addItemDecoration(new LibrariesAdapter.LibrariesItemDecoration());
|
||||
librariesRecyclerView.setAdapter(librariesAdapter);
|
||||
} catch (IOException e) {
|
||||
Log.d("TAG", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.seach_view, menu);
|
||||
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
|
||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
|
||||
searchView.setMaxWidth(Integer.MAX_VALUE);
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
librariesAdapter.getFilter().filter(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
librariesAdapter.getFilter().filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// Close search view when back button pressed
|
||||
if (!searchView.isIconified()) {
|
||||
searchView.setIconified(true);
|
||||
return;
|
||||
}
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(MultiLanguageUtils.attachBaseContext(newBase));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
MultiLanguageUtils.attachBaseContext(getApplicationContext());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.fatapp.oxygentoolbox.ui.about.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.util.DependenciesJson;
|
||||
import com.fatapp.oxygentoolbox.util.LicenseJson;
|
||||
import com.fatapp.oxygentoolbox.util.ResourceUtil;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class LibrariesAdapter extends RecyclerView.Adapter<LibrariesAdapter.ViewHolder> implements Filterable {
|
||||
private final Context context;
|
||||
private final DependenciesJson dependencies;
|
||||
private List<DependenciesJson.LibrariesDTO> librariesFiltered;
|
||||
|
||||
public LibrariesAdapter(Context context, DependenciesJson dependencies) {
|
||||
this.context = context;
|
||||
this.dependencies = dependencies;
|
||||
this.librariesFiltered = dependencies.getLibraries();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_libraries, parent, false);
|
||||
|
||||
return new ViewHolder(inflate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
DependenciesJson.LibrariesDTO library = librariesFiltered.get(position);
|
||||
holder.getLibraryName().setText(library.getName());
|
||||
holder.getLibraryCreator().setText(library.getDevelopersStr());
|
||||
holder.getLibraryVersion().setText(library.getArtifactVersion());
|
||||
holder.getLibraryDescription().setText(library.getDescription());
|
||||
holder.getLibraryLicense().setText(getLicensesNameStr(library.getLicenses()));
|
||||
|
||||
String url = library.getWebsite() != null && !library.getWebsite().isEmpty() ? library.getWebsite() : library.getScm() != null && library.getScm().getUrl() != null && !library.getScm().getUrl().isEmpty() ? library.getScm().getUrl() : null;
|
||||
if (url != null) {
|
||||
holder.cardView.setOnClickListener(view -> context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))));
|
||||
}
|
||||
|
||||
holder.getLibraryLicense().setOnClickListener(view -> {
|
||||
for (String license : library.getLicenses()) {
|
||||
try {
|
||||
String licenseStr = new JSONObject(dependencies.getLicenses()).getString(license);
|
||||
LicenseJson licenseObject = new Gson().fromJson(licenseStr, new TypeToken<LicenseJson>() {
|
||||
}.getType());
|
||||
new MaterialAlertDialogBuilder(context).setMessage(licenseObject.getContent()).show();
|
||||
} catch (JSONException e) {
|
||||
new MaterialAlertDialogBuilder(context).setMessage(String.format("Could not load license \"%s\"", license)).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return librariesFiltered.size();
|
||||
}
|
||||
|
||||
private String getLicensesNameStr(List<String> licenses) {
|
||||
StringJoiner stringJoiner = new StringJoiner(", ");
|
||||
for (String license : licenses) {
|
||||
try {
|
||||
String licenseStr = new JSONObject(dependencies.getLicenses()).getString(license);
|
||||
LicenseJson licenseObject = new Gson().fromJson(licenseStr, new TypeToken<LicenseJson>() {
|
||||
}.getType());
|
||||
stringJoiner.add(licenseObject.getName());
|
||||
} catch (JSONException e) {
|
||||
stringJoiner.add(license);
|
||||
}
|
||||
}
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence charSequence) {
|
||||
List<DependenciesJson.LibrariesDTO> libraries = new ArrayList<>();
|
||||
if (charSequence.toString().isEmpty()) {
|
||||
libraries = dependencies.getLibraries();
|
||||
} else {
|
||||
for (DependenciesJson.LibrariesDTO library : dependencies.getLibraries()) {
|
||||
if (library.getName().toLowerCase().contains(charSequence.toString().toLowerCase())) {
|
||||
libraries.add(library);
|
||||
}
|
||||
}
|
||||
}
|
||||
FilterResults results = new FilterResults();
|
||||
results.count = libraries.size();
|
||||
results.values = libraries;
|
||||
return results;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
|
||||
librariesFiltered = (ArrayList<DependenciesJson.LibrariesDTO>) filterResults.values;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private final MaterialCardView cardView;
|
||||
private final TextView libraryName;
|
||||
private final TextView libraryCreator;
|
||||
private final TextView libraryVersion;
|
||||
private final TextView libraryDescription;
|
||||
private final TextView libraryLicense;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
cardView = (MaterialCardView) itemView;
|
||||
libraryName = itemView.findViewById(R.id.library_name);
|
||||
libraryCreator = itemView.findViewById(R.id.library_creator);
|
||||
libraryVersion = itemView.findViewById(R.id.library_version);
|
||||
libraryDescription = itemView.findViewById(R.id.library_description);
|
||||
libraryLicense = itemView.findViewById(R.id.library_license);
|
||||
}
|
||||
|
||||
public TextView getLibraryName() {
|
||||
return libraryName;
|
||||
}
|
||||
|
||||
public TextView getLibraryCreator() {
|
||||
return libraryCreator;
|
||||
}
|
||||
|
||||
public TextView getLibraryVersion() {
|
||||
return libraryVersion;
|
||||
}
|
||||
|
||||
public TextView getLibraryDescription() {
|
||||
return libraryDescription;
|
||||
}
|
||||
|
||||
public TextView getLibraryLicense() {
|
||||
return libraryLicense;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LibrariesItemDecoration extends RecyclerView.ItemDecoration {
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
if (parent.getChildLayoutPosition(view) != 0) {
|
||||
outRect.top = -ResourceUtil.dpToPx(10f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.ui.home.fav.FavFragment;
|
||||
import com.fatapp.oxygentoolbox.ui.home.tools.ToolsFragment;
|
||||
import com.fatapp.oxygentoolbox.util.SharedPreferencesUtils;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
@@ -29,7 +30,7 @@ public class HomeFragment extends Fragment {
|
||||
ViewPager2 bottomNavViewPager = root.findViewById(R.id.bottom_nav_view_pager);
|
||||
BottomNavigationView bottomNavigationView = root.findViewById(R.id.bottom_navigation_view);
|
||||
|
||||
bottomNavViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback(){
|
||||
bottomNavViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
bottomNavigationView.getMenu().getItem(position).setChecked(true);
|
||||
@@ -43,13 +44,10 @@ public class HomeFragment extends Fragment {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return new ToolsFragment();
|
||||
case 1:
|
||||
return new FavFragment();
|
||||
if (position == 1) {
|
||||
return new FavFragment();
|
||||
}
|
||||
return null;
|
||||
return new ToolsFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,6 +56,8 @@ public class HomeFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
bottomNavViewPager.setCurrentItem(SharedPreferencesUtils.getLaunchPage() == SharedPreferencesUtils.LaunchPage.tools ? 0 : 1, false);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
package com.fatapp.oxygentoolbox.ui.setting;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.fatapp.oxygentoolbox.MainActivity;
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.util.MultiLanguageUtils;
|
||||
import com.fatapp.oxygentoolbox.ui.about.LibrariesActivity;
|
||||
import com.fatapp.oxygentoolbox.util.ResourceUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SettingFragment extends PreferenceFragmentCompat {
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
|
||||
setPreferencesFromResource(R.xml.fragment_setting, rootKey);
|
||||
ListPreference appLanguage = findPreference("app_language");
|
||||
if (appLanguage != null) {
|
||||
appLanguage.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference appLanguagePreference = findPreference(ResourceUtil.getString(R.string.setting_language_key));
|
||||
if (appLanguagePreference != null) {
|
||||
appLanguagePreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
Intent intent = new Intent(getActivity(), MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
requireActivity().startActivity(intent);
|
||||
@@ -34,5 +28,16 @@ public class SettingFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
public class Config {
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class DependenciesJson {
|
||||
|
||||
@SerializedName("metadata")
|
||||
private MetadataDTO metadata;
|
||||
@SerializedName("libraries")
|
||||
private List<LibrariesDTO> libraries;
|
||||
@SerializedName("licenses")
|
||||
@JsonAdapter(RawStringJsonAdapter.class)
|
||||
private String licenses;
|
||||
|
||||
public MetadataDTO getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public List<LibrariesDTO> getLibraries() {
|
||||
return libraries;
|
||||
}
|
||||
|
||||
public String getLicenses() {
|
||||
return licenses;
|
||||
}
|
||||
|
||||
public static class MetadataDTO {
|
||||
@SerializedName("generated")
|
||||
private String generated;
|
||||
|
||||
public String getGenerated() {
|
||||
return generated;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LibrariesDTO {
|
||||
@SerializedName("uniqueId")
|
||||
private String uniqueId;
|
||||
@SerializedName("funding")
|
||||
private List<?> funding;
|
||||
@SerializedName("developers")
|
||||
private List<DevelopersDTO> developers;
|
||||
@SerializedName("artifactVersion")
|
||||
private String artifactVersion;
|
||||
@SerializedName("description")
|
||||
private String description;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("licenses")
|
||||
private List<String> licenses;
|
||||
@SerializedName("scm")
|
||||
private ScmDTO scm;
|
||||
@SerializedName("website")
|
||||
private String website;
|
||||
|
||||
public String getUniqueId() {
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
public List<?> getFunding() {
|
||||
return funding;
|
||||
}
|
||||
|
||||
public List<DevelopersDTO> getDevelopers() {
|
||||
return developers;
|
||||
}
|
||||
|
||||
public String getDevelopersStr() {
|
||||
StringJoiner stringJoiner = new StringJoiner(", ");
|
||||
for (DevelopersDTO developer : getDevelopers()) {
|
||||
stringJoiner.add(developer.getName());
|
||||
}
|
||||
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
public String getArtifactVersion() {
|
||||
return artifactVersion;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<String> getLicenses() {
|
||||
return licenses;
|
||||
}
|
||||
|
||||
public ScmDTO getScm() {
|
||||
return scm;
|
||||
}
|
||||
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
|
||||
public static class ScmDTO {
|
||||
@SerializedName("connection")
|
||||
private String connection;
|
||||
@SerializedName("url")
|
||||
private String url;
|
||||
|
||||
public String getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DevelopersDTO {
|
||||
@SerializedName("organisationUrl")
|
||||
private String organisationUrl;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
public String getOrganisationUrl() {
|
||||
return organisationUrl;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class RawStringJsonAdapter extends TypeAdapter<String> {
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, String value) throws IOException {
|
||||
out.jsonValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(JsonReader in) {
|
||||
return JsonParser.parseReader(in).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class LicenseJson {
|
||||
@SerializedName("content")
|
||||
private String content;
|
||||
@SerializedName("hash")
|
||||
private String hash;
|
||||
@SerializedName("internalHash")
|
||||
private String internalHash;
|
||||
@SerializedName("url")
|
||||
private String url;
|
||||
@SerializedName("spdxId")
|
||||
private String spdxId;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String getInternalHash() {
|
||||
return internalHash;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getSpdxId() {
|
||||
return spdxId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,25 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.LocaleList;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.core.os.ConfigurationCompat;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MultiLanguageUtils {
|
||||
|
||||
public static Context attachBaseContext(Context context) {
|
||||
String locale;
|
||||
if (SharedPreferencesUtils.isNull()) {
|
||||
locale = "default";
|
||||
} else {
|
||||
locale = SharedPreferencesUtils.getLocale();
|
||||
}
|
||||
String language;
|
||||
String country;
|
||||
if (!locale.equals("default")) {
|
||||
language = locale.substring(0, locale.indexOf("_"));
|
||||
country = locale.substring(locale.indexOf("_") + 1);
|
||||
} else {
|
||||
language = ResourceUtil.getSystemLocale().get(0).getLanguage();
|
||||
country = ResourceUtil.getSystemLocale().get(0).getCountry();
|
||||
}
|
||||
Locale locale = SharedPreferencesUtils.getLanguage();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
return createConfigurationContext(context, language, country);
|
||||
return createConfigurationContext(context, locale.getLanguage(), locale.getCountry());
|
||||
} else {
|
||||
return updateConfiguration(context, language, country);
|
||||
return updateConfiguration(context, locale.getLanguage(), locale.getCountry());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,4 +109,12 @@ public final class ResourceUtil {
|
||||
Configuration configuration = Resources.getSystem().getConfiguration();
|
||||
return ConfigurationCompat.getLocales(configuration);
|
||||
}
|
||||
|
||||
public static int dpToPx(float dp) {
|
||||
return (int) (dp * getDisplayMetrics().density + 0.5f);
|
||||
}
|
||||
|
||||
public static float pxToDp(int px) {
|
||||
return px / getDisplayMetrics().density + 0.5f;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,11 @@ import android.content.SharedPreferences;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SharedPreferencesUtils {
|
||||
private static SharedPreferences preferences;
|
||||
|
||||
@@ -12,11 +17,31 @@ public class SharedPreferencesUtils {
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(app);
|
||||
}
|
||||
|
||||
public static String getLocale() {
|
||||
return preferences.getString("app_language", "default");
|
||||
public static Locale getLanguage() {
|
||||
String languagePreference;
|
||||
String language;
|
||||
String country;
|
||||
if (SharedPreferencesUtils.isNull() ||
|
||||
(languagePreference = preferences.getString(ResourceUtil.getString(R.string.setting_language_key), ResourceUtil.getString(R.string.setting_language_default_value))).equals(ResourceUtil.getString(R.string.setting_language_default_value))) {
|
||||
language = Objects.requireNonNull(ResourceUtil.getSystemLocale().get(0)).getLanguage();
|
||||
country = Objects.requireNonNull(ResourceUtil.getSystemLocale().get(0)).getCountry();
|
||||
} else {
|
||||
language = languagePreference.substring(0, languagePreference.indexOf("_"));
|
||||
country = languagePreference.substring(languagePreference.indexOf("_") + 1);
|
||||
}
|
||||
|
||||
return new Locale(language, country);
|
||||
}
|
||||
|
||||
public static boolean isNull() {
|
||||
return preferences == null;
|
||||
}
|
||||
|
||||
public static LaunchPage getLaunchPage() {
|
||||
return LaunchPage.valueOf(preferences.getString(ResourceUtil.getString(R.string.setting_launch_page_key), ResourceUtil.getString(R.string.setting_launch_page_default_value)));
|
||||
}
|
||||
|
||||
public enum LaunchPage {
|
||||
tools,favourites
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.tools.TimeScreenActivity;
|
||||
|
||||
public class ToolsLauncher {
|
||||
public static void launch(Context context, String activity) {
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import android.os.Build;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fatapp.oxygentoolbox.MainActivity;
|
||||
import com.fatapp.oxygentoolbox.ui.home.HomeFragment;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ToolsList {
|
||||
private static List<Tool> toolList = new ArrayList<>();
|
||||
|
||||
public static void init(InputStream file) throws IOException {
|
||||
int i;
|
||||
String str;
|
||||
StringBuilder jsonStringBuilder = new StringBuilder();
|
||||
|
||||
while ((i = file.read()) != -1) {
|
||||
jsonStringBuilder.append((char) i);
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(file);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
while ((str = bufferedReader.readLine()) != null) {
|
||||
jsonStringBuilder.append(str);
|
||||
}
|
||||
file.close();
|
||||
List<ToolsJson> toolsJsonList = new Gson().fromJson(jsonStringBuilder.toString(), new TypeToken<List<ToolsJson>>() {
|
||||
@@ -44,13 +41,7 @@ public class ToolsList {
|
||||
}
|
||||
|
||||
private static String getLocale(Locales strings) {
|
||||
String language;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
language = ResourceUtil.getResources().getConfiguration().getLocales().get(0).getLanguage();
|
||||
} else {
|
||||
language = ResourceUtil.getResources().getConfiguration().locale.getLanguage();
|
||||
}
|
||||
if (language.equals("zh")) {
|
||||
if (SharedPreferencesUtils.getLanguage().getLanguage().equals("zh")) {
|
||||
return strings.getCn();
|
||||
}
|
||||
return strings.getEn();
|
||||
|
||||
10
app/src/main/res/drawable/ic_launch.xml
Normal file
10
app/src/main/res/drawable/ic_launch.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?attr/app_text_theme"
|
||||
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z" />
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_setting_about.xml
Normal file
10
app/src/main/res/drawable/ic_setting_about.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?attr/app_text_theme"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z" />
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/ic_setting_language.xml
Normal file
12
app/src/main/res/drawable/ic_setting_language.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?attr/app_text_theme"
|
||||
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2L4.26,14zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8L5.08,8c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14L9.66,14c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.59,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z"
|
||||
tools:ignore="VectorPath" />
|
||||
</vector>
|
||||
37
app/src/main/res/layout/activity_libraries.xml
Normal file
37
app/src/main/res/layout/activity_libraries.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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:id="@+id/libraries_page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.about.LibrariesActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:theme="@style/Theme.OxygenToolbox.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/Theme.OxygenToolbox.PopupOverlay" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/libraries_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_bar_layout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
129
app/src/main/res/layout/item_libraries.xml
Normal file
129
app/src/main/res/layout/item_libraries.xml
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView 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="wrap_content"
|
||||
android:layout_marginStart="@dimen/library_item_card_margin_horizontal"
|
||||
android:layout_marginTop="@dimen/library_item_card_margin_vertical"
|
||||
android:layout_marginEnd="@dimen/library_item_card_margin_horizontal"
|
||||
android:layout_marginBottom="@dimen/library_item_card_margin_vertical"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/library_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/library_item_card_inner_padding"
|
||||
android:paddingLeft="@dimen/library_item_card_inner_padding"
|
||||
android:paddingTop="@dimen/library_item_card_inner_padding"
|
||||
android:paddingEnd="@dimen/library_item_card_inner_padding"
|
||||
android:paddingRight="@dimen/library_item_card_inner_padding"
|
||||
android:textAppearance="?textAppearanceHeadline5"
|
||||
app:layout_constraintBottom_toTopOf="@+id/library_creator"
|
||||
app:layout_constraintEnd_toStartOf="@+id/library_version"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Library name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/library_creator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="@dimen/library_item_card_inner_padding"
|
||||
android:paddingLeft="@dimen/library_item_card_inner_padding"
|
||||
android:paddingEnd="@dimen/library_item_card_inner_padding"
|
||||
android:paddingRight="@dimen/library_item_card_inner_padding"
|
||||
android:textAppearance="?textAppearanceSubtitle1"
|
||||
app:layout_constraintBottom_toTopOf="@+id/library_description_divider"
|
||||
app:layout_constraintEnd_toStartOf="@+id/library_version"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/library_name"
|
||||
tools:text="Creator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/library_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingTop="@dimen/library_item_card_inner_padding"
|
||||
android:paddingEnd="@dimen/library_item_card_inner_padding"
|
||||
android:textAppearance="?textAppearanceBody2"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="@id/library_name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/library_name"
|
||||
app:layout_constraintTop_toTopOf="@id/library_name"
|
||||
tools:text="Version" />
|
||||
|
||||
<View
|
||||
android:id="@+id/library_description_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginVertical="@dimen/library_item_card_divider_padding_vertical"
|
||||
android:layout_marginHorizontal="@dimen/library_item_card_divider_padding_horizontal"
|
||||
android:background="?attr/app_background"
|
||||
app:layout_constraintBottom_toTopOf="@id/library_description"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/library_creator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/library_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/library_item_card_inner_padding"
|
||||
android:layout_marginRight="@dimen/library_item_card_inner_padding"
|
||||
android:maxLines="20"
|
||||
android:textAppearance="?textAppearanceBody2"
|
||||
app:layout_constraintBottom_toTopOf="@id/library_bottom_divider"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/library_description_divider"
|
||||
tools:text="This is library description.This is library description.This is library description.This is library description.This is library description.This is library description.This is library description.This is library description." />
|
||||
|
||||
<View
|
||||
android:id="@+id/library_bottom_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginVertical="@dimen/library_item_card_divider_padding_vertical"
|
||||
android:layout_marginHorizontal="@dimen/library_item_card_divider_padding_horizontal"
|
||||
android:background="?attr/app_background"
|
||||
app:layout_constraintBottom_toTopOf="@id/library_license"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/library_description" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/library_license"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/library_item_card_inner_padding"
|
||||
android:paddingLeft="@dimen/library_item_card_inner_padding"
|
||||
android:paddingEnd="@dimen/library_item_card_inner_padding"
|
||||
android:paddingRight="@dimen/library_item_card_inner_padding"
|
||||
android:paddingBottom="@dimen/library_item_card_inner_padding"
|
||||
android:textAppearance="?textAppearanceBody1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/library_bottom_divider"
|
||||
tools:text="License" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
10
app/src/main/res/menu/seach_view.xml
Normal file
10
app/src/main/res/menu/seach_view.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_search"
|
||||
android:icon="@android:drawable/ic_menu_search"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/setting_search"
|
||||
app:showAsAction="always"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView" />
|
||||
</menu>
|
||||
@@ -21,7 +21,11 @@
|
||||
android:id="@+id/nav_setting"
|
||||
android:name="com.fatapp.oxygentoolbox.ui.setting.SettingFragment"
|
||||
android:label="@string/menu_setting"
|
||||
tools:layout="@xml/fragment_setting" />
|
||||
tools:layout="@xml/fragment_setting">
|
||||
<action
|
||||
android:id="@+id/action_setting_to_about"
|
||||
app:destination="@id/nav_about" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_about"
|
||||
|
||||
1
app/src/main/res/raw/dependencies.json
Normal file
1
app/src/main/res/raw/dependencies.json
Normal file
File diff suppressed because one or more lines are too long
@@ -27,11 +27,18 @@
|
||||
|
||||
<string name="setting_base_settings">基本设置</string>
|
||||
<string name="setting_language">语言</string>
|
||||
<string name="setting_launch_page">启动页</string>
|
||||
|
||||
<string-array name="setting_language_array">
|
||||
<item>跟随系统</item>
|
||||
<item>中文</item>
|
||||
<item>English</item>
|
||||
</string-array>
|
||||
<string name="setting_launch_page">启动页</string>
|
||||
<string-array name="setting_launch_page_array">
|
||||
<item>工具</item>
|
||||
<item>收藏</item>
|
||||
</string-array>
|
||||
<string name="setting_open_source">开源许可</string>
|
||||
<string name="setting_search">查找</string>
|
||||
<string name="setting_about">关于</string>
|
||||
<string name="setting_about_oxygen_toolbox">关于 氧工具</string>
|
||||
</resources>
|
||||
@@ -27,11 +27,14 @@
|
||||
|
||||
<string name="setting_base_settings">基本设置</string>
|
||||
<string name="setting_language">语言</string>
|
||||
<string name="setting_launch_page">启动页</string>
|
||||
|
||||
<string-array name="setting_language_array">
|
||||
<item>跟随系统</item>
|
||||
<item>中文</item>
|
||||
<item>English</item>
|
||||
</string-array>
|
||||
<string name="setting_launch_page">启动页</string>
|
||||
<string name="setting_open_source">开源许可</string>
|
||||
<string name="setting_search">查找</string>
|
||||
<string name="setting_about">关于</string>
|
||||
<string name="setting_about_oxygen_toolbox">关于 氧工具</string>
|
||||
</resources>
|
||||
@@ -27,11 +27,14 @@
|
||||
|
||||
<string name="setting_base_settings">基本设置</string>
|
||||
<string name="setting_language">语言</string>
|
||||
<string name="setting_launch_page">启动页</string>
|
||||
|
||||
<string-array name="setting_language_array">
|
||||
<item>跟随系统</item>
|
||||
<item>中文</item>
|
||||
<item>English</item>
|
||||
</string-array>
|
||||
<string name="setting_launch_page">启动页</string>
|
||||
<string name="setting_open_source">开源许可</string>
|
||||
<string name="setting_search">查找</string>
|
||||
<string name="setting_about">关于</string>
|
||||
<string name="setting_about_oxygen_toolbox">关于 氧工具</string>
|
||||
</resources>
|
||||
@@ -6,4 +6,10 @@
|
||||
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
||||
<dimen name="nav_header_height">176dp</dimen>
|
||||
<dimen name="default_text_size">20sp</dimen>
|
||||
|
||||
<dimen name="library_item_card_margin_vertical">16dp</dimen>
|
||||
<dimen name="library_item_card_margin_horizontal">16dp</dimen>
|
||||
<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>
|
||||
</resources>
|
||||
@@ -45,5 +45,21 @@
|
||||
<item>zh_CN</item>
|
||||
<item>en_US</item>
|
||||
</string-array>
|
||||
<string name="setting_language_default_value" translatable="false">default</string>
|
||||
<string name="setting_launch_page">Launch Page</string>
|
||||
<string name="setting_launch_page_key" translatable="false">app_launch_page</string>
|
||||
<string-array name="setting_launch_page_array">
|
||||
<item>Tools</item>
|
||||
<item>Favourites</item>
|
||||
</string-array>
|
||||
<string-array name="setting_launch_page_values">
|
||||
<item>tools</item>
|
||||
<item>favourites</item>
|
||||
</string-array>
|
||||
<string name="setting_launch_page_default_value" translatable="false">tools</string>
|
||||
<string name="setting_open_source">OpenSource</string>
|
||||
<string name="setting_search">Search</string>
|
||||
<string name="setting_about">About</string>
|
||||
<string name="setting_about_oxygen_toolbox">About OxygenToolbox</string>
|
||||
<string name="setting_about_oxygen_toolbox_key" translatable="false">app_about</string>
|
||||
</resources>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="ToolsButton" parent="Widget.AppCompat.Button">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:minWidth">0dp</item>
|
||||
@@ -15,10 +16,12 @@
|
||||
<item name="android:stateListAnimator">@null</item>
|
||||
<item name="android:textColor">@color/default_tools_button_text</item>
|
||||
</style>
|
||||
|
||||
<style name="ToolsLinearLayout">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeSpinner" parent="Widget.AppCompat.Light.DropDownItem.Spinner">
|
||||
<item name="android:textSize">@dimen/default_text_size</item>
|
||||
<item name="android:textColor">?attr/app_text_theme</item>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.OxygenToolbox.Default" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge">
|
||||
<style name="Theme.OxygenToolbox.Default" parent="Theme.MaterialComponents.DayNight.Bridge">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/default_app_theme</item>
|
||||
<item name="colorPrimaryVariant">@color/default_app_theme</item>
|
||||
|
||||
@@ -2,20 +2,27 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory app:title="@string/setting_base_settings">
|
||||
<ListPreference
|
||||
app:defaultValue="default"
|
||||
app:defaultValue="@string/setting_language_default_value"
|
||||
app:entries="@array/setting_language_array"
|
||||
app:entryValues="@array/setting_language_values"
|
||||
app:icon="@drawable/ic_setting_language"
|
||||
app:key="@string/setting_language_key"
|
||||
app:title="@string/setting_language"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
app:defaultValue="@string/setting_launch_page_default_value"
|
||||
app:entries="@array/setting_launch_page_array"
|
||||
app:entryValues="@array/setting_launch_page_values"
|
||||
app:icon="@drawable/ic_launch"
|
||||
app:key="@string/setting_launch_page_key"
|
||||
app:title="@string/setting_launch_page"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
app:key="help_category"
|
||||
app:title="Help">
|
||||
<PreferenceCategory app:title="@string/setting_about">
|
||||
<Preference
|
||||
app:key="feedback"
|
||||
app:summary="Report technical issues or suggest new features"
|
||||
app:title="Send feedback" />
|
||||
app:icon="@drawable/ic_setting_about"
|
||||
app:key="@string/setting_about_oxygen_toolbox_key"
|
||||
app:title="@string/setting_about_oxygen_toolbox" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user