mirror of
https://github.com/FatttSnake/OxygenToolbox.git
synced 2026-04-06 01:11:27 +08:00
Auto init basic tools
This commit is contained in:
@@ -40,4 +40,6 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.OxygenToolbox">
|
||||
<activity android:name=".tools.TimeScreenActivity" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
|
||||
BIN
app/src/main/assets/fonts/BasicTools.ttf
Normal file
BIN
app/src/main/assets/fonts/BasicTools.ttf
Normal file
Binary file not shown.
40
app/src/main/assets/json/BasicTools.json
Normal file
40
app/src/main/assets/json/BasicTools.json
Normal file
@@ -0,0 +1,40 @@
|
||||
[
|
||||
{
|
||||
"id": "basic",
|
||||
"content": {
|
||||
"version": "1.0",
|
||||
"versionID": 210510,
|
||||
"mainVersion": 210510,
|
||||
"font": "fonts/BasicTools.ttf",
|
||||
"icon": "\uE6AE",
|
||||
"title": {
|
||||
"cn": "\u57fa\u7840\u5de5\u5177",
|
||||
"tc": "\u57fa\u790e\u5de5\u5177",
|
||||
"en": "Basic Tools"
|
||||
},
|
||||
"desc": {
|
||||
"cn": "\u4e00\u4e9b\u57fa\u7840\u7684\u5de5\u5177\uff0c\u0041\u0050\u0050\u4e3b\u4f53\u81ea\u5e26",
|
||||
"tc": "\u4e00\u4e9b\u57fa\u790e\u7684\u5de5\u5177\uff0c\u0041\u0050\u0050\u4e3b\u9ad4\u81ea\u5e36",
|
||||
"en": "Some basic tools, the main body of the APP comes with it"
|
||||
},
|
||||
"buttons": [
|
||||
{
|
||||
"text": {
|
||||
"cn": "\u65f6\u95f4\u5c4f\u5e55",
|
||||
"tc": "\u6642\u9593\u5c4f\u5e55",
|
||||
"en": "Time Screen"
|
||||
},
|
||||
"activity": 0
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"cn": "\u7ffb\u8bd1",
|
||||
"tc": "\u7ffb\u8b6f",
|
||||
"en": "Translation"
|
||||
},
|
||||
"activity": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -5,13 +5,12 @@ import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fatapp.oxygentoolbox.layout.FoldLayout;
|
||||
import com.fatapp.oxygentoolbox.util.ToolsList;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import androidx.navigation.NavController;
|
||||
@@ -22,10 +21,8 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@@ -62,6 +59,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
|
||||
NavigationUI.setupWithNavController(navigationView, navController);
|
||||
|
||||
try {
|
||||
ToolsList.init(getResources().getAssets().open("json/BasicTools.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(getApplicationContext(), "初始化工具集失败", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
shortCutCreateTest();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class AutoLinefeedLayout extends ViewGroup {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
layoutHorizontal();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class AutoLinefeedLayout extends ViewGroup {
|
||||
for (int i = 0; i < count; i++) {
|
||||
measureChild(getChildAt(i), widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
if (heightMode == MeasureSpec.AT_MOST||heightMode == MeasureSpec.UNSPECIFIED) {
|
||||
if (heightMode == MeasureSpec.AT_MOST || heightMode == MeasureSpec.UNSPECIFIED) {
|
||||
final int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(getDesiredHeight(width), MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.fatapp.oxygentoolbox.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
public class FoldLayout extends LinearLayout implements View.OnClickListener {
|
||||
|
||||
private boolean init;
|
||||
private final int layoutId;
|
||||
@@ -40,8 +40,8 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
|
||||
public FoldLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
@SuppressLint("Recycle") TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.FoldLayout,defStyleAttr,0);
|
||||
layoutId = ta.getResourceId(R.styleable.FoldLayout_layoutId,-1);
|
||||
@SuppressLint("Recycle") TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FoldLayout, defStyleAttr, 0);
|
||||
layoutId = ta.getResourceId(R.styleable.FoldLayout_layoutId, -1);
|
||||
init(context);
|
||||
}
|
||||
|
||||
@@ -55,18 +55,18 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
*/
|
||||
private void addDefaultLayout(Context context) {
|
||||
|
||||
defaultView = LayoutInflater.from(context).inflate(layoutId, this,true);
|
||||
defaultView = LayoutInflater.from(context).inflate(layoutId, this, true);
|
||||
defaultView.setOnClickListener(this);
|
||||
content = new LinearLayout(context);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
content.setOrientation(VERTICAL);
|
||||
addView(content,layoutParams);
|
||||
addView(content, layoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(isShow) {
|
||||
if (isShow) {
|
||||
hideItem();
|
||||
} else {
|
||||
showItem();
|
||||
@@ -85,7 +85,7 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
private void initAnimation() {
|
||||
|
||||
int contentHeight = content.getMeasuredHeight();
|
||||
if(!init) {
|
||||
if (!init) {
|
||||
showAnimator = ValueAnimator.ofInt(0, contentHeight);
|
||||
showAnimator.addUpdateListener(animation -> {
|
||||
LayoutParams layoutParams = (LayoutParams) content.getLayoutParams();
|
||||
@@ -101,7 +101,7 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
}
|
||||
});
|
||||
|
||||
hideAnimator = ValueAnimator.ofInt(contentHeight,0);
|
||||
hideAnimator = ValueAnimator.ofInt(contentHeight, 0);
|
||||
hideAnimator.addUpdateListener(animation -> {
|
||||
LayoutParams layoutParams = (LayoutParams) content.getLayoutParams();
|
||||
layoutParams.height = (int) animation.getAnimatedValue();
|
||||
@@ -119,7 +119,6 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
}
|
||||
});
|
||||
init = true;
|
||||
hide();
|
||||
|
||||
showItem();
|
||||
}
|
||||
@@ -133,22 +132,13 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
final int position = i;
|
||||
content.addView(views.get(i));
|
||||
views.get(i).setOnClickListener(v -> {
|
||||
if(null != mOnItemClickListener) {
|
||||
mOnItemClickListener.onItemClick(v,position);
|
||||
if (null != mOnItemClickListener) {
|
||||
mOnItemClickListener.onItemClick(v, position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto hide
|
||||
*/
|
||||
public void hide() {
|
||||
LinearLayout.LayoutParams layoutParams = (LayoutParams) content.getLayoutParams();
|
||||
layoutParams.height = 0;
|
||||
content.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
public void showItem() {
|
||||
isShow = true;
|
||||
@@ -170,7 +160,7 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener{
|
||||
}
|
||||
|
||||
interface OnItemClickListener {
|
||||
void onItemClick(View view,int position);
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.fatapp.oxygentoolbox.tools;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
|
||||
public class TimeScreenActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_time_screen);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,25 @@
|
||||
package com.fatapp.oxygentoolbox.ui.home;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
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 androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.fatapp.oxygentoolbox.MainActivity;
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.layout.FoldLayout;
|
||||
import com.fatapp.oxygentoolbox.util.BasicToolsLauncher;
|
||||
import com.fatapp.oxygentoolbox.util.ToolsList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -32,8 +30,7 @@ public class HomeFragment extends Fragment {
|
||||
|
||||
private HomeViewModel homeViewModel;
|
||||
|
||||
private FoldLayout foldLayout;
|
||||
private FoldLayout foldLayout1;
|
||||
private LinearLayout foldLayoutsLinearLayout;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
homeViewModel =
|
||||
@@ -44,21 +41,56 @@ public class HomeFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
foldLayout = root.findViewById(R.id.foldLayout);
|
||||
List<View> viewList = new ArrayList<>();
|
||||
View layout_item = getLayoutInflater().inflate(R.layout.layout_item, null);
|
||||
ViewGroup layout_item_AutoLinefeedLayout = layout_item.findViewById(R.id.layout_item_AutoLinefeedLayout);
|
||||
for (int i = 1; i < 1000; i++) {
|
||||
View toolButton = getLayoutInflater().inflate(R.layout.tool_button, null);
|
||||
((Button) toolButton.findViewById(R.id.toolButton)).setText("Bt" + i);
|
||||
layout_item_AutoLinefeedLayout.addView(toolButton);
|
||||
}
|
||||
viewList.add(layout_item);
|
||||
foldLayout.addItemView(viewList);
|
||||
for (ToolsList.Tool tool : ToolsList.getToolList()) {
|
||||
|
||||
foldLayout1 = root.findViewById(R.id.foldLayout1);
|
||||
List<View> viewList1 = new ArrayList<>();
|
||||
viewList1.add(getLayoutInflater().inflate(R.layout.layout_item, null));
|
||||
foldLayout1.addItemView(viewList1);
|
||||
View foldLayoutBody = getLayoutInflater().inflate(R.layout.fold_layout_body, null);
|
||||
ViewGroup layout_item_AutoLinefeedLayout = foldLayoutBody.findViewById(R.id.layout_item_AutoLinefeedLayout);
|
||||
|
||||
for (ToolsList.Button button : tool.getButtonList()) {
|
||||
View toolButton = getLayoutInflater().inflate(R.layout.tool_button, null);
|
||||
((Button) toolButton.findViewById(R.id.toolButton)).setText(button.getText());
|
||||
toolButton.findViewById(R.id.toolButton).setOnClickListener(v -> {
|
||||
BasicToolsLauncher.launch(button.getActivity(), getContext());
|
||||
});
|
||||
layout_item_AutoLinefeedLayout.addView(toolButton);
|
||||
}
|
||||
|
||||
List<View> viewList = new ArrayList<>();
|
||||
viewList.add(foldLayoutBody);
|
||||
|
||||
View foldLayoutHead = getLayoutInflater().inflate(R.layout.fold_layout, null);
|
||||
FoldLayout foldLayout = foldLayoutHead.findViewById(R.id.foldLayout);
|
||||
((TextView) foldLayout.findViewById(R.id.foldLayoutTextView)).setText(tool.getFoldLayoutTitle());
|
||||
((TextView) foldLayout.findViewById(R.id.foldLayoutIcon)).setTypeface(Typeface.createFromAsset(getContext().getAssets(), tool.getFont()));
|
||||
((TextView) foldLayout.findViewById(R.id.foldLayoutIcon)).setText(tool.getIcon());
|
||||
|
||||
foldLayout.addItemView(viewList);
|
||||
|
||||
foldLayoutsLinearLayout = root.findViewById(R.id.foldLayoutsLinearLayout);
|
||||
foldLayoutsLinearLayout.addView(foldLayoutHead);
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < 10; i++) {
|
||||
View toolButton = getLayoutInflater().inflate(R.layout.tool_button, null);
|
||||
((Button) toolButton.findViewById(R.id.toolButton)).setText("Button");
|
||||
toolButton.findViewById(R.id.toolButton).setOnClickListener(v -> {
|
||||
BasicToolsLauncher.launch(0, getContext());
|
||||
});
|
||||
|
||||
View foldLayoutBody = getLayoutInflater().inflate(R.layout.fold_layout_body, null);
|
||||
ViewGroup layout_item_AutoLinefeedLayout = foldLayoutBody.findViewById(R.id.layout_item_AutoLinefeedLayout);
|
||||
layout_item_AutoLinefeedLayout.addView(toolButton);
|
||||
|
||||
List<View> viewList = new ArrayList<>();
|
||||
viewList.add(foldLayoutBody);
|
||||
|
||||
View foldLayoutHead = getLayoutInflater().inflate(R.layout.fold_layout, null);
|
||||
FoldLayout foldLayout = foldLayoutHead.findViewById(R.id.foldLayout);
|
||||
((TextView) foldLayout.findViewById(R.id.foldLayoutTextView)).setText("FoldLayout_" + i);
|
||||
foldLayout.addItemView(viewList);
|
||||
|
||||
foldLayoutsLinearLayout = root.findViewById(R.id.foldLayoutsLinearLayout);
|
||||
foldLayoutsLinearLayout.addView(foldLayoutHead);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import static androidx.core.content.ContextCompat.startActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.fatapp.oxygentoolbox.tools.TimeScreenActivity;
|
||||
|
||||
public class BasicToolsLauncher {
|
||||
public static void launch(int activity, Context context) {
|
||||
switch (activity) {
|
||||
case 0:
|
||||
startActivity(context, new Intent(context, TimeScreenActivity.class), null);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
public class Config {
|
||||
}
|
||||
233
app/src/main/java/com/fatapp/oxygentoolbox/util/ToolsJson.java
Normal file
233
app/src/main/java/com/fatapp/oxygentoolbox/util/ToolsJson.java
Normal file
@@ -0,0 +1,233 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ToolsJson {
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
@SerializedName("content")
|
||||
private Content content;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Content getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(Content content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static class Content {
|
||||
@SerializedName("version")
|
||||
private String version;
|
||||
@SerializedName("versionID")
|
||||
private Integer versionID;
|
||||
@SerializedName("mainVersion")
|
||||
private Integer mainVersion;
|
||||
@SerializedName("font")
|
||||
private String font;
|
||||
@SerializedName("icon")
|
||||
private String icon;
|
||||
@SerializedName("title")
|
||||
private Title title;
|
||||
@SerializedName("desc")
|
||||
private Desc desc;
|
||||
@SerializedName("buttons")
|
||||
private List<Buttons> buttons;
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Integer getVersionID() {
|
||||
return versionID;
|
||||
}
|
||||
|
||||
public void setVersionID(Integer versionID) {
|
||||
this.versionID = versionID;
|
||||
}
|
||||
|
||||
public Integer getMainVersion() {
|
||||
return mainVersion;
|
||||
}
|
||||
|
||||
public void setMainVersion(Integer mainVersion) {
|
||||
this.mainVersion = mainVersion;
|
||||
}
|
||||
|
||||
public Title getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(Title title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
public void setFont(String font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public Desc getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(Desc desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public List<Buttons> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void setButtons(List<Buttons> buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public static class Title {
|
||||
@SerializedName("cn")
|
||||
private String cn;
|
||||
@SerializedName("tc")
|
||||
private String tc;
|
||||
@SerializedName("en")
|
||||
private String en;
|
||||
|
||||
public String getCn() {
|
||||
return cn;
|
||||
}
|
||||
|
||||
public void setCn(String cn) {
|
||||
this.cn = cn;
|
||||
}
|
||||
|
||||
public String getTc() {
|
||||
return tc;
|
||||
}
|
||||
|
||||
public void setTc(String tc) {
|
||||
this.tc = tc;
|
||||
}
|
||||
|
||||
public String getEn() {
|
||||
return en;
|
||||
}
|
||||
|
||||
public void setEn(String en) {
|
||||
this.en = en;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Desc {
|
||||
@SerializedName("cn")
|
||||
private String cn;
|
||||
@SerializedName("tc")
|
||||
private String tc;
|
||||
@SerializedName("en")
|
||||
private String en;
|
||||
|
||||
public String getCn() {
|
||||
return cn;
|
||||
}
|
||||
|
||||
public void setCn(String cn) {
|
||||
this.cn = cn;
|
||||
}
|
||||
|
||||
public String getTc() {
|
||||
return tc;
|
||||
}
|
||||
|
||||
public void setTc(String tc) {
|
||||
this.tc = tc;
|
||||
}
|
||||
|
||||
public String getEn() {
|
||||
return en;
|
||||
}
|
||||
|
||||
public void setEn(String en) {
|
||||
this.en = en;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Buttons {
|
||||
@SerializedName("text")
|
||||
private Text text;
|
||||
@SerializedName("activity")
|
||||
private Integer activity;
|
||||
|
||||
public Text getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(Text text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
public void setActivity(Integer activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public static class Text {
|
||||
@SerializedName("cn")
|
||||
private String cn;
|
||||
@SerializedName("tc")
|
||||
private String tc;
|
||||
@SerializedName("en")
|
||||
private String en;
|
||||
|
||||
public String getCn() {
|
||||
return cn;
|
||||
}
|
||||
|
||||
public void setCn(String cn) {
|
||||
this.cn = cn;
|
||||
}
|
||||
|
||||
public String getTc() {
|
||||
return tc;
|
||||
}
|
||||
|
||||
public void setTc(String tc) {
|
||||
this.tc = tc;
|
||||
}
|
||||
|
||||
public String getEn() {
|
||||
return en;
|
||||
}
|
||||
|
||||
public void setEn(String en) {
|
||||
this.en = en;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
106
app/src/main/java/com/fatapp/oxygentoolbox/util/ToolsList.java
Normal file
106
app/src/main/java/com/fatapp/oxygentoolbox/util/ToolsList.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ToolsList {
|
||||
private static List<Tool> toolList = new ArrayList<>();
|
||||
|
||||
public static void init(InputStream file) throws IOException {
|
||||
int i;
|
||||
StringBuilder jsonStringBuilder = new StringBuilder();
|
||||
|
||||
while ((i = file.read()) != -1) {
|
||||
jsonStringBuilder.append((char) i);
|
||||
}
|
||||
file.close();
|
||||
List<ToolsJson> toolsJsonList = new Gson().fromJson(jsonStringBuilder.toString(), new TypeToken<List<ToolsJson>>(){}.getType());
|
||||
|
||||
for (ToolsJson toolsJson : toolsJsonList) {
|
||||
Tool tool = new Tool();
|
||||
tool.setFont(toolsJson.getContent().getFont());
|
||||
tool.setIcon(toolsJson.getContent().getIcon());
|
||||
tool.setFoldLayoutTitle(toolsJson.getContent().getTitle().getCn());
|
||||
for (ToolsJson.Content.Buttons cButton : toolsJson.getContent().getButtons()) {
|
||||
Button button = new Button();
|
||||
button.setText(cButton.getText().getCn());
|
||||
button.setActivity(cButton.getActivity());
|
||||
tool.buttonList.add(button);
|
||||
}
|
||||
toolList.add(tool);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Tool> getToolList() {
|
||||
return toolList;
|
||||
}
|
||||
|
||||
public void setToolList(List<Tool> toolList) {
|
||||
ToolsList.toolList = toolList;
|
||||
}
|
||||
|
||||
public static class Tool {
|
||||
private String font;
|
||||
private String icon;
|
||||
private String foldLayoutTitle;
|
||||
private List<Button> buttonList = new ArrayList<>();
|
||||
|
||||
public String getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
public void setFont(String font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getFoldLayoutTitle() {
|
||||
return foldLayoutTitle;
|
||||
}
|
||||
|
||||
public void setFoldLayoutTitle(String foldLayoutTitle) {
|
||||
this.foldLayoutTitle = foldLayoutTitle;
|
||||
}
|
||||
|
||||
public List<Button> getButtonList() {
|
||||
return buttonList;
|
||||
}
|
||||
|
||||
public void setButtonList(List<Button> buttonList) {
|
||||
this.buttonList = buttonList;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Button {
|
||||
private String text;
|
||||
private Integer activity;
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
public void setActivity(Integer activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="1024dp"
|
||||
android:height="1024dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/app_theme"
|
||||
android:pathData="M810.666667 942.933333c-34.133333 0-68.266667-12.8-93.866667-38.4l-234.666667-234.666666c-140.8 51.2-302.933333-12.8-371.2-153.6-38.4-81.066667-38.4-174.933333 0-256 4.266667-12.8 17.066667-21.333333 29.866667-25.6s25.6 0 38.4 12.8L315.733333 384H384V315.733333L247.466667 179.2c-8.533333-8.533333-12.8-21.333333-12.8-38.4 4.266667-12.8 12.8-25.6 25.6-29.866667 72.533333-34.133333 153.6-38.4 230.4-12.8s136.533333 81.066667 170.666666 153.6c34.133333 72.533333 38.4 153.6 12.8 230.4l234.666667 234.666667c51.2 51.2 51.2 136.533333 0 187.733333-29.866667 25.6-64 38.4-98.133333 38.4z m-320-366.933333c12.8 0 21.333333 4.266667 29.866666 12.8l256 256c17.066667 17.066667 51.2 17.066667 68.266667 0 8.533333-8.533333 12.8-21.333333 12.8-34.133333s-4.266667-25.6-12.8-34.133334l-256-256c-12.8-12.8-17.066667-34.133333-8.533333-46.933333 29.866667-59.733333 29.866667-123.733333 0-183.466667-25.6-51.2-68.266667-93.866667-119.466667-110.933333-34.133333-12.8-68.266667-17.066667-102.4-8.533333l98.133333 98.133333c8.533333 8.533333 12.8 17.066667 12.8 29.866667v128c0 25.6-17.066667 42.666667-42.666666 42.666666H298.666667c-12.8 0-21.333333-4.266667-29.866667-12.8L170.666667 358.4c-4.266667 42.666667 0 85.333333 17.066666 123.733333 51.2 106.666667 179.2 149.333333 285.866667 102.4 4.266667-8.533333 12.8-8.533333 17.066667-8.533333z" />
|
||||
</vector>
|
||||
9
app/src/main/res/layout/activity_time_screen.xml
Normal file
9
app/src/main/res/layout/activity_time_screen.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".tools.TimeScreenActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,36 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/foldLayoutLinearLayout"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/top_bottom_radius_background"
|
||||
android:gravity="center_vertical" >
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<com.fatapp.oxygentoolbox.layout.FoldLayout
|
||||
android:id="@+id/foldLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutId="@layout/fold_layout_head"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/tools_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="6"
|
||||
android:gravity="center_vertical"
|
||||
android:text="工具"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/arrowIcon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/right_to_down_arrow" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/layout_item_LinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
37
app/src/main/res/layout/fold_layout_head.xml
Normal file
37
app/src/main/res/layout/fold_layout_head.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/foldLayoutLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/top_bottom_radius_background"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/foldLayoutIcon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/app_theme" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/foldLayoutTextView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="6"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/arrowIcon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/right_to_down_arrow" />
|
||||
</LinearLayout>
|
||||
@@ -10,26 +10,11 @@
|
||||
tools:context=".ui.home.HomeFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/foldLayoutsLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.fatapp.oxygentoolbox.layout.FoldLayout
|
||||
android:id="@+id/foldLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutId="@layout/fold_layout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.fatapp.oxygentoolbox.layout.FoldLayout
|
||||
android:id="@+id/foldLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutId="@layout/fold_layout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
Reference in New Issue
Block a user