mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-04-02 18:30:44 +02:00
Show action bar in load/save game activities
This makes the "delete file" action accessible again. (Broke in version 1.75.)
This commit is contained in:
parent
da38bed581
commit
15b62e9bc2
@ -20,7 +20,6 @@ package org.petero.droidfish.activities;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -42,6 +41,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.databinding.DataBindingUtil;
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
|
||||||
import org.petero.droidfish.ColorTheme;
|
import org.petero.droidfish.ColorTheme;
|
||||||
@ -57,11 +57,12 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public abstract class EditPGN extends ListActivity {
|
public abstract class EditPGN extends AppCompatActivity {
|
||||||
private static ArrayList<GameInfo> gamesInFile = new ArrayList<>();
|
private static ArrayList<GameInfo> gamesInFile = new ArrayList<>();
|
||||||
private static boolean cacheValid = false;
|
private static boolean cacheValid = false;
|
||||||
private PGNFile pgnFile;
|
private PGNFile pgnFile;
|
||||||
private ProgressDialog progress;
|
private ProgressDialog progress;
|
||||||
|
|
||||||
private GameInfo selectedGi = null;
|
private GameInfo selectedGi = null;
|
||||||
private GameAdapter<GameInfo> aa = null;
|
private GameAdapter<GameInfo> aa = null;
|
||||||
|
|
||||||
@ -109,7 +110,6 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
pgnFile = new PGNFile(fileName);
|
pgnFile = new PGNFile(fileName);
|
||||||
loadGame = true;
|
loadGame = true;
|
||||||
showDialog(PROGRESS_DIALOG);
|
showDialog(PROGRESS_DIALOG);
|
||||||
final EditPGN lpgn = this;
|
|
||||||
workThread = new Thread(() -> {
|
workThread = new Thread(() -> {
|
||||||
if (!readFile())
|
if (!readFile())
|
||||||
return;
|
return;
|
||||||
@ -118,7 +118,7 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
lpgn.showList();
|
showList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -170,7 +170,6 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
} else {
|
} else {
|
||||||
pgnFile = new PGNFile(fileName);
|
pgnFile = new PGNFile(fileName);
|
||||||
showDialog(PROGRESS_DIALOG);
|
showDialog(PROGRESS_DIALOG);
|
||||||
final EditPGN lpgn = this;
|
|
||||||
workThread = new Thread(() -> {
|
workThread = new Thread(() -> {
|
||||||
if (!readFile())
|
if (!readFile())
|
||||||
return;
|
return;
|
||||||
@ -182,7 +181,7 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
pgnFile.appendPGN(pgnToSave);
|
pgnFile.appendPGN(pgnToSave);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
lpgn.showList();
|
showList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -254,7 +253,7 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
binding = DataBindingUtil.setContentView(this, R.layout.select_game);
|
binding = DataBindingUtil.setContentView(this, R.layout.select_game);
|
||||||
Util.overrideViewAttribs(findViewById(android.R.id.content));
|
Util.overrideViewAttribs(findViewById(android.R.id.content));
|
||||||
createAdapter();
|
createAdapter();
|
||||||
ListView lv = getListView();
|
ListView lv = binding.listView;
|
||||||
currentFilePos = defaultFilePos;
|
currentFilePos = defaultFilePos;
|
||||||
int itemNo = getItemNo(gamesInFile, defaultFilePos);
|
int itemNo = getItemNo(gamesInFile, defaultFilePos);
|
||||||
lv.setSelectionFromTop(itemNo, 0);
|
lv.setSelectionFromTop(itemNo, 0);
|
||||||
@ -456,12 +455,9 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
|
|
||||||
private void deleteGame(GameInfo gi) {
|
private void deleteGame(GameInfo gi) {
|
||||||
if (pgnFile.deleteGame(gi, gamesInFile)) {
|
if (pgnFile.deleteGame(gi, gamesInFile)) {
|
||||||
ListView lv = getListView();
|
|
||||||
int pos = lv.pointToPosition(0, 0);
|
|
||||||
createAdapter();
|
createAdapter();
|
||||||
String s = binding.selectGameFilter.getText().toString();
|
String s = binding.selectGameFilter.getText().toString();
|
||||||
setFilterString(s);
|
setFilterString(s);
|
||||||
lv.setSelection(pos);
|
|
||||||
// Update lastModTime, since current change has already been handled
|
// Update lastModTime, since current change has already been handled
|
||||||
String fileName = pgnFile.getName();
|
String fileName = pgnFile.getName();
|
||||||
lastModTime = new File(fileName).lastModified();
|
lastModTime = new File(fileName).lastModified();
|
||||||
@ -480,7 +476,7 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setListAdapter(aa);
|
binding.listView.setAdapter(aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFilterString(String s) {
|
private void setFilterString(String s) {
|
||||||
@ -493,7 +489,7 @@ public abstract class EditPGN extends ListActivity {
|
|||||||
!GameAdapter.matchItem(arr.get(itemNo), lastSearchString))
|
!GameAdapter.matchItem(arr.get(itemNo), lastSearchString))
|
||||||
itemNo++;
|
itemNo++;
|
||||||
if (itemNo < arr.size())
|
if (itemNo < arr.size())
|
||||||
getListView().setSelectionFromTop(itemNo, 0);
|
binding.listView.setSelectionFromTop(itemNo, 0);
|
||||||
};
|
};
|
||||||
aa.getFilter().filter(s, listener);
|
aa.getFilter().filter(s, listener);
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,11 @@
|
|||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:hint="@string/filter_text"
|
android:hint="@string/filter_text"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:maxLines="1" />
|
android:maxLines="1"
|
||||||
|
android:importantForAutofill="no" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@android:id/list"
|
android:id="@+id/list_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:focusable="false" />
|
android:focusable="false" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user