diff --git a/app/build.gradle b/app/build.gradle index c3c7207..88f6572 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,8 +21,6 @@ android { multiDexEnabled true Properties buildPro = loadBuildPro() - buildConfigField "String", "ROLL_APP_ID", buildPro['rollAppId'] - buildConfigField "String", "ROLL_APP_SECRET", buildPro['rollAppSecret'] } signingConfigs { @@ -107,8 +105,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.preference:preference:1.2.0' - implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0' - implementation 'androidx.navigation:navigation-ui-ktx:2.6.0' + implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' + implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' implementation 'androidx.core:core-splashscreen:1.0.1' implementation 'com.google.android.material:material:1.9.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 71ce965..1593da1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -61,17 +61,7 @@ - - - - - - - diff --git a/app/src/main/assets/json/BasicTools.json b/app/src/main/assets/json/BasicTools.json index f356330..6ffeb2e 100644 --- a/app/src/main/assets/json/BasicTools.json +++ b/app/src/main/assets/json/BasicTools.json @@ -30,19 +30,12 @@ }, "activity": "com.fatapp.oxygentoolbox.tools.translation.MainActivity" }, - { - "text": { - "cn": "\u0049\u0050\u0020\u67e5\u8be2", - "en": "IP Query" - }, - "activity": "com.fatapp.oxygentoolbox.tools.ip.MainActivity" - }, { "text": { "cn": "\u8fdb\u5236\u8f6c\u6362", "en": "Base Converter" }, - "activity": "com.fatapp.oxygentoolbox.tools.converter.MainActivity" + "activity": "com.fatapp.oxygentoolbox.tools.baseconverter.MainActivity" } ] } diff --git a/app/src/main/java/com/fatapp/oxygentoolbox/tools/converter/MainActivity.java b/app/src/main/java/com/fatapp/oxygentoolbox/tools/baseconverter/MainActivity.java similarity index 99% rename from app/src/main/java/com/fatapp/oxygentoolbox/tools/converter/MainActivity.java rename to app/src/main/java/com/fatapp/oxygentoolbox/tools/baseconverter/MainActivity.java index d525629..68bd8e8 100644 --- a/app/src/main/java/com/fatapp/oxygentoolbox/tools/converter/MainActivity.java +++ b/app/src/main/java/com/fatapp/oxygentoolbox/tools/baseconverter/MainActivity.java @@ -1,4 +1,4 @@ -package com.fatapp.oxygentoolbox.tools.converter; +package com.fatapp.oxygentoolbox.tools.baseconverter; import android.graphics.drawable.AnimatedVectorDrawable; import android.os.Bundle; diff --git a/app/src/main/java/com/fatapp/oxygentoolbox/tools/ip/MainActivity.java b/app/src/main/java/com/fatapp/oxygentoolbox/tools/ip/MainActivity.java deleted file mode 100644 index 91f87cb..0000000 --- a/app/src/main/java/com/fatapp/oxygentoolbox/tools/ip/MainActivity.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.fatapp.oxygentoolbox.tools.ip; - -import android.app.AlertDialog; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import com.fatapp.oxygentoolbox.BuildConfig; -import com.fatapp.oxygentoolbox.R; -import com.fatapp.oxygentoolbox.util.ResourceUtil; -import com.fatapp.oxygentoolbox.util.http.HttpHelper; -import com.fatapp.oxygentoolbox.util.http.ResponseListener; -import com.fatapp.oxygentoolbox.util.tool.BaseActivityNormal; -import com.google.android.material.snackbar.Snackbar; - -import org.json.JSONException; -import org.json.JSONObject; - -public class MainActivity extends BaseActivityNormal { - final String URL_SELF = "https://www.mxnzp.com/api/ip/self?app_id=%s&app_secret=%s"; - final String URL_QUERY = "https://www.mxnzp.com/api/ip/aim_ip?ip=%s&app_id=%s&app_secret=%s"; - - private TextView textViewCurrentIP; - private EditText editTextIpAddress; - private ImageView imageViewQuery; - private TextView textViewResultIP; - private TextView textViewResultProvince; - private TextView textViewResultCity; - private TextView textViewResultIsp; - - private void initView() { - textViewCurrentIP = findViewById(R.id.text_view_current_ip); - editTextIpAddress = findViewById(R.id.edit_text_ipaddress); - imageViewQuery = findViewById(R.id.image_view_query); - textViewResultIP = findViewById(R.id.text_view_result_ip); - textViewResultProvince = findViewById(R.id.text_view_result_province); - textViewResultCity = findViewById(R.id.text_view_result_city); - textViewResultIsp = findViewById(R.id.text_view_result_isp); - } - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - super.loadView(this, R.layout.activity_tool_ip); - - initView(); - getCurrentIP(); - initQuery(); - } - - private void getCurrentIP() { - final HttpHelper httpHelper = new HttpHelper(this, URL_SELF, new ResponseListener() { - @Override - public void onResponse(int code, String responseBody) { - if (code == 200) { - try { - if (new JSONObject(responseBody).getInt("code") == 1) { - final JSONObject data = new JSONObject(responseBody).getJSONObject("data"); - String ip = data.getString("ip"); - String desc = data.getString("desc"); - textViewCurrentIP.setText(String.format("%s %s", ip, desc)); - } else { - onFailure(); - } - } catch (JSONException e) { - onFailure(); - } - } else { - onFailure(); - } - } - - @Override - public void onFailure() { - textViewCurrentIP.setText(ResourceUtil.getString(R.string.tool_ip_Unknown)); - } - }); - - httpHelper.request(BuildConfig.ROLL_APP_ID, BuildConfig.ROLL_APP_SECRET); - } - - private void initQuery() { - editTextIpAddress.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { - - } - - @Override - public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - imageViewQuery.setEnabled(charSequence.length() != 0); - } - - @Override - public void afterTextChanged(Editable editable) { - - } - }); - editTextIpAddress.setOnEditorActionListener((textView, actionId, keyEvent) -> { - if (actionId == EditorInfo.IME_ACTION_SEARCH) { - query(); - return true; - } - return false; - }); - - imageViewQuery.setEnabled(false); - imageViewQuery.setOnClickListener(view -> query()); - } - - private void query() { - ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(editTextIpAddress.getWindowToken(), 0); - AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); - alertDialogBuilder.setTitle(ResourceUtil.getString(R.string.tool_ip_querying)); - alertDialogBuilder.setMessage(ResourceUtil.getString(R.string.tool_ip_wait)); - alertDialogBuilder.setCancelable(false); - AlertDialog alertDialog = alertDialogBuilder.show(); - final HttpHelper httpHelper = new HttpHelper(this, URL_QUERY, new ResponseListener() { - @Override - public void onResponse(int code, String responseBody) { - alertDialog.cancel(); - if (code == 200) { - try { - if (new JSONObject(responseBody).getInt("code") == 1) { - final JSONObject data = new JSONObject(responseBody).getJSONObject("data"); - String ip = data.getString("ip"); - String province = data.getString("province"); - String city = data.getString("city"); - String isp = data.getString("isp"); - textViewResultIP.setText(ip.isEmpty() ? ResourceUtil.getString(R.string.tool_ip_Unknown) : ip); - textViewResultProvince.setText(province.isEmpty() ? ResourceUtil.getString(R.string.tool_ip_Unknown) : province); - textViewResultCity.setText(city.isEmpty() ? ResourceUtil.getString(R.string.tool_ip_Unknown) : city); - textViewResultIsp.setText(isp.isEmpty() ? ResourceUtil.getString(R.string.tool_ip_Unknown) : isp); - } else { - setUnknown(); - Snackbar.make(getConstraintLayoutRoot(), new JSONObject(responseBody).getString("msg"), Snackbar.LENGTH_LONG).show(); - } - } catch (JSONException e) { - onFailure(); - } - } else { - onFailure(); - } - } - - @Override - public void onFailure() { - alertDialog.cancel(); - setUnknown(); - Snackbar.make(getConstraintLayoutRoot(), ResourceUtil.getString(R.string.tool_ip_query_failed), Snackbar.LENGTH_LONG).show(); - } - }); - httpHelper.request(editTextIpAddress.getText().toString(), BuildConfig.ROLL_APP_ID, BuildConfig.ROLL_APP_SECRET); - } - - private void setUnknown() { - textViewResultIP.setText(ResourceUtil.getString(R.string.tool_ip_Unknown)); - textViewResultProvince.setText(ResourceUtil.getString(R.string.tool_ip_Unknown)); - textViewResultCity.setText(ResourceUtil.getString(R.string.tool_ip_Unknown)); - textViewResultIsp.setText(ResourceUtil.getString(R.string.tool_ip_Unknown)); - } -} diff --git a/app/src/main/res/layout/activity_tool_converter.xml b/app/src/main/res/layout/activity_tool_converter.xml index 9163b07..546f28e 100644 --- a/app/src/main/res/layout/activity_tool_converter.xml +++ b/app/src/main/res/layout/activity_tool_converter.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".tools.converter.MainActivity"> + tools:context=".tools.baseconverter.MainActivity"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index c0e817c..e636db8 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -78,16 +78,6 @@ 请输入内容…… 翻译失败,请检查网络连接。 - 当前 IP: - 未知 - IP 地址 - 查询中 - 请耐心等待…… - 城市 - 省份 - 网络提供商 - 查询失败,请检查网络连接。 - 选择进制 源进制 目标进制 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c0e817c..e636db8 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -78,16 +78,6 @@ 请输入内容…… 翻译失败,请检查网络连接。 - 当前 IP: - 未知 - IP 地址 - 查询中 - 请耐心等待…… - 城市 - 省份 - 网络提供商 - 查询失败,请检查网络连接。 - 选择进制 源进制 目标进制 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c0e817c..e636db8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -78,16 +78,6 @@ 请输入内容…… 翻译失败,请检查网络连接。 - 当前 IP: - 未知 - IP 地址 - 查询中 - 请耐心等待…… - 城市 - 省份 - 网络提供商 - 查询失败,请检查网络连接。 - 选择进制 源进制 目标进制 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c7a9afa..bcc3635 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -45,10 +45,6 @@ @dimen/common_layout_margin 200dp - 10dp - @dimen/common_layout_margin - 48dp - 16sp 5dp @dimen/common_layout_margin diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eba6c4a..5e1aa3c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -115,16 +115,6 @@ 한국인 Please enter text… Translation failed, please check network connection. - - Current IP:  - Unknown - IP address - Querying - Please wait patiently… - City - Province - ISP - Query failed, please check network connection. 2 (binary) 8 (octal)