Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.kkontagion.flipmenu","split":"","minSdkVersion":"23"}}]
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:label="@string/title_activity_settings" />
<activity
android:name=".ConfirmActivity"
android:label="@string/title_activity_menu"
android:label="@string/title_activity_confirm"
android:parentActivityName=".MainActivity" />

<provider
Expand Down Expand Up @@ -59,10 +59,14 @@
</activity>
<activity
android:name=".HistoryActivity"
android:label="@string/title_activity_history"
android:parentActivityName=".MainActivity" />
<activity android:name=".SeeItemActivity"></activity>
<activity android:name=".SeeItemActivity"
android:label="@string/title_activity_see"
android:parentActivityName=".OrderActivity" />
<activity
android:name=".howtouse_Activity"
android:label="@string/title_activity_usage"
android:parentActivityName=".MainActivity" />

</application>
Expand Down
30 changes: 23 additions & 7 deletions app/src/main/java/com/kkontagion/flipmenu/ConfirmActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ public class ConfirmActivity extends AppCompatActivity {
ArrayAdapter<CharSequence> adapter;
Uri imageUri;
Boolean isEmpty = false;
String chosenLang, filename,status,message = "";
String chosenLang, filename,status,message = "", spName;
AlertDialog.Builder builder;
RelativeLayout rlLoading;
EditText etLocation;

boolean fromHistory = false;
HistoryItem hItem = null;


@Override
Expand Down Expand Up @@ -120,11 +121,16 @@ protected void onCreate(Bundle savedInstanceState) {

filename = getIntent().getStringExtra("filepath");
imageUri = Uri.fromFile(new File(filename));
spName = imageUri.getLastPathSegment().split("\\.")[0];

fromHistory = getIntent().getBooleanExtra("fromHistory", false);
if (fromHistory) {
this.hItem = getIntent().getParcelableExtra("historyItem");
if (hItem.getLocation().equalsIgnoreCase(getString(R.string.history_location)))
etLocation.setHint(hItem.getLocation());
else
etLocation.setText(hItem.getLocation());
Glide.with(this).load(new File(filename)).into(imgPreview);
HistoryItem hItem = getIntent().getParcelableExtra("historyItem");
this.message = hItem.getFullText();
this.jsonTextDetect = hItem.getJsonData().toString();
formatDetectedText();
Expand All @@ -146,11 +152,18 @@ public void onClick(View view) {
// Show progressbar
tvLoading.setText(R.string.progress_translate);
rlLoading.setVisibility(View.VISIBLE);
etLocation.setEnabled(false);

// Select Language
chosenLang = getResources().getStringArray(R.array.list_preference_language_values)[spinner.getSelectedItemPosition()];
Log.d(getClass().getSimpleName(), "onClick: " + chosenLang);

String loc = etLocation.getText().toString();
Log.d(getClass().getSimpleName(), "onClick: Saving updated location.");
getSharedPreferences(spName, MODE_PRIVATE).edit()
.putString("location", (loc.length() > 0 ? loc : getString(R.string.history_location)))
.apply();

translateText(transHolder);
}
});
Expand Down Expand Up @@ -458,14 +471,17 @@ public void onFinish() {
rlLoading.setVisibility(View.GONE);
statusText.setText(status);

// get location
String loc = etLocation.getText().toString();

Log.d(getClass().getSimpleName(), "onFinish: from history? " + fromHistory);

if (!fromHistory) {
// get location
String loc = etLocation.getText().toString();
// save data
String fname = imageUri.getLastPathSegment().split("\\.")[0];
SharedPreferences.Editor spE = getSharedPreferences(fname, MODE_PRIVATE).edit();

SharedPreferences.Editor spE = getSharedPreferences(spName, MODE_PRIVATE).edit();
spE.putString("jsondata", jsonTextDetect)
.putString("location", (loc.length() > 0 ? loc : getString(R.string.history_location))) // TODO get location
.putString("location", (loc.length() > 0 ? loc : getString(R.string.history_location)))
.putLong("datetime", Calendar.getInstance().getTimeInMillis())
.apply();
}
Expand Down
32 changes: 20 additions & 12 deletions app/src/main/java/com/kkontagion/flipmenu/HistoryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.kkontagion.flipmenu.adapters.HistoryAdapter;
import com.kkontagion.flipmenu.objects.HistoryItem;
Expand Down Expand Up @@ -33,16 +35,22 @@ protected void onCreate(Bundle savedInstanceState) {
ArrayList<String> imagesUri = imageRetrieval();
Log.d("penis", imagesUri.toString());


// Kon:
// 1) get SharedPrefs for each image (ref. ConfirmActivity:440), and assign to a HistoryItem with the image
hItems = new ArrayList<>();
for (String name : imagesUri) {
Uri uri = Uri.parse(name);
hItems.add(new HistoryItem(name, getSharedPreferences(uri.getLastPathSegment().split("\\.")[0], MODE_PRIVATE), this));
if (imagesUri.isEmpty()) {
TextView tv = findViewById(R.id.tv_empty);
tv.setVisibility(View.VISIBLE);
} else {
// 1) get SharedPrefs for each image (ref. ConfirmActivity:440), and assign to a HistoryItem with the image
hItems = new ArrayList<>();
for (String name : imagesUri) {
Uri uri = Uri.parse(name);
hItems.add(new HistoryItem(name, getSharedPreferences(uri.getLastPathSegment().split("\\.")[0], MODE_PRIVATE), this));
}
// 2) load into an adapter and display in the RecyclerView with item_history layout.
adapter = new HistoryAdapter(this, hItems);
rv.setAdapter(adapter);
}
// 2) load into an adapter and display in the RecyclerView with item_history layout.
adapter = new HistoryAdapter(this, hItems);
rv.setAdapter(adapter);
}

private ArrayList<String> imageRetrieval() {
Expand All @@ -53,12 +61,12 @@ private ArrayList<String> imageRetrieval() {
{
listFile = file.listFiles();

if (listFile.length > 0) {
for (int i = 0; i < listFile.length; i++) {

for (int i = 0; i < listFile.length; i++)
{

imagesLinks.add(listFile[i].getAbsolutePath());
imagesLinks.add(listFile[i].getAbsolutePath());

}
}
}

Expand Down
31 changes: 23 additions & 8 deletions app/src/main/java/com/kkontagion/flipmenu/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,26 @@ public class MainActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (getIntent().getBooleanExtra("fromHelp", false))
doCamera();

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Button clickButton = (Button) findViewById(R.id.bt_translate);
clickButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
if(CheckingPermissionIsEnabledOrNot())
{
accessCamera();
}
else {
RequestMultiplePermission();
}
doCamera();
}
});
// Kon
Button helpButton = findViewById(R.id.bt_how);
helpButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getBaseContext(), howtouse_Activity.class));
}
});

Expand All @@ -70,6 +76,16 @@ public void onClick(View v) {

}

private void doCamera() {
if(CheckingPermissionIsEnabledOrNot())
{
accessCamera();
}
else {
RequestMultiplePermission();
}
}

private void accessCamera() {
File mainDirectory = new File( Environment.getExternalStorageDirectory() + "/fancaidan");
if (!mainDirectory.exists()) {
Expand Down Expand Up @@ -220,7 +236,6 @@ public boolean onNavigationItemSelected(MenuItem item) {
}
break;
case R.id.nav_history:
// TODO Kon: change to history page
startActivity(new Intent(this, HistoryActivity.class));
break;
case R.id.nav_help:
Expand Down
50 changes: 28 additions & 22 deletions app/src/main/java/com/kkontagion/flipmenu/MenuActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,6 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
this.items = savedInstanceState.getParcelableArrayList("items");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gocart, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.action_cart:
Intent cart = new Intent(this, OrderActivity.class);
// home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
cart.putExtra("items", collateOrders());
startActivityForResult(cart, 200);
return true;
default:
return super.onOptionsItemSelected(item);
}
}

private void setupItems() {
items = new ArrayList<>();

Expand All @@ -122,7 +101,7 @@ private void setupItems() {
Log.d(getClass().getSimpleName(), "setupItems ORIG: " + jsonOrig.toString());


if (textTrans.size() < 2) {
if (textTrans.size() < 1) {
char orig = 'a';
char trans = 'z';
for (int i = 0; i < 26; i++)
Expand Down Expand Up @@ -219,4 +198,31 @@ public void seeBoundingBox(Item item) {
i.putExtra("imgpath", getIntent().getStringExtra("imgpath"));
startActivityForResult(i, 10);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gohome, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_home) {
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(new Intent(this, MainActivity.class));
finish();
return true;
}

return super.onOptionsItemSelected(item);
}
}
25 changes: 23 additions & 2 deletions app/src/main/java/com/kkontagion/flipmenu/OrderActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
Expand All @@ -21,7 +22,7 @@
import java.util.ArrayList;
import java.util.Locale;

public class OrderActivity extends AppCompatActivity {
public class OrderActivity extends AppCompatActivity implements ItemAdapter.OnViewClickListener {

ArrayList<Item> orders;
ItemAdapter adapter;
Expand Down Expand Up @@ -70,7 +71,7 @@ public void onInit(int status) {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getBaseContext(), prepareSpeech(),Toast.LENGTH_SHORT).show();
// Toast.makeText(getBaseContext(), prepareSpeech(),Toast.LENGTH_SHORT).show();
t1.speak(prepareSpeech(),TextToSpeech.QUEUE_FLUSH,null,null);
}
});
Expand Down Expand Up @@ -107,6 +108,15 @@ private String prepareSpeech() {





@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gohome, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
Expand All @@ -115,6 +125,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
setResult(RESULT_CANCELED, prepareBack());
finish();
return true;
case R.id.action_home:
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(new Intent(this, MainActivity.class));
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -145,4 +161,9 @@ private Intent prepareBack() {
newData.putExtra("orders", orders);
return newData;
}

@Override
public void seeBoundingBox(Item item) {
// Empty function
}
}
18 changes: 9 additions & 9 deletions app/src/main/java/com/kkontagion/flipmenu/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ public void onCreate(Bundle savedInstanceState) {
bindPreferenceSummaryToValue(findPreference("pref_language"));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
// if (id == android.R.id.home) {
// startActivity(new Intent(getActivity(), SettingsActivity.class));
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
}
}
Loading