Commit a8717743 authored by PurkkaKoodari's avatar PurkkaKoodari

Minor improvements

parent 43b1f4ab
......@@ -62,13 +62,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
......@@ -76,6 +69,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
......
......@@ -23,6 +23,7 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import net.pietu1998.wordbasehacker.solver.Game;
......@@ -41,10 +42,10 @@ public class GameListActivity extends AppCompatActivity implements LoaderManager
private ArrayAdapter<Game> adapter;
private final List<Game> games = new ArrayList<>();
private SwipeRefreshLayout swipe = null;
private Snackbar snackbar;
private ListView list;
private TextView listEmpty;
private long lastModified = -1;
@SuppressLint("SdCardPath")
private static final String WORDBASE_DB_PATH = "/data/data/com.wordbaseapp/databases/wordbase.db";
......@@ -71,7 +72,8 @@ public class GameListActivity extends AppCompatActivity implements LoaderManager
actionBar.setTitle(R.string.title_activity_game_list);
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, games);
ListView list = (ListView) findViewById(R.id.list);
listEmpty = (TextView) findViewById(R.id.list_empty);
list = (ListView) findViewById(R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
......@@ -133,33 +135,31 @@ public class GameListActivity extends AppCompatActivity implements LoaderManager
public void onLoadFinished(Loader<LoadResult> loader, LoadResult result) {
swipe.setRefreshing(false);
if (result.message != 0) {
snackbar = Snackbar.make(swipe, result.message, Snackbar.LENGTH_INDEFINITE);
snackbar.show();
adapter.clear();
listEmpty.setText(result.message);
list.setVisibility(View.GONE);
listEmpty.setVisibility(View.VISIBLE);
} else {
boolean dismissSnackbar = true;
if (result.games != null) {
if (snackbar != null)
snackbar.dismiss();
lastModified = result.lastModified;
adapter.clear();
adapter.addAll(result.games);
} else if (result.explicit) {
snackbar = Snackbar.make(swipe, R.string.data_not_changed, Snackbar.LENGTH_LONG);
final Snackbar snackbar = Snackbar.make(swipe, R.string.data_not_changed, Snackbar.LENGTH_LONG);
snackbar.setAction(R.string.open, new View.OnClickListener() {
@Override
public void onClick(View view) {
if (snackbar != null)
snackbar.dismiss();
snackbar.dismiss();
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.wordbaseapp", "com.wordbaseapp.GameMenuActivity"));
startActivity(intent);
}
});
snackbar.show();
dismissSnackbar = false;
}
if (dismissSnackbar && snackbar != null)
snackbar.dismiss();
listEmpty.setText(R.string.no_games);
list.setVisibility(adapter.isEmpty() ? View.GONE : View.VISIBLE);
listEmpty.setVisibility(adapter.isEmpty() ? View.VISIBLE : View.GONE);
}
}
......@@ -202,7 +202,6 @@ public class GameListActivity extends AppCompatActivity implements LoaderManager
unknownOpponent = activity.getResources().getString(R.string.unknown_opponent);
String db = PreferenceManager.getDefaultSharedPreferences(activity).getString(activity.getString(R.string.pref_key_dbpath), "");
inputDb = db.isEmpty() ? WORDBASE_DB_PATH : db;
Log.d("WordbaseHacker", inputDb);
cacheDb = new File(activity.getCacheDir(), "wordbase.db");
this.lastModified = bundle.getLong("lastModified", -1);
this.explicit = bundle.getBoolean("explicit", false);
......@@ -291,7 +290,9 @@ public class GameListActivity extends AppCompatActivity implements LoaderManager
protected void onStartLoading() {
forceLoad();
try {
activityReference.get().swipe.setRefreshing(true);
GameListActivity activity = activityReference.get();
activity.swipe.setRefreshing(true);
activity.listEmpty.setVisibility(View.GONE);
} catch (NullPointerException ignore) {}
}
......
......@@ -107,7 +107,6 @@ public class HudView extends View {
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
Log.d("WordbaseHacker", "Drawing view, resize: " + editMode);
if (editMode) {
canvas.save();
canvas.translate(x, y);
......
......@@ -14,6 +14,7 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;
public class SettingsActivity extends AppCompatActivity {
......@@ -31,7 +32,6 @@ public class SettingsActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.d("WordbaseHacker", "options");
if (item.getItemId() == android.R.id.home) {
setResult(shouldReload);
finish();
......@@ -85,6 +85,7 @@ public class SettingsActivity extends AppCompatActivity {
intent.setComponent(new ComponentName("com.wordbaseapp", "com.wordbaseapp.BoardActivity"));
startActivity(intent);
((HackerApplication) getActivity().getApplication()).editHudSettings();
Toast.makeText(getActivity(), R.string.hud_edit_info, Toast.LENGTH_LONG).show();
return true;
}
});
......
......@@ -11,16 +11,25 @@
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/list"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/list_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/no_games"/>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/list_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="@string/no_games"/>
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
\ No newline at end of file
......@@ -36,13 +36,14 @@
<string name="debug_version">%1$s (debug version)</string>
<string name="bitbucket_url">https://bitbucket.org/Pietu1998/wordbase-hacker</string>
<string name="board_description">Game board</string>
<string name="no_games">No games waiting for your move</string>
<string name="no_games">No games are waiting for your move.</string>
<string name="allow_draw_on_top_title">Permission required</string>
<string name="allow_draw_on_top">In order to assist you in playing the best word, Wordbase Hacker must be allowed to draw on top of Wordbase. Press OK to open settings or Cancel to disable the feature.</string>
<string name="allow_draw_on_top_settings">In order to assist you in playing the best word, Wordbase Hacker must be allowed to draw on top of Wordbase. Press OK to open settings.</string>
<string name="data_not_changed">The database has not changed. Open Wordbase to update it.</string>
<string name="open">Open</string>
<string name="hud_close_info">Press back to return and close HUD.</string>
<string name="hud_edit_info">Press the tick to save, then press back to return.</string>
<!-- Preference keys -->
<string name="pref_key_hud"><xliff:g>hud</xliff:g></string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment