mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 23:28:52 -04:00
Code cleanup
This commit is contained in:
parent
ca3da54da0
commit
01d514d9fe
@ -1,5 +1,3 @@
|
|||||||
package com.kdt.filerapi;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012 Paul Burke
|
* Copyright (C) 2012 Paul Burke
|
||||||
*
|
*
|
||||||
@ -16,6 +14,8 @@ package com.kdt.filerapi;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
package com.ipaulpro.afilechooser;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
@ -30,7 +30,7 @@ import net.kdt.pojavlaunch.*;
|
|||||||
* @author paulburke (ipaulpro)
|
* @author paulburke (ipaulpro)
|
||||||
*
|
*
|
||||||
* @addDate 2018-08-08
|
* @addDate 2018-08-08
|
||||||
* @addToMyProject khanhduy032 (kdt032)
|
* @addToMyProject khanhduy032
|
||||||
*/
|
*/
|
||||||
public class FileListAdapter extends BaseAdapter {
|
public class FileListAdapter extends BaseAdapter {
|
||||||
|
|
@ -1,64 +1,46 @@
|
|||||||
package com.kdt.filerapi;
|
package com.kdt.filerapi;
|
||||||
|
|
||||||
|
import android.support.v7.app.*;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.graphics.*;
|
|
||||||
import android.os.*;
|
|
||||||
import android.support.annotation.*;
|
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.widget.AdapterView.*;
|
import android.widget.AdapterView.*;
|
||||||
|
import com.ipaulpro.afilechooser.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import net.kdt.pojavlaunch.*;
|
||||||
|
|
||||||
public class FileListView extends LinearLayout
|
public class FileListView extends LinearLayout
|
||||||
{
|
{
|
||||||
//For list view:
|
//For list view:
|
||||||
private String fullPath;
|
private String fullPath;
|
||||||
private TextView mainTv;
|
|
||||||
private ListView mainLv;
|
private ListView mainLv;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
private boolean lockedHome = false;
|
||||||
//For message empty:
|
|
||||||
private WindowManager emptyWm;
|
|
||||||
private TextView emptyTv;
|
|
||||||
|
|
||||||
//For File selected listener:
|
//For File selected listener:
|
||||||
private FileSelectedListener listener;
|
private FileSelectedListener listener;
|
||||||
|
private AlertDialog build;
|
||||||
|
private String homePath;
|
||||||
|
|
||||||
public FileListView(Context context)
|
public FileListView(Context context, AlertDialog build) {
|
||||||
{
|
|
||||||
super(context);
|
super(context);
|
||||||
init(context);
|
init(context);
|
||||||
|
this.build = build;
|
||||||
}
|
}
|
||||||
public FileListView(Context context, AttributeSet attrs)
|
|
||||||
{
|
public FileListView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
init(context);
|
init(context);
|
||||||
}
|
}
|
||||||
public FileListView(Context context, AttributeSet attrs, int defStyle)
|
|
||||||
{
|
public FileListView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
init(context);
|
init(context);
|
||||||
}
|
}
|
||||||
public void init(final Context context)
|
|
||||||
{
|
|
||||||
//Empty message setup:
|
|
||||||
WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
|
|
||||||
mParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
|
||||||
mParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
|
||||||
mParams.gravity = Gravity.CENTER;
|
|
||||||
mParams.format = PixelFormat.TRANSLUCENT;
|
|
||||||
mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION;
|
|
||||||
mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
|
||||||
|
|
||||||
emptyWm = (WindowManager) context.getSystemService(context.WINDOW_SERVICE);
|
|
||||||
|
|
||||||
emptyTv = new TextView(context);
|
|
||||||
emptyTv.setText("This folder is empty");
|
|
||||||
|
|
||||||
emptyWm.addView(emptyTv, mParams);
|
|
||||||
|
|
||||||
|
public void init(final Context context) {
|
||||||
//Main setup:
|
//Main setup:
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
@ -66,12 +48,9 @@ public class FileListView extends LinearLayout
|
|||||||
|
|
||||||
setOrientation(VERTICAL);
|
setOrientation(VERTICAL);
|
||||||
|
|
||||||
mainTv = new TextView(context);
|
|
||||||
mainTv.setText("Path: null");
|
|
||||||
|
|
||||||
mainLv = new ListView(context);
|
mainLv = new ListView(context);
|
||||||
|
|
||||||
listFileAt(Environment.getExternalStorageDirectory().getPath());
|
//listFileAt(Environment.getExternalStorageDirectory().getPath());
|
||||||
|
|
||||||
mainLv.setOnItemClickListener(new OnItemClickListener(){
|
mainLv.setOnItemClickListener(new OnItemClickListener(){
|
||||||
@Override
|
@Override
|
||||||
@ -79,18 +58,26 @@ public class FileListView extends LinearLayout
|
|||||||
{
|
{
|
||||||
// TODO: Implement this method
|
// TODO: Implement this method
|
||||||
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
||||||
String name = mainFile.getName();
|
if (p3 == 0) {
|
||||||
//Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();
|
|
||||||
if(name.equals(".. ")){
|
|
||||||
parentDir();
|
parentDir();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
listFileAt(mainFile.getAbsolutePath());
|
listFileAt(mainFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mainLv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
|
||||||
addView(mainTv, layParam);
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> p1, View p2, int p3, long p4)
|
||||||
|
{
|
||||||
|
// TODO: Implement this method
|
||||||
|
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
||||||
|
if (mainFile.isFile()) {
|
||||||
|
listener.onFileLongClick(mainFile, mainFile.getAbsolutePath());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
addView(mainLv, layParam);
|
addView(mainLv, layParam);
|
||||||
}
|
}
|
||||||
public void setFileSelectedListener(FileSelectedListener listener)
|
public void setFileSelectedListener(FileSelectedListener listener)
|
||||||
@ -103,59 +90,43 @@ public class FileListView extends LinearLayout
|
|||||||
final File mainPath = new File(path);
|
final File mainPath = new File(path);
|
||||||
if(mainPath.exists()){
|
if(mainPath.exists()){
|
||||||
if(mainPath.isDirectory()){
|
if(mainPath.isDirectory()){
|
||||||
|
if(!lockedHome){
|
||||||
|
homePath = path;
|
||||||
|
lockedHome = true;
|
||||||
|
}
|
||||||
fullPath = path;
|
fullPath = path;
|
||||||
|
|
||||||
File[] listFile = mainPath.listFiles();
|
File[] listFile = mainPath.listFiles();
|
||||||
FileListAdapter fileAdapter = new FileListAdapter(context);
|
FileListAdapter fileAdapter = new FileListAdapter(context);
|
||||||
fileAdapter.add(new File(path, ".. "));
|
if(!path.equals(homePath)){
|
||||||
|
//fileAdapter.add(new File(path, "Path=\""+path+"\".noEquals(homePath=\""+homePath+"\")"));
|
||||||
|
fileAdapter.add(new File(path, ".."));
|
||||||
|
}
|
||||||
|
|
||||||
if(listFile.length != 0){
|
if(listFile.length != 0){
|
||||||
Arrays.sort(listFile, new SortFileName());
|
Arrays.sort(listFile, new SortFileName());
|
||||||
for(File file : listFile){
|
for(File file : listFile){
|
||||||
fileAdapter.add(file);
|
fileAdapter.add(file);
|
||||||
}
|
}
|
||||||
emptyTv.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
emptyTv.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
mainLv.setAdapter(fileAdapter);
|
mainLv.setAdapter(fileAdapter);
|
||||||
mainTv.setText("Path: " + path);
|
build.setTitle(new File(path).getName());
|
||||||
|
} else {
|
||||||
|
listener.onFileSelected(mainPath, path);
|
||||||
}
|
}
|
||||||
else{
|
} else {
|
||||||
String name = mainPath.getName();
|
|
||||||
// String extension = getExtension(path);
|
|
||||||
listener.onFileSelected(mainPath, path, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Toast.makeText(context, "This folder (or file) doesn't exist", Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, "This folder (or file) doesn't exist", Toast.LENGTH_SHORT).show();
|
||||||
refreshPath();
|
refreshPath();
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e){
|
||||||
catch(Exception e){
|
Tools.showError(context, e);
|
||||||
/*
|
|
||||||
new AlertDialog.Builder(context)
|
|
||||||
.setTitle("Error")
|
|
||||||
.setMessage(Log.getStackTraceString(e))
|
|
||||||
.setPositiveButton("OK", null)
|
|
||||||
.show();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static String getExtension(String path)
|
|
||||||
{
|
public String getFullPath(){
|
||||||
return getExtension(new File(path));
|
|
||||||
}
|
|
||||||
public static String getExtension(File file)
|
|
||||||
{
|
|
||||||
return file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf("."));
|
|
||||||
}
|
|
||||||
public String getFullPath()
|
|
||||||
{
|
|
||||||
return fullPath;
|
return fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshPath()
|
public void refreshPath()
|
||||||
{
|
{
|
||||||
listFileAt(getFullPath());
|
listFileAt(getFullPath());
|
||||||
@ -163,7 +134,7 @@ public class FileListView extends LinearLayout
|
|||||||
public void parentDir()
|
public void parentDir()
|
||||||
{
|
{
|
||||||
File pathFile = new File(fullPath);
|
File pathFile = new File(fullPath);
|
||||||
if(!pathFile.getAbsolutePath().equals(Environment.getExternalStorageDirectory().getAbsolutePath())){
|
if(!pathFile.getAbsolutePath().equals("/")){
|
||||||
listFileAt(pathFile.getParent());
|
listFileAt(pathFile.getParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ package com.kdt.filerapi;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public interface FileSelectedListener
|
public abstract class FileSelectedListener
|
||||||
{
|
{
|
||||||
public void onFileSelected(File file, String path, String name);
|
public abstract void onFileSelected(File file, String path);
|
||||||
|
public void onFileLongClick(File file, String path) {}
|
||||||
}
|
}
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
package com.kdt.filermod;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2012 Paul Burke
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import android.content.*;
|
|
||||||
import android.view.*;
|
|
||||||
import android.widget.*;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List adapter for Files.
|
|
||||||
*
|
|
||||||
* @version 2013-12-11
|
|
||||||
* @author paulburke (ipaulpro)
|
|
||||||
*
|
|
||||||
* @addDate 2018-08-08
|
|
||||||
* @addToMyProject khanhduy032 (kdt032)
|
|
||||||
*/
|
|
||||||
public class MFileListAdapter extends BaseAdapter {
|
|
||||||
|
|
||||||
private final LayoutInflater mInflater;
|
|
||||||
|
|
||||||
private List<File> mData = new ArrayList<File>();
|
|
||||||
|
|
||||||
public MFileListAdapter(Context context) {
|
|
||||||
mInflater = LayoutInflater.from(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(File file) {
|
|
||||||
mData.add(file);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(File file) {
|
|
||||||
mData.remove(file);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insert(File file, int index) {
|
|
||||||
mData.add(index, file);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
mData.clear();
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getItem(int position) {
|
|
||||||
return mData.get(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return mData.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<File> getListItems() {
|
|
||||||
return mData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the list items without notifying on the clear. This prevents loss of
|
|
||||||
* scroll position.
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
public void setListItems(List<File> data) {
|
|
||||||
mData = data;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
View row = convertView;
|
|
||||||
|
|
||||||
if (row == null)
|
|
||||||
row = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
|
|
||||||
|
|
||||||
TextView view = (TextView) row;
|
|
||||||
|
|
||||||
// Get the file at the current position
|
|
||||||
final File file = getItem(position);
|
|
||||||
|
|
||||||
// Set the TextView as the file name
|
|
||||||
view.setText(file.getName());
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,167 +0,0 @@
|
|||||||
package com.kdt.filermod;
|
|
||||||
|
|
||||||
import android.app.*;
|
|
||||||
import android.content.*;
|
|
||||||
import android.graphics.*;
|
|
||||||
import android.os.*;
|
|
||||||
import android.util.*;
|
|
||||||
import android.view.*;
|
|
||||||
import android.widget.*;
|
|
||||||
import android.widget.AdapterView.*;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
import net.kdt.pojavlaunch.*;
|
|
||||||
|
|
||||||
public class MFileListView extends LinearLayout
|
|
||||||
{
|
|
||||||
//For list view:
|
|
||||||
private String fullPath;
|
|
||||||
private ListView mainLv;
|
|
||||||
private Context context;
|
|
||||||
private boolean lockedHome = false;
|
|
||||||
|
|
||||||
//For File selected listener:
|
|
||||||
private MFileSelectedListener listener;
|
|
||||||
private AlertDialog build;
|
|
||||||
private String homePath;
|
|
||||||
|
|
||||||
public MFileListView(Context context, AlertDialog build)
|
|
||||||
{
|
|
||||||
super(context);
|
|
||||||
init(context);
|
|
||||||
this.build = build;
|
|
||||||
}
|
|
||||||
public MFileListView(Context context, AttributeSet attrs)
|
|
||||||
{
|
|
||||||
super(context, attrs);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
public MFileListView(Context context, AttributeSet attrs, int defStyle)
|
|
||||||
{
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
public void init(final Context context)
|
|
||||||
{
|
|
||||||
//Main setup:
|
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
LayoutParams layParam = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
|
||||||
|
|
||||||
setOrientation(VERTICAL);
|
|
||||||
|
|
||||||
mainLv = new ListView(context);
|
|
||||||
|
|
||||||
//listFileAt(Environment.getExternalStorageDirectory().getPath());
|
|
||||||
|
|
||||||
mainLv.setOnItemClickListener(new OnItemClickListener(){
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4)
|
|
||||||
{
|
|
||||||
// TODO: Implement this method
|
|
||||||
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
|
||||||
String name = mainFile.getName();
|
|
||||||
//Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();
|
|
||||||
if(name.equals(".. ")){
|
|
||||||
parentDir();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
listFileAt(mainFile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mainLv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
|
|
||||||
@Override
|
|
||||||
public boolean onItemLongClick(AdapterView<?> p1, View p2, int p3, long p4)
|
|
||||||
{
|
|
||||||
// TODO: Implement this method
|
|
||||||
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
|
||||||
String name = mainFile.getName();
|
|
||||||
//Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();
|
|
||||||
if(mainFile.isFile()){
|
|
||||||
String extension = getExtension(mainFile.getAbsolutePath());
|
|
||||||
listener.onFileLongClick(mainFile, mainFile.getAbsolutePath(), name, extension);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addView(mainLv, layParam);
|
|
||||||
}
|
|
||||||
public void setFileSelectedListener(MFileSelectedListener listener)
|
|
||||||
{
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
public void listFileAt(final String path)
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
final File mainPath = new File(path);
|
|
||||||
if(mainPath.exists()){
|
|
||||||
if(mainPath.isDirectory()){
|
|
||||||
if(!lockedHome){
|
|
||||||
homePath = path;
|
|
||||||
lockedHome = true;
|
|
||||||
}
|
|
||||||
fullPath = path;
|
|
||||||
|
|
||||||
File[] listFile = mainPath.listFiles();
|
|
||||||
MFileListAdapter fileAdapter = new MFileListAdapter(context);
|
|
||||||
if(!path.equals(homePath)){
|
|
||||||
//fileAdapter.add(new File(path, "Path=\""+path+"\".noEquals(homePath=\""+homePath+"\")"));
|
|
||||||
fileAdapter.add(new File(path, ".. "));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(listFile.length != 0){
|
|
||||||
Arrays.sort(listFile, new MSortFileName());
|
|
||||||
for(File file : listFile){
|
|
||||||
fileAdapter.add(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mainLv.setAdapter(fileAdapter);
|
|
||||||
build.setTitle(new File(path).getName());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
String name = mainPath.getName();
|
|
||||||
String extension = getExtension(path);
|
|
||||||
listener.onFileSelected(mainPath, path, name, extension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Toast.makeText(context, "This folder (or file) doesn't exist", Toast.LENGTH_SHORT).show();
|
|
||||||
refreshPath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e){
|
|
||||||
/*
|
|
||||||
new AlertDialog.Builder(context)
|
|
||||||
.setTitle("Error")
|
|
||||||
.setMessage(Log.getStackTraceString(e))
|
|
||||||
.setPositiveButton("OK", null)
|
|
||||||
.show();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static String getExtension(String path)
|
|
||||||
{
|
|
||||||
return getExtension(new File(path));
|
|
||||||
}
|
|
||||||
public static String getExtension(File file)
|
|
||||||
{
|
|
||||||
return file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf("."));
|
|
||||||
}
|
|
||||||
public String getFullPath()
|
|
||||||
{
|
|
||||||
return fullPath;
|
|
||||||
}
|
|
||||||
public void refreshPath()
|
|
||||||
{
|
|
||||||
listFileAt(getFullPath());
|
|
||||||
}
|
|
||||||
public void parentDir()
|
|
||||||
{
|
|
||||||
File pathFile = new File(fullPath);
|
|
||||||
if(!pathFile.getAbsolutePath().equals(Environment.getExternalStorageDirectory().getAbsolutePath())){
|
|
||||||
listFileAt(pathFile.getParent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.kdt.filermod;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public interface MFileSelectedListener
|
|
||||||
{
|
|
||||||
public void onFileSelected(File file, String path, String nane, String extension);
|
|
||||||
public void onFileLongClick(File file, String path, String nane, String extension);
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.kdt.filermod;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class MSortFileName implements Comparator<File>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare(File f1, File f2) {
|
|
||||||
return f1.getName().compareToIgnoreCase(f2.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,15 +5,15 @@ import android.os.*;
|
|||||||
import android.support.design.widget.*;
|
import android.support.design.widget.*;
|
||||||
import android.support.v4.widget.*;
|
import android.support.v4.widget.*;
|
||||||
import android.support.v7.app.*;
|
import android.support.v7.app.*;
|
||||||
|
import android.support.v7.preference.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import com.kdt.filerapi.*;
|
import com.kdt.filerapi.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import net.kdt.pojavlaunch.*;
|
||||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
|
||||||
import android.support.v7.preference.*;
|
|
||||||
import net.kdt.pojavlaunch.prefs.*;
|
import net.kdt.pojavlaunch.prefs.*;
|
||||||
|
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||||
|
|
||||||
public class CustomControlsActivity extends AppCompatActivity
|
public class CustomControlsActivity extends AppCompatActivity
|
||||||
{
|
{
|
||||||
@ -106,13 +106,13 @@ public class CustomControlsActivity extends AppCompatActivity
|
|||||||
builder.setPositiveButton(android.R.string.cancel, null);
|
builder.setPositiveButton(android.R.string.cancel, null);
|
||||||
|
|
||||||
final AlertDialog dialog = builder.create();
|
final AlertDialog dialog = builder.create();
|
||||||
FileListView flv = new FileListView(this);
|
FileListView flv = new FileListView(this, dialog);
|
||||||
flv.listFileAt(Tools.CTRLMAP_PATH);
|
flv.listFileAt(Tools.CTRLMAP_PATH);
|
||||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileSelected(File file, String path, String name) {
|
public void onFileSelected(File file, String path) {
|
||||||
if (name.endsWith(".json")) {
|
if (file.getName().endsWith(".json")) {
|
||||||
setDefaultControlJson(path);
|
setDefaultControlJson(path);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
@ -188,13 +188,13 @@ public class CustomControlsActivity extends AppCompatActivity
|
|||||||
builder.setPositiveButton(android.R.string.cancel, null);
|
builder.setPositiveButton(android.R.string.cancel, null);
|
||||||
|
|
||||||
final AlertDialog dialog = builder.create();
|
final AlertDialog dialog = builder.create();
|
||||||
FileListView flv = new FileListView(this);
|
FileListView flv = new FileListView(this, dialog);
|
||||||
flv.listFileAt(Tools.CTRLMAP_PATH);
|
flv.listFileAt(Tools.CTRLMAP_PATH);
|
||||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileSelected(File file, String path, String name) {
|
public void onFileSelected(File file, String path) {
|
||||||
if (name.endsWith(".json")) {
|
if (file.getName().endsWith(".json")) {
|
||||||
loadControl(path);
|
loadControl(path);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package net.kdt.pojavlaunch;
|
package net.kdt.pojavlaunch;
|
||||||
|
|
||||||
import android.app.*;
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.support.design.widget.*;
|
import android.support.design.widget.*;
|
||||||
import android.support.v4.app.*;
|
import android.support.v4.app.*;
|
||||||
|
import android.support.v4.view.*;
|
||||||
import android.support.v7.app.*;
|
import android.support.v7.app.*;
|
||||||
import android.text.*;
|
import android.text.*;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
@ -17,16 +17,17 @@ import com.kdt.filerapi.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import net.kdt.pojavlaunch.*;
|
||||||
import net.kdt.pojavlaunch.mcfragments.*;
|
import net.kdt.pojavlaunch.mcfragments.*;
|
||||||
import net.kdt.pojavlaunch.prefs.*;
|
import net.kdt.pojavlaunch.prefs.*;
|
||||||
import net.kdt.pojavlaunch.util.*;
|
import net.kdt.pojavlaunch.util.*;
|
||||||
import net.kdt.pojavlaunch.value.*;
|
import net.kdt.pojavlaunch.value.*;
|
||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.view.*;
|
import android.app.*;
|
||||||
//import android.support.v7.view.menu.*;
|
//import android.support.v7.view.menu.*;
|
||||||
//import net.zhuoweizhang.boardwalk.downloader.*;
|
//import net.zhuoweizhang.boardwalk.downloader.*;
|
||||||
|
|
||||||
@ -829,12 +830,11 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
dialog.setView(edit);
|
dialog.setView(edit);
|
||||||
} else {
|
} else {
|
||||||
dialog = builder.create();
|
dialog = builder.create();
|
||||||
FileListView flv = new FileListView(this);
|
FileListView flv = new FileListView(this, dialog);
|
||||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileSelected(File file, String path, String name) {
|
public void onFileSelected(File file, String path) {
|
||||||
if (name.endsWith(".jar")) {
|
if (file.getName().endsWith(".jar")) {
|
||||||
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
||||||
intent.putExtra("modFile", file);
|
intent.putExtra("modFile", file);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -6,7 +6,9 @@ import android.graphics.*;
|
|||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.support.design.widget.*;
|
import android.support.design.widget.*;
|
||||||
import android.support.v4.app.*;
|
import android.support.v4.app.*;
|
||||||
|
import android.support.v4.view.*;
|
||||||
import android.support.v7.app.*;
|
import android.support.v7.app.*;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.*;
|
import android.text.*;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
@ -17,16 +19,15 @@ import com.kdt.filerapi.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import net.kdt.pojavlaunch.*;
|
||||||
import net.kdt.pojavlaunch.mcfragments.*;
|
import net.kdt.pojavlaunch.mcfragments.*;
|
||||||
import net.kdt.pojavlaunch.prefs.*;
|
import net.kdt.pojavlaunch.prefs.*;
|
||||||
import net.kdt.pojavlaunch.util.*;
|
import net.kdt.pojavlaunch.util.*;
|
||||||
import net.kdt.pojavlaunch.value.*;
|
import net.kdt.pojavlaunch.value.*;
|
||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.view.*;
|
|
||||||
//import android.support.v7.view.menu.*;
|
//import android.support.v7.view.menu.*;
|
||||||
//import net.zhuoweizhang.boardwalk.downloader.*;
|
//import net.zhuoweizhang.boardwalk.downloader.*;
|
||||||
|
|
||||||
@ -836,12 +837,12 @@ public class PojavLauncherActivity extends AppCompatActivity
|
|||||||
dialog.setView(edit);
|
dialog.setView(edit);
|
||||||
} else {
|
} else {
|
||||||
dialog = builder.create();
|
dialog = builder.create();
|
||||||
FileListView flv = new FileListView(this);
|
FileListView flv = new FileListView(this, dialog);
|
||||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileSelected(File file, String path, String name) {
|
public void onFileSelected(File file, String path) {
|
||||||
if (name.endsWith(".jar")) {
|
if (file.getName().endsWith(".jar")) {
|
||||||
Intent intent = new Intent(PojavLauncherActivity.this, InstallModActivity.class);
|
Intent intent = new Intent(PojavLauncherActivity.this, InstallModActivity.class);
|
||||||
intent.putExtra("modFile", file);
|
intent.putExtra("modFile", file);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.kdt.pojavlaunch;
|
package net.kdt.pojavlaunch;
|
||||||
|
|
||||||
import android.*;
|
import android.*;
|
||||||
import android.app.*;
|
import android.support.v7.app.*;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.content.pm.*;
|
import android.content.pm.*;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
@ -13,7 +13,6 @@ import android.view.*;
|
|||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.widget.CompoundButton.*;
|
import android.widget.CompoundButton.*;
|
||||||
import com.kdt.filerapi.*;
|
import com.kdt.filerapi.*;
|
||||||
import com.kdt.filermod.*;
|
|
||||||
import com.kdt.mojangauth.*;
|
import com.kdt.mojangauth.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -21,10 +20,10 @@ import net.kdt.pojavlaunch.update.*;
|
|||||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||||
import org.apache.commons.compress.archivers.tar.*;
|
import org.apache.commons.compress.archivers.tar.*;
|
||||||
import org.apache.commons.compress.compressors.xz.*;
|
import org.apache.commons.compress.compressors.xz.*;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import org.apache.commons.io.*;
|
import org.apache.commons.io.*;
|
||||||
|
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
public class PojavLoginActivity extends AppCompatActivity
|
public class PojavLoginActivity extends AppCompatActivity
|
||||||
// MineActivity
|
// MineActivity
|
||||||
{
|
{
|
||||||
@ -378,12 +377,12 @@ public class PojavLoginActivity extends AppCompatActivity
|
|||||||
builder.setCancelable(false);
|
builder.setCancelable(false);
|
||||||
|
|
||||||
final AlertDialog dialog = builder.create();
|
final AlertDialog dialog = builder.create();
|
||||||
FileListView flv = new FileListView(PojavLoginActivity.this);
|
FileListView flv = new FileListView(PojavLoginActivity.this, dialog);
|
||||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileSelected(File file, String path, String name) {
|
public void onFileSelected(File file, String path) {
|
||||||
if (name.endsWith(".tar.xz")) {
|
if (file.getName().endsWith(".tar.xz")) {
|
||||||
selectedFile.append(path);
|
selectedFile.append(path);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
@ -537,24 +536,22 @@ public class PojavLoginActivity extends AppCompatActivity
|
|||||||
fhint.setText(R.string.hint_select_account);
|
fhint.setText(R.string.hint_select_account);
|
||||||
// fhint.setLayoutParams(lpHint);
|
// fhint.setLayoutParams(lpHint);
|
||||||
|
|
||||||
final MFileListView flv = new MFileListView(this, dialog);
|
final FileListView flv = new FileListView(this, dialog);
|
||||||
// flv.setLayoutParams(lpFlv);
|
// flv.setLayoutParams(lpFlv);
|
||||||
|
|
||||||
flv.listFileAt(Tools.mpProfiles);
|
flv.listFileAt(Tools.mpProfiles);
|
||||||
flv.setFileSelectedListener(new MFileSelectedListener(){
|
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileLongClick(final File file, String path, String name, String extension)
|
public void onFileLongClick(final File file, String path)
|
||||||
{
|
{
|
||||||
AlertDialog.Builder builder2 = new AlertDialog.Builder(PojavLoginActivity.this);
|
AlertDialog.Builder builder2 = new AlertDialog.Builder(PojavLoginActivity.this);
|
||||||
builder2.setTitle(name);
|
builder2.setTitle(file.getName());
|
||||||
builder2.setMessage(R.string.warning_remove_account);
|
builder2.setMessage(R.string.warning_remove_account);
|
||||||
builder2.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
builder2.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface p1, int p2)
|
public void onClick(DialogInterface p1, int p2) {
|
||||||
{
|
|
||||||
// TODO: Implement this method
|
|
||||||
file.delete();
|
file.delete();
|
||||||
flv.refreshPath();
|
flv.refreshPath();
|
||||||
}
|
}
|
||||||
@ -563,7 +560,7 @@ public class PojavLoginActivity extends AppCompatActivity
|
|||||||
builder2.show();
|
builder2.show();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFileSelected(File file, final String path, String nane, String extension) {
|
public void onFileSelected(File file, final String path) {
|
||||||
try {
|
try {
|
||||||
if (MCProfile.load(path).isMojangAccount()){
|
if (MCProfile.load(path).isMojangAccount()){
|
||||||
MCProfile.updateTokens(PojavLoginActivity.this, path, new RefreshListener(){
|
MCProfile.updateTokens(PojavLoginActivity.this, path, new RefreshListener(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user