From dc9db738b78408b07e030329fd45a3e0bfd4bb17 Mon Sep 17 00:00:00 2001 From: Rachel030219 <291054446@qq.com> Date: Sun, 23 Oct 2016 07:20:16 +0800 Subject: [PATCH] changed the application ID --- app/build.gradle | 6 +- app/src/main/AndroidManifest.xml | 8 +- .../net/rachel030219/hash/AboutActivity.java | 123 ------ .../rachel030219/hash/ClipboardManager.java | 55 --- .../java/net/rachel030219/hash/FileUtils.java | 158 ------- .../java/net/rachel030219/hash/HashTool.java | 97 ---- .../net/rachel030219/hash/MainActivity.java | 413 ------------------ .../rachel030219/hash/SettingsActivity.java | 58 --- .../rachel030219/hash/SettingsFragment.java | 28 -- app/src/main/res/layout/settings_activity.xml | 2 +- app/src/main/res/values-zh-rCN/strings.xml | 4 +- app/src/main/res/values/strings.xml | 4 +- 12 files changed, 12 insertions(+), 944 deletions(-) delete mode 100644 app/src/main/java/net/rachel030219/hash/AboutActivity.java delete mode 100644 app/src/main/java/net/rachel030219/hash/ClipboardManager.java delete mode 100644 app/src/main/java/net/rachel030219/hash/FileUtils.java delete mode 100644 app/src/main/java/net/rachel030219/hash/HashTool.java delete mode 100644 app/src/main/java/net/rachel030219/hash/MainActivity.java delete mode 100644 app/src/main/java/net/rachel030219/hash/SettingsActivity.java delete mode 100644 app/src/main/java/net/rachel030219/hash/SettingsFragment.java diff --git a/app/build.gradle b/app/build.gradle index 5cf970b..e6663bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,11 +20,11 @@ android { buildToolsVersion "23.0.3" defaultConfig { - applicationId "net.rachel030219.hash" + applicationId "net.rachel030219.hashchecker" minSdkVersion 9 targetSdkVersion 23 - versionCode 11 - versionName "1.1 STABLE" + versionCode 12 + versionName "1.2 STABLE" } buildTypes { release { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8151520..07a13f3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. --> + package="net.rachel030219.hashchecker"> @@ -26,7 +26,7 @@ limitations under the License. android:theme="@style/AppTheme" > @@ -50,11 +50,11 @@ limitations under the License. diff --git a/app/src/main/java/net/rachel030219/hash/AboutActivity.java b/app/src/main/java/net/rachel030219/hash/AboutActivity.java deleted file mode 100644 index 11bc110..0000000 --- a/app/src/main/java/net/rachel030219/hash/AboutActivity.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright 2016 Rachel030219 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package net.rachel030219.hash; - -import android.os.Build; -import android.os.Bundle; -import android.net.Uri; -import android.view.View; -import android.view.MenuItem; -import android.view.WindowManager; -import android.widget.TextView; -import android.content.Intent; -import android.content.Context; -import android.content.DialogInterface; -import android.content.res.Resources; - -import android.support.v7.app.ActionBar; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -public class AboutActivity extends AppCompatActivity{ - TextView mPreferenceFragmentCompat; - TextView mMaterialSettingsActivityDemo; - - TextView mAboutMe; - - @Override - public void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - setContentView(R.layout.about); - - Toolbar mToolbar = (Toolbar)findViewById(R.id.about_toolbar); - mToolbar.setTitle(getTitle()); - setSupportActionBar(mToolbar); - - ActionBar mActionBar = getSupportActionBar(); - mActionBar.setHomeButtonEnabled(true); - mActionBar.setDisplayHomeAsUpEnabled(true); - - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { - WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); - localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); - } - - bindViews(); - } - - private void bindViews(){ - Resources res = getResources(); - mPreferenceFragmentCompat = (TextView)findViewById(R.id.about_projects_preferencefragment); - mPreferenceFragmentCompat.setOnClickListener(new OnProjectClick(this,res.getString(R.string.about_projects_preferencefragment),res.getString(R.string.about_projects_preferencefragment_license),"https://github.com/Machinarius/PreferenceFragment-Compat")); - mMaterialSettingsActivityDemo = (TextView)findViewById(R.id.about_projects_materialsettingsactivitydemo); - mMaterialSettingsActivityDemo.setOnClickListener(new OnProjectClick(this,res.getString(R.string.about_projects_materialsettingsactivitydemo),res.getString(R.string.about_projects_materialsettingsactivitydemo_license),"https://drakeet.me/material-design-settings-activity")); - - mAboutMe = (TextView)findViewById(R.id.about_me); - mAboutMe.setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this); - builder.setTitle(R.string.about_me_title); - builder.setMessage(R.string.about_me_content); - builder.setPositiveButton("GOT IT",null); - builder.show(); - } - }); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item){ - // TODO: Implement this method - switch(item.getItemId()){ - case android.R.id.home: - finish(); - break; - } - return true; - } - - class OnProjectClick implements View.OnClickListener{ - Context context; - String title; - String license; - String url; - - OnProjectClick(Context context,String title,String license,String url){ - this.context = context; - this.title = title; - this.license = license; - this.url = url; - } - - @Override - public void onClick(View v){ - AlertDialog.Builder dialog = new AlertDialog.Builder(context); - dialog.setTitle(title); - dialog.setMessage(license); - dialog.setPositiveButton("GOT IT",null); - dialog.setNegativeButton("MORE...",new DialogInterface.OnClickListener(){ - @Override - public void onClick(DialogInterface dialog,int i){ - Uri uri = Uri.parse(url); - Intent intent = new Intent(Intent.ACTION_VIEW,uri); - startActivity(intent); - } - }); - dialog.show(); - } - } -} diff --git a/app/src/main/java/net/rachel030219/hash/ClipboardManager.java b/app/src/main/java/net/rachel030219/hash/ClipboardManager.java deleted file mode 100644 index 08091b5..0000000 --- a/app/src/main/java/net/rachel030219/hash/ClipboardManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright 2016 Rachel030219 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package net.rachel030219.hash; - -public class ClipboardManager{ - android.text.ClipboardManager oldManager; - android.content.ClipboardManager newManager; - - boolean newAPI = android.os.Build.VERSION.SDK_INT >= 11; - - public ClipboardManager(android.content.Context context){ - if(newAPI){ - newManager = (android.content.ClipboardManager)context.getSystemService(context.CLIPBOARD_SERVICE); - } else { - oldManager = (android.text.ClipboardManager)context.getSystemService(context.CLIPBOARD_SERVICE); - } - } - - public void set(String text){ - if(newAPI){ - newManager.setPrimaryClip(android.content.ClipData.newPlainText(null, text)); - } else { - oldManager.setText(text); - } - } - - public CharSequence get(){ - if(newAPI){ - return newManager.getPrimaryClip().getItemAt(0).getText(); - } else { - return oldManager.getText(); - } - } - - public boolean has(){ - if(newAPI){ - return newManager.hasPrimaryClip(); - } else { - return oldManager.hasText(); - } - } -} diff --git a/app/src/main/java/net/rachel030219/hash/FileUtils.java b/app/src/main/java/net/rachel030219/hash/FileUtils.java deleted file mode 100644 index a9b4d5c..0000000 --- a/app/src/main/java/net/rachel030219/hash/FileUtils.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright 2016 Rachel030219 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -// From Rachel:I got this from a answer under Stack Overflow. Thanks him! - -package net.rachel030219.hash; - -import android.os.Build; -import android.os.Environment; -import android.net.Uri; -import android.content.Context; -import android.content.ContentUris; -import android.database.Cursor; -import android.provider.MediaStore; -import android.provider.DocumentsContract; - -public class FileUtils{ - /** - * Get a file path from a Uri. This will get the the path for Storage Access - * Framework Documents, as well as the _data field for the MediaStore and - * other file-based ContentProviders. - * - * @param context The context. - * @param uri The Uri to query. - * @author paulburke - */ - public static String getPath(final Context context, final Uri uri) { - - final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - - // DocumentProvider - if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { - // ExternalStorageProvider - if (isExternalStorageDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - - if ("primary".equalsIgnoreCase(type)) { - return Environment.getExternalStorageDirectory() + "/" + split[1]; - } - - // TODO handle non-primary volumes - } - // DownloadsProvider - else if (isDownloadsDocument(uri)) { - - final String id = DocumentsContract.getDocumentId(uri); - final Uri contentUri = ContentUris.withAppendedId( - Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); - - return getDataColumn(context, contentUri, null, null); - } - // MediaProvider - else if (isMediaDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - - Uri contentUri = null; - if ("image".equals(type)) { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; - } else if ("video".equals(type)) { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; - } else if ("audio".equals(type)) { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; - } - - final String selection = "_id=?"; - final String[] selectionArgs = new String[] { - split[1] - }; - - return getDataColumn(context, contentUri, selection, selectionArgs); - } - } - // MediaStore (and general) - else if ("content".equalsIgnoreCase(uri.getScheme())) { - return getDataColumn(context, uri, null, null); - } - // File - else if ("file".equalsIgnoreCase(uri.getScheme())) { - return uri.getPath(); - } - - return null; - } - - /** - * Get the value of the data column for this Uri. This is useful for - * MediaStore Uris, and other file-based ContentProviders. - * - * @param context The context. - * @param uri The Uri to query. - * @param selection (Optional) Filter used in the query. - * @param selectionArgs (Optional) Selection arguments used in the query. - * @return The value of the _data column, which is typically a file path. - */ - public static String getDataColumn(Context context, Uri uri, String selection, - String[] selectionArgs) { - - Cursor cursor = null; - final String column = "_data"; - final String[] projection = { - column - }; - - try { - cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, - null); - if (cursor != null && cursor.moveToFirst()) { - final int column_index = cursor.getColumnIndexOrThrow(column); - return cursor.getString(column_index); - } - } finally { - if (cursor != null) - cursor.close(); - } - return null; - } - - - /** - * @param uri The Uri to check. - * @return Whether the Uri authority is ExternalStorageProvider. - */ - public static boolean isExternalStorageDocument(Uri uri) { - return "com.android.externalstorage.documents".equals(uri.getAuthority()); - } - - /** - * @param uri The Uri to check. - * @return Whether the Uri authority is DownloadsProvider. - */ - public static boolean isDownloadsDocument(Uri uri) { - return "com.android.providers.downloads.documents".equals(uri.getAuthority()); - } - - /** - * @param uri The Uri to check. - * @return Whether the Uri authority is MediaProvider. - */ - public static boolean isMediaDocument(Uri uri) { - return "com.android.providers.media.documents".equals(uri.getAuthority()); - } -} diff --git a/app/src/main/java/net/rachel030219/hash/HashTool.java b/app/src/main/java/net/rachel030219/hash/HashTool.java deleted file mode 100644 index 9df7803..0000000 --- a/app/src/main/java/net/rachel030219/hash/HashTool.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright 2016 Rachel030219 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package net.rachel030219.hash; - -import java.io.File; -import java.io.InputStream; -import java.io.FileInputStream; -import java.security.MessageDigest; -import java.security.DigestInputStream; - -public class HashTool{ - - public static String getFileHash(String type, File file){ - - int bufferSize = 256 * 1024; - - FileInputStream fileInputStream = null; - - DigestInputStream digestInputStream = null; - - try { - - MessageDigest messageDigest = MessageDigest.getInstance(type); - - fileInputStream = new FileInputStream(file); - - digestInputStream = new DigestInputStream(fileInputStream,messageDigest); - - byte[] buffer =new byte[bufferSize]; - - while (digestInputStream.read(buffer) > 0); - - messageDigest= digestInputStream.getMessageDigest(); - - byte[] resultByteArray = messageDigest.digest(); - - return byteArrayToHex(resultByteArray); - - } catch (Exception e) { - - return null; - - } finally { - - try { - - digestInputStream.close(); - - } catch (Exception e) { - - } - - try { - - fileInputStream.close(); - - } catch (Exception e) { - - } - } - - } - - public static String byteArrayToHex(byte[] byteArray) { - - char[] hexDigits = {'0','1','2','3','4','5','6','7','8','9', 'A','B','C','D','E','F' }; - - char[] resultCharArray =new char[byteArray.length * 2]; - - int index = 0; - - for (byte b : byteArray) { - - resultCharArray[index++] = hexDigits[b>>> 4 & 0xf]; - - resultCharArray[index++] = hexDigits[b& 0xf]; - - } - - return new String(resultCharArray); - - } - -} diff --git a/app/src/main/java/net/rachel030219/hash/MainActivity.java b/app/src/main/java/net/rachel030219/hash/MainActivity.java deleted file mode 100644 index fa3706f..0000000 --- a/app/src/main/java/net/rachel030219/hash/MainActivity.java +++ /dev/null @@ -1,413 +0,0 @@ -package net.rachel030219.hash; - -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.FileOutputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import android.Manifest; -import android.os.Build; -import android.os.Bundle; -import android.app.ProgressDialog; -import android.net.Uri; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.View; -import android.view.MenuItem; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.TextView; -import android.content.Intent; -import android.content.DialogInterface; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.content.res.Resources; -import android.graphics.Color; -import android.preference.PreferenceManager; - -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.app.AppCompatDelegate; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.widget.Toolbar; -import android.support.v7.widget.CardView; -import android.support.design.widget.Snackbar; -import android.support.design.widget.NavigationView; -import android.support.design.widget.TextInputLayout; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.FloatingActionButton; - -public class MainActivity extends AppCompatActivity { - private static final int FILE_SELECT_CODE = 1; - private static final int REQUEST_FILE_PERMISSION_CODE_INAPP = 2; - private static final int REQUEST_FILE_PERMISSION_CODE_SHARE = 3; - - Toolbar mToolbar; - ActionBar mActionBar; - DrawerLayout mDrawerLayout; - ActionBarDrawerToggle mDrawerToggle; - FloatingActionButton mFab; - CoordinatorLayout mRoot; - - CardView mResult; - TextView mFile; - TextView mMD5; - TextView mSHA1; - TextView mSHA256; - TextView mSHA384; - TextView mSHA512; - - String md5 = null; - String sha1 = null; - String sha256 = null; - String sha384 = null; - String sha512 = null; - - CardView mCheck; - EditText mCheckInput; - - ClipboardManager manager; - - SharedPreferences defaultPreferences; - boolean uppercase; - - @Override - public void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - - setContentView(R.layout.main); - - manager = new ClipboardManager(this); - - bindView(); - checkUpdated(); - - // handle share - Intent open = getIntent(); - if(open != null){ - String action = open.getAction(); - String type = open.getType(); - if(action.equals(Intent.ACTION_SEND) && type != null){ - defaultPreferences = PreferenceManager.getDefaultSharedPreferences(this); - uppercase = defaultPreferences.getBoolean("output_case",true); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ - if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){ - requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_FILE_PERMISSION_CODE_SHARE); - } else { - Uri data = open.getParcelableExtra(Intent.EXTRA_STREAM); - showResult(data); - } - } else { - Uri data = open.getParcelableExtra(Intent.EXTRA_STREAM); - showResult(data); - } - } - } - } - - private void bindView(){ - mToolbar = (Toolbar)findViewById(R.id.toolbar); - mToolbar.setTitle(getTitle()); - setSupportActionBar(mToolbar); - - mActionBar = getSupportActionBar(); - mActionBar.setHomeButtonEnabled(true); - mActionBar.setDisplayHomeAsUpEnabled(true); - - mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer); - mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close) { - @Override - public void onDrawerOpened(View mDrawerView) { - super.onDrawerOpened(mDrawerView); - } - @Override - public void onDrawerClosed(View mDrawerView) { - super.onDrawerClosed(mDrawerView); - } - }; - mDrawerToggle.syncState(); - mDrawerLayout.setDrawerListener(mDrawerToggle); - - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { - WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); - localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); - mDrawerLayout.setFitsSystemWindows(true); - mDrawerLayout.setClipToPadding(false); - } - - NavigationView mNavigation = (NavigationView) findViewById(R.id.navigation); - mNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { - @Override - public boolean onNavigationItemSelected(MenuItem menuItem) { - switch(menuItem.getItemId()){ - case R.id.setting: - Intent settingIntent = new Intent(MainActivity.this,SettingsActivity.class); - startActivity(settingIntent); - break; - case R.id.about: - Intent aboutIntent = new Intent(MainActivity.this,AboutActivity.class); - startActivity(aboutIntent); - break; - } - mDrawerLayout.closeDrawers(); - return true; - } - }); - - mFab = (FloatingActionButton)findViewById(R.id.fab); - mFab.setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ - if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){ - requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_FILE_PERMISSION_CODE_INAPP); - } else { - showFileChooser(); - } - } else { - showFileChooser(); - } - } - }); - - mRoot = (CoordinatorLayout)findViewById(R.id.rootLayout); - - mResult = (CardView)findViewById(R.id.result); - mFile = (TextView)findViewById(R.id.file); - mMD5 = (TextView)findViewById(R.id.md5); - mSHA1 = (TextView)findViewById(R.id.sha1); - mSHA256 = (TextView)findViewById(R.id.sha256); - mSHA384 = (TextView)findViewById(R.id.sha384); - mSHA512 = (TextView)findViewById(R.id.sha512); - - mCheck = (CardView)findViewById(R.id.check); - mCheckInput = (EditText)findViewById(R.id.checkInput); - mCheckInput.addTextChangedListener(new TextWatcher(){ - @Override - public void beforeTextChanged(CharSequence text, int start, int count, int after){ - // TODO: Implement this method - } - - @Override - public void onTextChanged(CharSequence text, int start, int before, int count){ - // TODO: Implement this method - } - - @Override - public void afterTextChanged(Editable text){ - // TODO: Implement this method - String check = null; - Pattern lowerPattern = Pattern.compile("[a-z]"); - Pattern upperPattern = Pattern.compile("[A-Z]"); - if(!text.toString().equals("")) - check = text.toString().substring(0,text.toString().length()); - if(uppercase){ - if(check != null){ - Matcher matcher = lowerPattern.matcher(check); - if(matcher.find()){ - int selection = mCheckInput.getSelectionStart(); - mCheckInput.setText(text.toString().toUpperCase()); - mCheckInput.setSelection(selection); - } - } - } else { - if(check != null){ - Matcher matcher = upperPattern.matcher(check); - if(matcher.find()){ - int selection = mCheckInput.getSelectionStart(); - mCheckInput.setText(text.toString().toLowerCase()); - mCheckInput.setSelection(selection); - } - } - } - - if(!text.toString().equals(md5) && !text.toString().equals(sha1) && !text.toString().equals(sha256) && !text.toString().equals(sha384) && !text.toString().equals(sha512)) { - mCheckInput.setTextColor(Color.parseColor("#FF0000")); - mMD5.setTextColor(Color.parseColor("#797979")); - mSHA1.setTextColor(Color.parseColor("#797979")); - mSHA256.setTextColor(Color.parseColor("#797979")); - mSHA384.setTextColor(Color.parseColor("#797979")); - mSHA512.setTextColor(Color.parseColor("#797979")); - } else { - if(text.toString().equals(md5)) { - mMD5.setTextColor(Color.parseColor("#00CD00")); - mCheckInput.setTextColor(Color.parseColor("#00CD00")); - } else if(text.toString().equals(sha1)) { - mSHA1.setTextColor(Color.parseColor("#00CD00")); - mCheckInput.setTextColor(Color.parseColor("#00CD00")); - } else if(text.toString().equals(sha256)) { - mSHA256.setTextColor(Color.parseColor("#00CD00")); - mCheckInput.setTextColor(Color.parseColor("#00CD00")); - } else if(text.toString().equals(sha384)) { - mSHA384.setTextColor(Color.parseColor("#00CD00")); - mCheckInput.setTextColor(Color.parseColor("#00CD00")); - } else if(text.toString().equals(sha512)) { - mSHA512.setTextColor(Color.parseColor("#00CD00")); - mCheckInput.setTextColor(Color.parseColor("#00CD00")); - } - } - } - }); - } - - private void showFileChooser() { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.setType("*/*"); - intent.addCategory(Intent.CATEGORY_OPENABLE); - - defaultPreferences = PreferenceManager.getDefaultSharedPreferences(this); - uppercase = defaultPreferences.getBoolean("output_case",true); - - try { - startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), FILE_SELECT_CODE); - mCheckInput.setText(""); - } catch (android.content.ActivityNotFoundException ex) { - android.widget.Toast.makeText(this, "Please install a File Manager.", android.widget.Toast.LENGTH_SHORT).show(); - } - } - - public void checkUpdated(){ - final SharedPreferences preferences = getSharedPreferences("updated",MODE_PRIVATE); - if(!preferences.getBoolean("updated11",false)){ - AlertDialog.Builder dialog = new AlertDialog.Builder(this); - dialog.setTitle(R.string.updated_title); - dialog.setMessage(R.string.updated_changelog); - dialog.setPositiveButton("GOT IT",new DialogInterface.OnClickListener(){ - @Override - public void onClick(DialogInterface dialog,int count){ - preferences.edit().putBoolean("updated11",true).apply(); - } - }); - dialog.show(); - } - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data){ - switch(requestCode){ - case FILE_SELECT_CODE: - if(resultCode == RESULT_OK){ - showResult(data.getData()); - } - break; - } - super.onActivityResult(requestCode,resultCode,data); - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults){ - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if(requestCode == REQUEST_FILE_PERMISSION_CODE_INAPP){ - int grantResult = grantResults[0]; - if (grantResult == PackageManager.PERMISSION_GRANTED){ - showFileChooser(); - } - } else if(requestCode == REQUEST_FILE_PERMISSION_CODE_SHARE) { - int grantResult = grantResults[0]; - if (grantResult == PackageManager.PERMISSION_GRANTED){ - showResult((Uri)getIntent().getParcelableExtra(Intent.EXTRA_STREAM)); - } - } - - int grantResult = grantResults[0]; - if (grantResult == PackageManager.PERMISSION_GRANTED){ - switch(requestCode){ - case REQUEST_FILE_PERMISSION_CODE_INAPP: - showFileChooser(); - break; - case REQUEST_FILE_PERMISSION_CODE_SHARE: - showResult((Uri)getIntent().getParcelableExtra(Intent.EXTRA_STREAM)); - break; - } - } else if(grantResult == PackageManager.PERMISSION_DENIED) { - Snackbar.make(mRoot,"Pl",Snackbar.LENGTH_LONG).show(); - } - } - - public void showResult(Uri uri){ - try{ - final File file = new File(FileUtils.getPath(this,uri)); - final Resources res = getResources(); - - final ProgressDialog dialog = ProgressDialog.show(MainActivity.this,null,"Calculating...",true); - new Thread(){ - @Override - public void run(){ - md5 = HashTool.getFileHash("MD5",file); - sha1 = HashTool.getFileHash("SHA1",file); - sha256 = HashTool.getFileHash("SHA256",file); - sha384 = HashTool.getFileHash("SHA384",file); - sha512 = HashTool.getFileHash("SHA512",file); - - if(uppercase){ - md5 = md5.toUpperCase(); - sha1 = sha1.toUpperCase(); - sha256 = sha256.toUpperCase(); - sha384 = sha384.toUpperCase(); - sha512 = sha512.toUpperCase(); - } else { - md5 = md5.toLowerCase(); - sha1 = sha1.toLowerCase(); - sha256 = sha256.toLowerCase(); - sha384 = sha384.toLowerCase(); - sha512 = sha512.toLowerCase(); - } - - runOnUiThread(new Runnable(){ - @Override - public void run(){ - changeResults(); - - mFile.setText(String.format(res.getString(R.string.file),file.getAbsolutePath())); - - mResult.setVisibility(View.VISIBLE); - mCheck.setVisibility(View.VISIBLE); - mCheckInput.requestFocus(); - mCheckInput.setFocusableInTouchMode(true); - - dialog.dismiss(); - } - }); - } - }.start(); - } catch (Exception e) { - - } - } - - public void changeResults(){ - Resources res = getResources(); - mMD5.setText(String.format(res.getString(R.string.md5),md5)); - mSHA1.setText(String.format(res.getString(R.string.sha1),sha1)); - mSHA256.setText(String.format(res.getString(R.string.sha256),sha256)); - mSHA384.setText(String.format(res.getString(R.string.sha384),sha384)); - mSHA512.setText(String.format(res.getString(R.string.sha512),sha512)); - - mMD5.setOnLongClickListener(new OnHashLongClick(md5,"MD5")); - mSHA1.setOnLongClickListener(new OnHashLongClick(sha1,"SHA1")); - mSHA256.setOnLongClickListener(new OnHashLongClick(sha256,"SHA256")); - mSHA384.setOnLongClickListener(new OnHashLongClick(sha384,"SHA384")); - mSHA512.setOnLongClickListener(new OnHashLongClick(sha512,"SHA512")); - } - - class OnHashLongClick implements View.OnLongClickListener{ - String text; - String type; - - OnHashLongClick(String text,String type){ - this.text = text; - this.type = type; - } - - @Override - public boolean onLongClick(View v){ - manager.set(text); - Snackbar.make(mRoot,String.format(getResources().getString(R.string.copied),type),Snackbar.LENGTH_SHORT).show(); - return true; - } - } -} diff --git a/app/src/main/java/net/rachel030219/hash/SettingsActivity.java b/app/src/main/java/net/rachel030219/hash/SettingsActivity.java deleted file mode 100644 index 24661b2..0000000 --- a/app/src/main/java/net/rachel030219/hash/SettingsActivity.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2016 Rachel030219 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package net.rachel030219.hash; - -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.view.MenuItem; -import android.view.WindowManager; - -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -public class SettingsActivity extends AppCompatActivity{ - @Override - public void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - setContentView(R.layout.settings_activity); - - Toolbar mToolbar = (Toolbar)findViewById(R.id.settings_toolbar); - mToolbar.setTitle(getTitle()); - setSupportActionBar(mToolbar); - - ActionBar mActionBar = getSupportActionBar(); - mActionBar.setHomeButtonEnabled(true); - mActionBar.setDisplayHomeAsUpEnabled(true); - - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { - WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); - localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item){ - // TODO: Implement this method - switch(item.getItemId()){ - case android.R.id.home: - finish(); - break; - } - return true; - } -} diff --git a/app/src/main/java/net/rachel030219/hash/SettingsFragment.java b/app/src/main/java/net/rachel030219/hash/SettingsFragment.java deleted file mode 100644 index c7c7792..0000000 --- a/app/src/main/java/net/rachel030219/hash/SettingsFragment.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright 2016 Rachel030219 - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package net.rachel030219.hash; - -import android.os.Bundle; - -import com.github.machinarius.preferencefragment.PreferenceFragment; - -public class SettingsFragment extends PreferenceFragment{ - @Override - public void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.layout.settings); - } -} diff --git a/app/src/main/res/layout/settings_activity.xml b/app/src/main/res/layout/settings_activity.xml index de6048e..a9c926b 100644 --- a/app/src/main/res/layout/settings_activity.xml +++ b/app/src/main/res/layout/settings_activity.xml @@ -38,7 +38,7 @@ limitations under the License. diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 3479e46..7dbe217 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -42,7 +42,7 @@ limitations under the License. 使结果以大写输出 使结果以小写输出 - HashChecker 1.1 STABLE + HashChecker 1.2 STABLE 开源项目 PreferenceFragment-Compat by Machinarius Copyright (C) 2013 The Android Open Source Project\nLicensed under the Apache License, Version 2.0 (the \"License\");\nYou may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. @@ -54,6 +54,6 @@ limitations under the License. 自述 你好,我是Rachel,一名13岁的初三学生,也是一名独立开发者。\n我用空余时间来开发Android应用。所有我个人的应用都将永久免费,希望你会喜欢。欢迎关注我的Twitter(@tangrui003 )来获取最新消息,加入Telegram频道(@rachelnotice )以得到更新提示,你也可以随意在Telegram(@Rachel030219 )上向我提任何问题。\n-Rachel, 2016 更新日志 - HashChecker 1.1 STABLE 更新日志:\n-上传到 Google Play !(击掌!\n-删除了 捐赠 菜单!(击掌…蛤? + HashChecker 1.2 STABLE 更新日志:\n-上传到 Google Play !(击掌!\n-删除了 捐赠 菜单!(击掌…蛤?\n-更改包名 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c0d3e50..11f4a1a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,7 +42,7 @@ limitations under the License. Make result be uppercase Make result be lowercase - HashChecker 1.1 STABLE + HashChecker 1.2 STABLE Open-source projects PreferenceFragment-Compat by Machinarius Copyright (C) 2013 The Android Open Source Project\nLicensed under the Apache License, Version 2.0 (the \"License\");\nYou may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. @@ -54,6 +54,6 @@ limitations under the License. About me Hi, I am Rachel, a thirteen-year-old student(Grade Nine) and independent developer.\nI spent my free time developing on Android. All of my apps are free forever, hope you like them. And, please follow me on Twitter(@tangrui003 ) to get latest news and join the Telegram channel(@rachelnotice ) to get latest update notice, and feel free to ask me any question through Telegram(@Rachel030219 ).\n- Rachel, 2016 What\'s New - HashChecker 1.1 STABLE Changelog:\n- Uploaded to Google Play! (Yeah! + HashChecker 1.2 STABLE Changelog:\n- Uploaded to Google Play! (Yeah!\n- Changed the package name and application ID