Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion src/com/amaze/filemanager/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Random;


public class MainActivity extends android.support.v4.app.FragmentActivity {
Expand Down Expand Up @@ -94,6 +95,8 @@ public class MainActivity extends android.support.v4.app.FragmentActivity {
public ArrayList<String> COPY_PATH = null, MOVE_PATH = null;
Context con=this;
public FrameLayout frameLayout;
public boolean mReturnIntent = false;
private Intent intent;
/**
* Called when the activity is first created.
*/
Expand Down Expand Up @@ -137,6 +140,13 @@ public void onClick(View view) {

}
});

intent = getIntent();
if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {
mReturnIntent = true;
Toast.makeText(this, "Pick a file", Toast.LENGTH_LONG).show();
}

skin = PreferenceManager.getDefaultSharedPreferences(this).getString("skin_color", "#673ab7");
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.action_bar);
linearLayout.setBackgroundColor(Color.parseColor(skin));
Expand Down Expand Up @@ -444,8 +454,8 @@ protected void onPause() {
public void onResume() {
super.onResume();
registerReceiver(RECIEVER, new IntentFilter("run"));

}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ( keyCode == KeyEvent.KEYCODE_MENU ) {
Expand All @@ -472,4 +482,42 @@ public void onReceive(Context context, Intent intent) {
}
}
};

private void random() {

String[] colors = new String[]{
"#e51c23",
"#e51c23",
"#e91e63",
"#9c27b0",
"#673ab7",
"#3f51b5",
"#5677fc",
"#0288d1",
"#0097a7",
"#009688",
"#259b24",
"#8bc34a",
"#ffa000",
"#f57c00",
"#e64a19",
"#795548",
"#212121",
"#607d8b"
};

Random random = new Random();
int pos = random.nextInt(colors.length - 1);
Sp.edit().putString("skin_color", colors[pos]).commit();
}

@Override
protected void onDestroy() {
super.onDestroy();

boolean check = Sp.getBoolean("random_checkbox", false);
if (check) {
random();
}
}
}
5 changes: 4 additions & 1 deletion src/com/amaze/filemanager/activities/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onBackPressed() {
Intent in = new Intent(Preferences.this, MainActivity.class);
in.setAction(Intent.ACTION_MAIN);
finish();
startActivity(in);
}
Expand All @@ -62,8 +63,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
case android.R.id.home:
// Navigate "up" the demo structure to the launchpad activity.
// See http://developer.android.com/design/patterns/navigation.html for more.
Intent in = new Intent(Preferences.this, MainActivity.class);
in.setAction(Intent.ACTION_MAIN);
finish();
startActivity(new Intent(this, MainActivity.class));
startActivity(in);
return true;


Expand Down
95 changes: 25 additions & 70 deletions src/com/amaze/filemanager/fragments/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Random;


public class Main extends android.support.v4.app.Fragment {
Expand Down Expand Up @@ -141,7 +140,6 @@ public class Main extends android.support.v4.app.Fragment {
private FloatingActionButton fab;
private TabSpinnerAdapter tabSpinnerAdapter;
public float[] color;
private boolean mReturnIntent = false;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -163,12 +161,6 @@ public void onFinish() {
crossfadeInverse();
}
};

Intent intent = getActivity().getIntent();
if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {
mReturnIntent = true;
Toast.makeText(getActivity(), "Pick a file", Toast.LENGTH_LONG).show();
}
}

@Override
Expand Down Expand Up @@ -570,7 +562,7 @@ public void onListItemClicked(int position, View v) {
loadlist(f, false);
} else {

if (mReturnIntent) {
if (mainActivity.mReturnIntent) {
returnIntentResults(f);
} else {

Expand All @@ -586,11 +578,11 @@ public void onListItemClicked(int position, View v) {
}

private void returnIntentResults (File file) {
mReturnIntent = false;
mainActivity.mReturnIntent = false;

Intent intent = new Intent();
intent.setData(Uri.fromFile(file));
getActivity().setResult(Activity.RESULT_OK, intent);
getActivity().setResult(getActivity().RESULT_OK, intent);
getActivity().finish();
}

Expand Down Expand Up @@ -1288,73 +1280,36 @@ public void onAnimationEnd(Animator animation) {
// Animate the loading view to 0% opacity. After the animation ends,
// set its visibility to GONE as an optimization step (it won't
// participate in layout passes, etc.)


}

@Override
public void onDetach() {
super.onDetach();
boolean check = Sp.getBoolean("random_checkbox", false);
if (check) {
random();
}
public String getSelectionColor(){

String[] colors = new String[]{
"#e51c23","#9fe84e40",
"#e91e63","#9fec407a",
"#9c27b0","#9fab47bc",
"#673ab7","#9f7e57c2",
"#3f51b5","#9f5c6bc0",
"#5677fc","#9f738ffe",
"#0288d1","#9f29b6f6",
"#0097a7","#9f26c6da",
"#009688","#9f26a69a",
"#259b24","#9f2baf2b",
"#8bc34a","#9f9ccc65",
"#ffa000","#9fffca28",
"#f57c00","#9fffa726",
"#e64a19","#9fff7043",
"#795548","#9f8d6e63",
"#212121","#9fbdbdbd",
"#607d8b","#9f78909c",
};
return colors[ Arrays.asList(colors).indexOf(skin)+1];
}
public String getSelectionColor(){

String[] colors = new String[]{
"#e51c23","#9fe84e40",
"#e91e63","#9fec407a",
"#9c27b0","#9fab47bc",
"#673ab7","#9f7e57c2",
"#3f51b5","#9f5c6bc0",
"#5677fc","#9f738ffe",
"#0288d1","#9f29b6f6",
"#0097a7","#9f26c6da",
"#009688","#9f26a69a",
"#259b24","#9f2baf2b",
"#8bc34a","#9f9ccc65",
"#ffa000","#9fffca28",
"#f57c00","#9fffa726",
"#e64a19","#9fff7043",
"#795548","#9f8d6e63",
"#212121","#9fbdbdbd",
"#607d8b","#9f78909c",
};
return colors[ Arrays.asList(colors).indexOf(skin)+1];
}
public float[] calculatevalues(String color){
int c=Color.parseColor(color);
float r=(float)Color.red(c)/255;
float g=(float)Color.green(c)/255;
float b=(float)Color.blue(c)/255;
return new float[]{r,g,b};
}
private void random() {

String[] colors = new String[]{
"#e51c23",
"#e51c23",
"#e91e63",
"#9c27b0",
"#673ab7",
"#3f51b5",
"#5677fc",
"#0288d1",
"#0097a7",
"#009688",
"#259b24",
"#8bc34a",
"#ffa000",
"#f57c00",
"#e64a19",
"#795548",
"#212121",
"#607d8b"
};

Random random = new Random();
int pos = random.nextInt(colors.length - 1);
Sp.edit().putString("skin_color", colors[pos]).commit();
}
}