Skip to content

Commit

Permalink
1.3 STABLE rolled out!
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel030219 committed Nov 6, 2016
1 parent 6f8e2b6 commit 2d4e494
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 53 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
applicationId "net.rachel030219.hashchecker"
minSdkVersion 9
targetSdkVersion 25
versionCode 12
versionName "1.2 STABLE"
versionCode 13
versionName "1.3 STABLE"
}
buildTypes {
release {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ limitations under the License.

<activity
android:name="net.rachel030219.hashchecker.MainActivity"
android:theme="@style/AppTheme.Transparent"
android:windowSoftInputMode="stateHidden|adjustPan">
android:theme="@style/AppTheme.Transparent">

<intent-filter>

Expand Down
25 changes: 24 additions & 1 deletion app/src/main/java/net/rachel030219/hashchecker/HashTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.DigestInputStream;

import java.util.zip.CRC32;

public class HashTool{

public static String getFileHash(String type, File file){
Expand Down Expand Up @@ -92,5 +97,23 @@ public static String byteArrayToHex(byte[] byteArray) {
return new String(resultCharArray);

}


public static long getCRC32(File file){
try {
InputStream fi = new BufferedInputStream(new FileInputStream(file));

int gByte = 0;
CRC32 gCRC = new CRC32();
while ((gByte = fi.read()) != -1) {
gCRC.update(gByte);
}
fi.close();

return gCRC.getValue();
} catch (IOException e) {
e.printStackTrace();
return 0;
}
}

}
88 changes: 70 additions & 18 deletions app/src/main/java/net/rachel030219/hashchecker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
import android.support.design.widget.NavigationView;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.widget.Toast;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {
private static final int FILE_SELECT_CODE = 1;
Expand All @@ -60,6 +63,7 @@ public class MainActivity extends AppCompatActivity {
String sha256 = null;
String sha384 = null;
String sha512 = null;
String crc32 = null;

HashMap<Integer,String> mMap;

Expand All @@ -68,6 +72,7 @@ public class MainActivity extends AppCompatActivity {
boolean eSHA256 = true;
boolean eSHA384 = true;
boolean eSHA512 = true;
boolean eCRC32 = true;
boolean eCover = true;

ClipboardManager manager;
Expand Down Expand Up @@ -125,6 +130,7 @@ private void getPreferences(){
eSHA256 = defaultPreferences.getBoolean("output_sha256",true);
eSHA384 = defaultPreferences.getBoolean("output_sha384",true);
eSHA512 = defaultPreferences.getBoolean("output_sha512",true);
eCRC32 = defaultPreferences.getBoolean("output_crc32",true);
eCover = defaultPreferences.getBoolean("output_cover",true);
uppercase = defaultPreferences.getBoolean("output_case",true);
}
Expand Down Expand Up @@ -203,14 +209,15 @@ private void showFileChooser() {

public void checkUpdated(){
final SharedPreferences preferences = getSharedPreferences("updated",MODE_PRIVATE);
if(!preferences.getBoolean("updated12",false)){
if(!preferences.getBoolean("updated13",false)){
preferences.edit().clear().apply();
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("updated12",true).apply();
preferences.edit().putBoolean("updated13",true).apply();
}
});
dialog.show();
Expand Down Expand Up @@ -305,6 +312,8 @@ public void run(){
sha384 = HashTool.getFileHash("SHA384",file);
if (eSHA512)
sha512 = HashTool.getFileHash("SHA512",file);
if (eCRC32)
crc32 = HashTool.getCRC32(file) + "";

if(uppercase){
mMap = new HashMap<>();
Expand All @@ -318,6 +327,7 @@ public void run(){
mMap.put(5,sha384.toUpperCase());
if (eSHA512)
mMap.put(6,sha512.toUpperCase());
mMap.put(7,crc32.toUpperCase());

if(!multiShare && eCover)
mDatas = new ArrayList<>();
Expand All @@ -334,6 +344,7 @@ public void run(){
mMap.put(5,sha384.toLowerCase());
if (eSHA512)
mMap.put(6,sha512.toLowerCase());
mMap.put(7,crc32.toLowerCase());

if(!multiShare && eCover)
mDatas = new ArrayList<>();
Expand Down Expand Up @@ -383,6 +394,7 @@ public void onBindViewHolder(Holder holder, int position) {
String sha256 = mDatas.get(position).get(4);
String sha384 = mDatas.get(position).get(5);
String sha512 = mDatas.get(position).get(6);
String crc32 = mDatas.get(position).get(7);

holder.mFile.setText(String.format(res.getString(R.string.file),path));

Expand All @@ -391,31 +403,34 @@ public void onBindViewHolder(Holder holder, int position) {
holder.mSHA256.setText(String.format(res.getString(R.string.sha256),sha256));
holder.mSHA384.setText(String.format(res.getString(R.string.sha384),sha384));
holder.mSHA512.setText(String.format(res.getString(R.string.sha512),sha512));
holder.mCRC32.setText(String.format(res.getString(R.string.crc32),crc32));
holder.mCheckInput.setText("");

holder.mMD5.setOnLongClickListener(new OnHashLongClick(md5,"MD5"));
holder.mSHA1.setOnLongClickListener(new OnHashLongClick(sha1,"SHA1"));
holder.mSHA256.setOnLongClickListener(new OnHashLongClick(sha256,"SHA256"));
holder.mSHA384.setOnLongClickListener(new OnHashLongClick(sha384,"SHA384"));
holder.mSHA512.setOnLongClickListener(new OnHashLongClick(sha512,"SHA512"));
holder.mCRC32.setOnLongClickListener(new OnHashLongClick(crc32,"CRC32"));

holder.mCheckInput.addTextChangedListener(new Watcher(holder,md5,sha1,sha256,sha384,sha512));
holder.mCheckInput.addTextChangedListener(new Watcher(holder,md5,sha1,sha256,sha384,sha512,crc32));

if (eSHA256) {
if (eSHA256)
holder.mSHA256.setVisibility(View.VISIBLE);
} else {
else
holder.mSHA256.setVisibility(View.GONE);
}
if (eSHA384) {
if (eSHA384)
holder.mSHA384.setVisibility(View.VISIBLE);
} else {
else
holder.mSHA384.setVisibility(View.GONE);
}
if (eSHA512) {
if (eSHA512)
holder.mSHA512.setVisibility(View.VISIBLE);
} else {
else
holder.mSHA512.setVisibility(View.GONE);
}
if (eCRC32)
holder.mCRC32.setVisibility(View.VISIBLE);
else
holder.mCRC32.setVisibility(View.GONE);
}

@Override
Expand All @@ -437,6 +452,7 @@ class Holder extends RecyclerView.ViewHolder{
TextView mSHA256;
TextView mSHA384;
TextView mSHA512;
TextView mCRC32;
EditText mCheckInput;

Holder(View view){
Expand All @@ -446,12 +462,12 @@ class Holder extends RecyclerView.ViewHolder{
mFile = (TextView)view.findViewById(R.id.file);

mMD5 = (TextView)view.findViewById(R.id.md5);

mSHA1 = (TextView)view.findViewById(R.id.sha1);

mSHA256 = (TextView)view.findViewById(R.id.sha256);
mSHA384 = (TextView)view.findViewById(R.id.sha384);
mSHA512 = (TextView)view.findViewById(R.id.sha512);
mCRC32 = (TextView)view.findViewById(R.id.crc32);

// EditText
mCheckInput = (EditText)view.findViewById(R.id.checkInput);
Expand All @@ -472,14 +488,16 @@ class Watcher implements TextWatcher{
String sha256;
String sha384;
String sha512;
String crc32;

Watcher(Holder holder,String md5,String sha1,String sha256,String sha384,String sha512){
Watcher(Holder holder,String md5,String sha1,String sha256,String sha384,String sha512,String crc32){
this.holder = holder;
this.md5 = md5;
this.sha1 = sha1;
this.sha256 = sha256;
this.sha384 = sha384;
this.sha512 = sha512;
this.crc32 = crc32;
}
@Override
public void beforeTextChanged(CharSequence text, int start, int count, int after){
Expand All @@ -492,7 +510,7 @@ public void onTextChanged(CharSequence text, int start, int before, int count){
if (!text.equals(""))
check = text.subSequence(0,text.toString().length()).toString();
if(check != null){
if(!check.toString().equals(md5) && !check.toString().equals(sha1) && !check.toString().equals(sha256) && !check.toString().equals(sha384) && !check.toString().equals(sha512)) {
if(!check.toString().equals(md5) && !check.toString().equals(sha1) && !check.toString().equals(sha256) && !check.toString().equals(sha384) && !check.toString().equals(sha512) && !check.toString().equals(crc32)) {
holder.mCheckInput.setTextColor(Color.parseColor("#FF0000"));
holder.mMD5.setTextColor(Color.parseColor("#797979"));
holder.mSHA1.setTextColor(Color.parseColor("#797979"));
Expand All @@ -505,21 +523,57 @@ public void onTextChanged(CharSequence text, int start, int before, int count){
if (eSHA512) {
holder.mSHA512.setTextColor(Color.parseColor("#797979"));
}
if (eCRC32) {
holder.mCRC32.setTextColor(Color.parseColor("#797979"));
}
} else {
if(check.toString().equals(md5)) {
holder.mMD5.setTextColor(Color.parseColor("#00CD00"));
holder.mSHA1.setTextColor(Color.parseColor("#797979"));
holder.mSHA256.setTextColor(Color.parseColor("#797979"));
holder.mSHA384.setTextColor(Color.parseColor("#797979"));
holder.mSHA512.setTextColor(Color.parseColor("#797979"));
holder.mCRC32.setTextColor(Color.parseColor("#797979"));
holder.mCheckInput.setTextColor(Color.parseColor("#00CD00"));
} else if(check.toString().equals(sha1)) {
holder.mMD5.setTextColor(Color.parseColor("#797979"));
holder.mSHA1.setTextColor(Color.parseColor("#00CD00"));
holder.mSHA256.setTextColor(Color.parseColor("#797979"));
holder.mSHA384.setTextColor(Color.parseColor("#797979"));
holder.mSHA512.setTextColor(Color.parseColor("#797979"));
holder.mCRC32.setTextColor(Color.parseColor("#797979"));
holder.mCheckInput.setTextColor(Color.parseColor("#00CD00"));
} else if(eSHA256 && check.toString().equals(sha256)) {
holder.mMD5.setTextColor(Color.parseColor("#797979"));
holder.mSHA1.setTextColor(Color.parseColor("#797979"));
holder.mSHA256.setTextColor(Color.parseColor("#00CD00"));
holder.mSHA384.setTextColor(Color.parseColor("#797979"));
holder.mSHA512.setTextColor(Color.parseColor("#797979"));
holder.mCRC32.setTextColor(Color.parseColor("#797979"));
holder.mCheckInput.setTextColor(Color.parseColor("#00CD00"));
} else if(eSHA384 && check.toString().equals(sha384)) {
holder.mMD5.setTextColor(Color.parseColor("#797979"));
holder.mSHA1.setTextColor(Color.parseColor("#797979"));
holder.mSHA256.setTextColor(Color.parseColor("#797979"));
holder.mSHA384.setTextColor(Color.parseColor("#00CD00"));
holder.mSHA512.setTextColor(Color.parseColor("#797979"));
holder.mCRC32.setTextColor(Color.parseColor("#797979"));
holder.mCheckInput.setTextColor(Color.parseColor("#00CD00"));
} else if(eSHA512 && check.toString().equals(sha512)) {
holder.mSHA512.setTextColor(Color.parseColor("#00CD00"));
holder.mMD5.setTextColor(Color.parseColor("#797979"));
holder.mSHA1.setTextColor(Color.parseColor("#797979"));
holder.mSHA256.setTextColor(Color.parseColor("#797979"));
holder.mSHA384.setTextColor(Color.parseColor("#797979"));
holder.mSHA512.setTextColor(Color.parseColor("00CD00"));
holder.mCRC32.setTextColor(Color.parseColor("#797979"));
holder.mCheckInput.setTextColor(Color.parseColor("#00CD00"));
} else if (eCRC32 && check.toString().equals(crc32)){
holder.mMD5.setTextColor(Color.parseColor("#797979"));
holder.mSHA1.setTextColor(Color.parseColor("#797979"));
holder.mSHA256.setTextColor(Color.parseColor("#797979"));
holder.mSHA384.setTextColor(Color.parseColor("#797979"));
holder.mSHA512.setTextColor(Color.parseColor("#797979"));
holder.mCRC32.setTextColor(Color.parseColor("#00CD00"));
holder.mCheckInput.setTextColor(Color.parseColor("#00CD00"));
}
}
Expand All @@ -540,7 +594,6 @@ public void afterTextChanged(Editable text){
int selection = holder.mCheckInput.getSelectionStart();
holder.mCheckInput.setText(text.toString().toUpperCase());
holder.mCheckInput.setSelection(selection);
check = text.toString().substring(0,text.toString().length());
}
}
} else {
Expand All @@ -550,7 +603,6 @@ public void afterTextChanged(Editable text){
int selection = holder.mCheckInput.getSelectionStart();
holder.mCheckInput.setText(text.toString().toLowerCase());
holder.mCheckInput.setSelection(selection);
check = text.toString().substring(0,text.toString().length());
}
}
}
Expand Down
Binary file removed app/src/main/res/drawable-nodpi/header.jpg
Binary file not shown.
27 changes: 0 additions & 27 deletions app/src/main/res/layout-v17/settings_category.xml

This file was deleted.

10 changes: 10 additions & 0 deletions app/src/main/res/layout/main_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@ limitations under the License.
android:layout_width="match_parent"
android:layout_height="196dp"
android:scaleType="centerCrop"/>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end|bottom"
android:gravity="end|bottom"
android:background="@android:color/transparent"
android:textColor="#FFFFFF"
android:text="@string/header"
android:padding="8dp"/>

</FrameLayout>
7 changes: 7 additions & 0 deletions app/src/main/res/layout/recycler_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ limitations under the License.
android:layout_marginBottom="10dp"
android:visibility="gone"/>

<TextView
android:id="@+id/crc32"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:visibility="gone"/>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
Expand Down
Loading

0 comments on commit 2d4e494

Please sign in to comment.