mirror of
https://github.com/TeamAmaze/AmazeFileManager.git
synced 2026-10-23 17:12:34 +08:00
Partial working tab feature
Includes fixes in database classes
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 232 B |
@@ -2,8 +2,9 @@
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/spinnerText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="#000000"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
@@ -18,8 +19,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="?android:borderlessButtonStyle"
|
||||
android:src="@drawable/ic_action_expand"
|
||||
android:background="@null"
|
||||
android:src="@drawable/spinner_triangle"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -38,7 +38,6 @@
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="rememberLastPath"
|
||||
|
||||
android:title="Remember Last Path" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -54,8 +53,8 @@ public class TabHandler extends SQLiteOpenHelper {
|
||||
sqLiteDatabase.close();
|
||||
}
|
||||
|
||||
public Tab findTab(String tabLabel) {
|
||||
String query = "Select * FROM " + TABLE_TAB + " WHERE " + COLUMN_LABEL + "= \"" + tabLabel + "\"";
|
||||
public Tab findTab(int tabNo) {
|
||||
String query = "Select * FROM " + TABLE_TAB + " WHERE " + COLUMN_TAB_NO + "= \"" + tabNo + "\"";
|
||||
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
|
||||
Cursor cursor = sqLiteDatabase.rawQuery(query, null);
|
||||
Tab tab = new Tab();
|
||||
@@ -80,7 +79,7 @@ public class TabHandler extends SQLiteOpenHelper {
|
||||
contentValues.put(COLUMN_PATH, tab.getPath());
|
||||
|
||||
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
|
||||
sqLiteDatabase.update(TABLE_TAB, contentValues, tab.getTab() + "=" + COLUMN_ID, null);
|
||||
sqLiteDatabase.update(TABLE_TAB, contentValues, tab.getTab() + "=" + COLUMN_TAB_NO, null);
|
||||
sqLiteDatabase.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -29,6 +31,7 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
@@ -239,10 +242,11 @@ public class Main extends android.support.v4.app.Fragment {
|
||||
this.setRetainInstance(false);
|
||||
|
||||
File f = new File(home);
|
||||
if(rememberLastPath){
|
||||
/*if(rememberLastPath){
|
||||
f=new File(Sp.getString("current",home));
|
||||
}*/
|
||||
f=new File(Sp.getString("current",home));
|
||||
|
||||
}
|
||||
buttons = (LinearLayout) getActivity().findViewById(R.id.buttons);
|
||||
pathbar = (LinearLayout) getActivity().findViewById(R.id.pathbar);
|
||||
|
||||
@@ -407,7 +411,10 @@ public class Main extends android.support.v4.app.Fragment {
|
||||
ba2.show();
|
||||
break;
|
||||
case 2:
|
||||
tabHandler.addTab(new Tab(1, "legacy", "/storage/emulated/legacy"));
|
||||
int older = tabHandler.getTabsCount();
|
||||
tabHandler.addTab(new Tab(older, "legacy", "/storage/emulated/legacy"));
|
||||
restartPC(getActivity());
|
||||
Sp.edit().putInt("spinner_selected", older).commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -494,13 +501,14 @@ public class Main extends android.support.v4.app.Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadlist(File f, boolean back) {
|
||||
public void loadlist(final File f, boolean back) {
|
||||
if(mActionMode!=null){mActionMode.finish();}
|
||||
new LoadList(back, ma).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (f));
|
||||
|
||||
// Spinner
|
||||
|
||||
tabHandler.updateTab(new Tab(1, f.getName(), f.getPath()));
|
||||
int spinner_current = Sp.getInt("spinner_selected", 0);
|
||||
tabHandler.updateTab(new Tab(spinner_current, f.getName(), f.getPath()));
|
||||
content = tabHandler.getAllTabs();
|
||||
list1 = new ArrayList<String>();
|
||||
adapter1 = new ArrayAdapter<String>(getActivity(),
|
||||
@@ -513,6 +521,38 @@ public class Main extends android.support.v4.app.Fragment {
|
||||
}
|
||||
mainActivity.tabsSpinner.setAdapter(adapter1);
|
||||
|
||||
mainActivity.tabsSpinner.setSelection(spinner_current);
|
||||
|
||||
Fragment fragment = new Main();
|
||||
final FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
|
||||
final TabHandler tabHandler1 = new TabHandler(getActivity(), null, null, 1);
|
||||
mainActivity.tabsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
|
||||
int spinner_current = Sp.getInt("spinner_selected", 0);
|
||||
if (i == spinner_current) {
|
||||
|
||||
}
|
||||
else {
|
||||
Tab tab = tabHandler1.findTab(i);
|
||||
String name = tab.getPath();
|
||||
//Toast.makeText(getActivity(), name, Toast.LENGTH_SHORT).show();
|
||||
Sp.edit().putString("current", name).apply();
|
||||
Sp.edit().putInt("spinner_selected", i).apply();
|
||||
fragmentTransaction.replace(R.id.content_frame, new Main());
|
||||
fragmentTransaction.commit();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user