mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-10 16:02:05 -04:00
Lawn maintenance: removed unused imports, reformatted lines, closed unclosed reading objects (cursor) etc
This commit is contained in:
parent
ee8d8165fd
commit
ae2ffea09c
@ -231,6 +231,7 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
private boolean isFirstRun;
|
private boolean isFirstRun;
|
||||||
|
|
||||||
private SharedPreferences settings;
|
private SharedPreferences settings;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActionModeStarted(ActionMode mode) {
|
public void onActionModeStarted(ActionMode mode) {
|
||||||
if (mActionMode == null) {
|
if (mActionMode == null) {
|
||||||
@ -774,6 +775,8 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
openFullScreen();
|
openFullScreen();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
@ -1256,16 +1259,16 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
if(isOpenNewTabInBackground){
|
if (isOpenNewTabInBackground) {
|
||||||
newTabInBackground(url);
|
newTabInBackground(url);
|
||||||
Snackbar snackbar = Snackbar.make(snackbarLayout, stringsGetter(R.string.new_tab_snackbar) , Snackbar.LENGTH_LONG)
|
Snackbar snackbar = Snackbar.make(snackbarLayout, stringsGetter(R.string.new_tab_snackbar), Snackbar.LENGTH_LONG)
|
||||||
.setAction(stringsGetter(R.string.open), new View.OnClickListener() {
|
.setAction(stringsGetter(R.string.open), new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(mWebViews.size() > 1)
|
if (mWebViews.size() > 1)
|
||||||
selectTab(mWebViews.size() -1);
|
selectTab(mWebViews.size() - 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
snackbar.setActionTextColor(getResources().getColor(R.color.white_undo));
|
snackbar.setActionTextColor(getResources().getColor(R.color.white_undo));
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
} else {
|
} else {
|
||||||
@ -1384,6 +1387,9 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
bookmarks = new ArrayList<>(data.getStringArrayListExtra("bookmarks_array_list"));
|
bookmarks = new ArrayList<>(data.getStringArrayListExtra("bookmarks_array_list"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
@ -1673,7 +1679,7 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private class KiwixWebViewClient extends WebViewClient {
|
private class KiwixWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
HashMap<String, String> documentTypes = new HashMap<String, String>() {{
|
private HashMap<String, String> documentTypes = new HashMap<String, String>() {{
|
||||||
put("epub", "application/epub+zip");
|
put("epub", "application/epub+zip");
|
||||||
put("pdf", "application/pdf");
|
put("pdf", "application/pdf");
|
||||||
}};
|
}};
|
||||||
|
@ -89,12 +89,11 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
+ " where " + CONTACTS_COLUMN_ZIM + " = '" + zimFile + "'", null);
|
+ " where " + CONTACTS_COLUMN_ZIM + " = '" + zimFile + "'", null);
|
||||||
res.moveToLast();
|
res.moveToLast();
|
||||||
|
|
||||||
while (res.isBeforeFirst() == false) {
|
while (!res.isBeforeFirst()) {
|
||||||
array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_SEARCH)));
|
array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_SEARCH)));
|
||||||
res.moveToPrevious();
|
res.moveToPrevious();
|
||||||
}
|
}
|
||||||
|
res.close();
|
||||||
|
|
||||||
return array_list;
|
return array_list;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,30 +2,28 @@ package org.kiwix.kiwixmobile.utils.files;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.KiwixMobileActivity;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class FileReader {
|
public class FileReader {
|
||||||
|
|
||||||
public String readFile(String filePath , Context context){
|
public String readFile(String filePath, Context context) {
|
||||||
try {
|
try {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
InputStream json = context.getAssets().open(filePath);
|
InputStream json = context.getAssets().open(filePath);
|
||||||
BufferedReader in =
|
BufferedReader in =
|
||||||
new BufferedReader(new InputStreamReader(json, "UTF-8"));
|
new BufferedReader(new InputStreamReader(json, "UTF-8"));
|
||||||
String str;
|
String str;
|
||||||
|
|
||||||
while ((str = in.readLine()) != null) {
|
while ((str = in.readLine()) != null) {
|
||||||
buf.append(str);
|
buf.append(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
in.close();
|
in.close();
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
return "";
|
return "";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,34 +6,37 @@ import android.content.SharedPreferences;
|
|||||||
|
|
||||||
public class RateAppCounter {
|
public class RateAppCounter {
|
||||||
|
|
||||||
String MASTER_NAME = "visitCounter";
|
private String MASTER_NAME = "visitCounter";
|
||||||
String NOTHANKS_CLICKED = "clickedNoThanks";
|
private String NOTHANKS_CLICKED = "clickedNoThanks";
|
||||||
SharedPreferences visitCounter;
|
private SharedPreferences visitCounter;
|
||||||
|
|
||||||
public RateAppCounter(Context context) {
|
public RateAppCounter(Context context) {
|
||||||
visitCounter = context.getSharedPreferences(MASTER_NAME, 0);
|
visitCounter = context.getSharedPreferences(MASTER_NAME, 0);
|
||||||
visitCounter = context.getSharedPreferences(NOTHANKS_CLICKED,0);
|
visitCounter = context.getSharedPreferences(NOTHANKS_CLICKED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getNoThanksState(){
|
public boolean getNoThanksState() {
|
||||||
return visitCounter.getBoolean(NOTHANKS_CLICKED, false);
|
return visitCounter.getBoolean(NOTHANKS_CLICKED, false);
|
||||||
}
|
}
|
||||||
public void setNoThanksState(boolean val){
|
|
||||||
|
public void setNoThanksState(boolean val) {
|
||||||
SharedPreferences.Editor CounterEditor = visitCounter.edit();
|
SharedPreferences.Editor CounterEditor = visitCounter.edit();
|
||||||
CounterEditor.putBoolean(NOTHANKS_CLICKED, val);
|
CounterEditor.putBoolean(NOTHANKS_CLICKED, val);
|
||||||
CounterEditor.commit();
|
CounterEditor.commit();
|
||||||
}
|
}
|
||||||
public void setCount(int count) {
|
|
||||||
SharedPreferences.Editor CounterEditor = visitCounter.edit();
|
|
||||||
CounterEditor.putInt("count", count);
|
|
||||||
CounterEditor.commit();
|
|
||||||
|
|
||||||
}
|
public SharedPreferences.Editor getEditor() {
|
||||||
public SharedPreferences.Editor getEditor(){
|
|
||||||
return visitCounter.edit();
|
return visitCounter.edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return visitCounter.getInt("count", 0);
|
return visitCounter.getInt("count", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCount(int count) {
|
||||||
|
SharedPreferences.Editor CounterEditor = visitCounter.edit();
|
||||||
|
CounterEditor.putInt("count", count);
|
||||||
|
CounterEditor.commit();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,7 @@ import android.widget.TextView;
|
|||||||
import org.kiwix.kiwixmobile.JNIKiwix;
|
import org.kiwix.kiwixmobile.JNIKiwix;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.kiwix.kiwixmobile.ZimContentProvider;
|
import org.kiwix.kiwixmobile.ZimContentProvider;
|
||||||
|
|
||||||
|
@ -18,13 +18,15 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.R;
|
import org.kiwix.kiwixmobile.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class BookmarksActivity extends AppCompatActivity
|
public class BookmarksActivity extends AppCompatActivity
|
||||||
implements AdapterView.OnItemClickListener {
|
implements AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
SparseBooleanArray sparseBooleanArray;
|
private SparseBooleanArray sparseBooleanArray;
|
||||||
private ArrayList<String> contents;
|
private ArrayList<String> contents;
|
||||||
private ArrayList<String> tempContents;
|
private ArrayList<String> tempContents;
|
||||||
private ListView bookmarksList;
|
private ListView bookmarksList;
|
||||||
@ -62,10 +64,9 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
} else if (selected.contains(contents.get(position))) {
|
} else if (selected.contains(contents.get(position))) {
|
||||||
selected.remove(contents.get(position));
|
selected.remove(contents.get(position));
|
||||||
numOfSelected--;
|
numOfSelected--;
|
||||||
if(numOfSelected == 0){
|
if (numOfSelected == 0) {
|
||||||
mode.finish();
|
mode.finish();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mode.setTitle(Integer.toString(numOfSelected));
|
mode.setTitle(Integer.toString(numOfSelected));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +181,7 @@ public class BookmarksActivity extends AppCompatActivity
|
|||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String stringsGetter(int strId){
|
public String stringsGetter(int strId) {
|
||||||
return getResources().getString(strId);
|
return getResources().getString(strId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,14 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.kiwix.kiwixmobile.R;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import org.kiwix.kiwixmobile.R;
|
|
||||||
|
|
||||||
public class KiwixWebView extends WebView {
|
public class KiwixWebView extends WebView {
|
||||||
|
|
||||||
@ -170,7 +172,7 @@ public class KiwixWebView extends WebView {
|
|||||||
|| result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
|
|| result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
|
||||||
MenuItem saveMenu = menu.add(0, 1, 0, getResources().getString(R.string.save_media));
|
MenuItem saveMenu = menu.add(0, 1, 0, getResources().getString(R.string.save_media));
|
||||||
saveMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
saveMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
public boolean onMenuItemClick(android.view.MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
Message msg = saveHandler.obtainMessage();
|
Message msg = saveHandler.obtainMessage();
|
||||||
requestFocusNodeHref(msg);
|
requestFocusNodeHref(msg);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user