Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
vvasuki committed Mar 31, 2017
1 parent 864254f commit 38780c6
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified app/app-release.apk
Binary file not shown.
2 changes: 2 additions & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
Expand All @@ -99,6 +100,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
applicationId "sanskritcode.sanskritdictionaryupdater"
minSdkVersion 17
targetSdkVersion 21
versionCode 20
targetSdkVersion 20
versionCode 21
versionName "2.9"
multiDexEnabled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ProgressBar;
import android.widget.TextView;

Expand Down Expand Up @@ -42,17 +42,18 @@ public class GetDictionariesActivity extends Activity {
private List<String> dictFiles = new ArrayList<String>();
private List<Boolean> dictFailure = new ArrayList<Boolean>();

private TextView topText;
private Button button;
private ProgressBar progressBar;
static private List<CheckBox> checkBoxes = new ArrayList<CheckBox>();
static private TextView topText;
static private Button button;
static private ProgressBar progressBar;

private File sdcard;
private File downloadsDir;
private File dictDir;
private boolean allDone = false;

SharedPreferences sharedDictVersionStore;
SharedPreferences.Editor dictVersionEditor;
static SharedPreferences sharedDictVersionStore;
static SharedPreferences.Editor dictVersionEditor;

public static String[] getDictNameAndVersion(String fileName) {
// handle filenames of the type: kRdanta-rUpa-mAlA__2016-02-20_23-22-27.tar.gz
Expand All @@ -63,15 +64,15 @@ public static String[] getDictNameAndVersion(String fileName) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharedDictVersionStore = getSharedPreferences(
sharedDictVersionStore = getSharedPreferences(
getString(R.string.dict_version_store), Context.MODE_PRIVATE);
dictVersionEditor = sharedDictVersionStore.edit();
allDone = false;
setContentView(R.layout.activity_get_dictionaries);
topText = (TextView) findViewById(R.id.textView);
button = (Button) findViewById(R.id.button);
button.setText(getString(R.string.buttonWorking));
button.setEnabled(false);
button.setClickable(false);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
dictionariesSelectedLst.addAll(dictionariesSelected);
dictFailure = new ArrayList<Boolean>(Collections.nCopies(dictionariesSelectedLst.size(), false));
Expand All @@ -91,19 +92,15 @@ protected void onCreate(Bundle savedInstanceState) {
}

public void buttonPressed1(View v) {
Button button = (Button) findViewById(R.id.button);
button.setText(getString(R.string.buttonWorking));
button.setEnabled(false);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}

protected void getDictionaries(int index) {
if (dictionariesSelectedLst.size() == 0) {
topText.setText("No dictionaries selected!");
topText.append(getString(R.string.txtTryAgain));
button.setText(R.string.proceed_button);
button.setEnabled(true);
button.setClickable(true);
} else {
if (index >= dictionariesSelectedLst.size()) {
extractDicts(0);
Expand Down Expand Up @@ -140,13 +137,12 @@ public String apply(String in) {
}
if (successes.length() > 0) topText.append("\n" + "Succeeded on:" + successes);

button.setEnabled(true);
button.setClickable(true);
button.setText(R.string.buttonValQuit);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finishAffinity();
System.exit(0);
}
});
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ public class GetUrlActivity extends Activity {
private static final String DICTIONARY_LOCATION = "dict";
private static final String DOWNLOAD_LOCATION = "dict";

private TextView topText;
private Button button;
static private TextView topText;
static private Button button;
static private List<CheckBox> checkBoxes = new ArrayList<CheckBox>();

SharedPreferences sharedDictVersionStore;
private List<CheckBox> checkBoxes = new ArrayList<CheckBox>();

public static HashSet<String> dictionariesSelected = new HashSet<String>();
CompoundButton.OnCheckedChangeListener checkboxListener = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
dictionariesSelected.add(buttonView.getHint().toString());
} else {
dictionariesSelected.remove(buttonView.getHint().toString());
}
button.setEnabled(dictionariesSelected.size() > 0);
if (isChecked) {
dictionariesSelected.add(buttonView.getHint().toString());
} else {
dictionariesSelected.remove(buttonView.getHint().toString());
}
button.setClickable(!dictionariesSelected.isEmpty());
Log.d(ACTIVITY_NAME, "button enablement " + button.isClickable());
}
};

Expand All @@ -62,7 +63,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(getLocalClassName(), "whenActivityLoaded indexedDicts " + indexedDicts);

sharedDictVersionStore = getSharedPreferences(
sharedDictVersionStore = getSharedPreferences(
getString(R.string.dict_version_store), Context.MODE_PRIVATE);

indexesSelected = MainActivity.indexesSelected;
Expand All @@ -72,20 +73,13 @@ protected void onCreate(Bundle savedInstanceState) {
topText = (TextView) findViewById(R.id.textView);
button = (Button) findViewById(R.id.button);
button.setText(getString(R.string.buttonWorking));
button.setEnabled(false);
button.setClickable(false);

setContentView(R.layout.activity_get_url);
DictUrlGetter dictUrlGetter = new DictUrlGetter();
dictUrlGetter.execute(indexesSelected.keySet().toArray(new String[0]));
}

@Override
protected void onRestart() {
super.onRestart();
button.setText(getString(R.string.proceed_button));
button.setEnabled(true);
}

public void buttonPressed1(View v) {
Button button = (Button) findViewById(R.id.button);
Intent intent = new Intent(this, GetDictionariesActivity.class);
Expand All @@ -95,14 +89,14 @@ public void buttonPressed1(View v) {
protected void selectCheckboxes() {
boolean currentVersionsKnown = (sharedDictVersionStore.getAll().size() > 0);
int autoUnselectedDicts = 0;
for(CheckBox cb : checkBoxes) {
for (CheckBox cb : checkBoxes) {
// handle values: kRdanta-rUpa-mAlA -> 2016-02-20_23-22-27
String filename = cb.getHint().toString();
boolean proposedVersionNewer = true;

String[] dictnameParts = GetDictionariesActivity.getDictNameAndVersion(filename);
String dictname = dictnameParts[0];
if(dictnameParts.length > 1) {
if (dictnameParts.length > 1) {
String currentVersion = sharedDictVersionStore.getString(dictname, "0000");
String proposedVersion = dictnameParts[1];
proposedVersionNewer = (proposedVersion.compareTo(currentVersion) > 1);
Expand All @@ -111,6 +105,7 @@ protected void selectCheckboxes() {
if (proposedVersionNewer) {
cb.setChecked(true);
} else {
cb.setChecked(false);
autoUnselectedDicts++;
}
}
Expand Down Expand Up @@ -179,7 +174,7 @@ protected void onPostExecute(Integer result) {
text.setText("From " + indexName);
layout.addView(text);

for(String url: indexedDicts.get(indexName)) {
for (String url : indexedDicts.get(indexName)) {
CheckBox cb = new CheckBox(getApplicationContext());
cb.setText(url.replaceAll(".*/", ""));
cb.setHint(url);
Expand All @@ -195,6 +190,7 @@ protected void onPostExecute(Integer result) {
}

}

@Override
public void onBackPressed() {
indexedDicts = new LinkedHashMap<String, List<String>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Flow: MainActivity::OnCreate -> IndexGetter -> (user chooses indices, checkboxListener) -> buttonPressed1 ->
* GetUrlActivity::DictUrlGetter -> (user chooses dictionaries)
* GetDictionariesActivity -> (getDictionaries <-> downloadDict) -> (extractDict <-> DictExtracter)
*
* <p>
* IntraActivity lifecycle looks like this: http://stackoverflow.com/questions/6509791/onrestart-vs-onresume-android-lifecycle-question
*/
public class MainActivity extends Activity {
Expand All @@ -42,9 +42,9 @@ public class MainActivity extends Activity {
public static Map<String, String> indexUrls = new LinkedHashMap<String, String>();
public static Map<String, String> indexesSelected = new LinkedHashMap<String, String>();

private TextView topText;
private Button button;
private List<CheckBox> checkBoxes = new ArrayList<CheckBox>();
static private TextView topText;
static private Button button;
static private List<CheckBox> checkBoxes = new ArrayList<CheckBox>();

CompoundButton.OnCheckedChangeListener checkboxListener = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Expand All @@ -53,14 +53,15 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
} else {
indexesSelected.remove(buttonView.getText().toString());
}
button.setClickable(!indexesSelected.isEmpty());
}
};

private void addCheckboxes() {
// retainOnlyOneDictForDebugging();
checkBoxes = new ArrayList<CheckBox>();
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
for (String name: indexUrls.keySet()) {
for (String name : indexUrls.keySet()) {
CheckBox cb = new CheckBox(getApplicationContext());
cb.setText(name);
cb.setHint(indexUrls.get(name));
Expand All @@ -69,7 +70,7 @@ private void addCheckboxes() {
layout.addView(cb, layout.getChildCount());
checkBoxes.add(cb);
}
for(CheckBox checkBox : checkBoxes) {
for (CheckBox checkBox : checkBoxes) {
if (indexesSelected.keySet().contains(checkBox.getText())) {
checkBox.setChecked(true);
} else {
Expand All @@ -78,7 +79,6 @@ private void addCheckboxes() {
}

button.setText(getString(R.string.proceed_button));
button.setEnabled(true);
// getDictionaries(0);

}
Expand All @@ -95,9 +95,9 @@ protected void onCreate(Bundle savedInstanceState) {

button = (Button) findViewById(R.id.button);
button.setText(getString(R.string.buttonWorking));
button.setEnabled(false);
button.setClickable(false);

if(indexUrls.size() == 0) {
if (indexUrls.size() == 0) {
MainActivity.IndexGetter indexGetter = new MainActivity.IndexGetter();
indexGetter.execute(index_indexorum);
} else {
Expand All @@ -115,7 +115,7 @@ protected void onStart() {
protected void onResume() {
super.onResume();
button.setText(R.string.proceed_button);
button.setEnabled(true);
button.setClickable(true);
Log.d(MAIN_ACTIVITY, "onResume Indices selected " + indexesSelected.toString());
}

Expand All @@ -130,7 +130,7 @@ protected class IndexGetter extends AsyncTask<String, Integer, Integer> {
private final String INDEX_GETTER = MainActivity.IndexGetter.class.getName();

@Override
public Integer doInBackground(String ... params) {
public Integer doInBackground(String... params) {
String indexList = params[0];
Log.i(INDEX_GETTER, indexList);
try {
Expand Down

0 comments on commit 38780c6

Please sign in to comment.