Skip to content

Commit

Permalink
Added back button navigation to all activities
Browse files Browse the repository at this point in the history
- Commented the log info messages
- Added setTitle to the activity name
- Added german version for the string name chooser_title
  • Loading branch information
akarsh committed Jan 18, 2019
1 parent 3ddad88 commit 91b49cc
Show file tree
Hide file tree
Showing 19 changed files with 348 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sakarsh.akarshseggemuresume;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;

import com.google.gson.Gson;
Expand All @@ -28,5 +30,27 @@ protected void onCreate(Bundle savedInstanceState) {
AwardsListAdapter awardsListAdapter = new AwardsListAdapter(this, awardsArrayList);
listView = findViewById(R.id.listView);
listView.setAdapter(awardsListAdapter);

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.awards);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public boolean isEmulator() {
deviceInfo.append("Build.DEVICE " + Build.DEVICE + "\n");
String info = deviceInfo.toString();


Log.i("CheckEmulator", info);

// Log.i("CheckEmulator", info);

Boolean isvm = false;
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -54,6 +55,28 @@ protected void onCreate(Bundle savedInstanceState) {
imageURL = getIntent().getStringExtra("imageURL");

openFileFromStorage();

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.contact);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

private void openFileFromStorage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ protected Void doInBackground(Void... arg0) {
File externalStorage = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/" + downloadDirectory);
if (!externalStorage.exists()) {
externalStorage.mkdirs();
Log.i(TAG, downloadDirectory + " directory is created");
// Log.i(TAG, downloadDirectory + " directory is created");
File outputFile = new File(externalStorage, downloadFileName);
Log.i(TAG, outputFile + " file path");
// Log.i(TAG, outputFile + " file path");
if (!outputFile.exists()) {
outputFile.createNewFile();
Log.i(TAG, downloadFileName + " file is created");
// Log.i(TAG, downloadFileName + " file is created");
}

FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
InputStream inputStream = httpsURLConnection.getInputStream();
Bitmap bitmap = null;
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
Log.i(TAG, downloadFileName + " file has been written");
// Log.i(TAG, downloadFileName + " file has been written");
fileOutputStream.close();
inputStream.close();
}
Expand All @@ -89,7 +89,7 @@ private void downloadInInternalStorage(HttpsURLConnection httpsURLConnection) {
InputStream inputStream = httpsURLConnection.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
Log.i(TAG, downloadFileName + " file has been written");
// Log.i(TAG, downloadFileName + " file has been written");
fileOutputStream.close();
inputStream.close();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ protected Void doInBackground(Void... arg0) {
File externalStorage = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/" + downloadDirectory);
if (!externalStorage.exists()) {
externalStorage.mkdirs();
Log.i(TAG, downloadDirectory + " directory is created");
// Log.i(TAG, downloadDirectory + " directory is created");
File outputFile = new File(externalStorage, downloadFileName);
Log.i(TAG, outputFile + " file path");
// Log.i(TAG, outputFile + " file path");
if (!outputFile.exists()) {
outputFile.createNewFile();
Log.i(TAG, downloadFileName + " file is created");
// Log.i(TAG, downloadFileName + " file is created");
}

FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
Expand All @@ -78,7 +78,7 @@ protected Void doInBackground(Void... arg0) {
while ((initialLength = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, initialLength);
}
Log.i(TAG, downloadFileName + " file has been written");
// Log.i(TAG, downloadFileName + " file has been written");
fileOutputStream.close();
inputStream.close();
}
Expand All @@ -103,7 +103,7 @@ private void downloadInInternalStorage(HttpsURLConnection httpsURLConnection) {
while ((initialLength = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, initialLength);
}
Log.i(TAG, downloadFileName + " file has been written");
// Log.i(TAG, downloadFileName + " file has been written");
fileOutputStream.close();
inputStream.close();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sakarsh.akarshseggemuresume;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;

import com.google.gson.Gson;
Expand All @@ -28,5 +30,27 @@ protected void onCreate(Bundle savedInstanceState) {
EducationListAdapter educationListAdapter = new EducationListAdapter(this, educationArrayList);
listView = findViewById(R.id.listView);
listView.setAdapter(educationListAdapter);

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.education);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sakarsh.akarshseggemuresume;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;

import com.google.gson.Gson;
Expand All @@ -28,5 +30,27 @@ protected void onCreate(Bundle savedInstanceState) {
ExperienceListAdapter experienceListAdapter = new ExperienceListAdapter(this, experienceArrayList);
listView = findViewById(R.id.listView);
listView.setAdapter(experienceListAdapter);

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.experience);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

Expand Down Expand Up @@ -38,10 +40,29 @@ protected void onCreate(Bundle savedInstanceState) {
} else {
textViewPlaceOfBirth.setVisibility(View.GONE);
}

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.info);
// Log.i("Info", "Locale: "+getResources().getConfiguration().locale);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sakarsh.akarshseggemuresume;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;

import com.google.gson.Gson;
Expand All @@ -28,5 +30,27 @@ protected void onCreate(Bundle savedInstanceState) {
InterestsListAdapter interestsListAdapter = new InterestsListAdapter(this, interestArrayList);
listView = findViewById(R.id.listView);
listView.setAdapter(interestsListAdapter);

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.interests);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sakarsh.akarshseggemuresume;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;

import com.google.gson.Gson;
Expand All @@ -28,5 +30,27 @@ protected void onCreate(Bundle savedInstanceState) {
LanguagesListAdapter languagesListAdapter = new LanguagesListAdapter(this, languagesArrayList);
listView = findViewById(R.id.listView);
listView.setAdapter(languagesListAdapter);

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.languages);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.sakarsh.akarshseggemuresume;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
Expand Down Expand Up @@ -62,5 +64,27 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
startActivity(chooser);
}
});

// activates the back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// setting the title of the action bar
getSupportActionBar().setTitle(R.string.profiles);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// handles the click for back button
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Loading

0 comments on commit 91b49cc

Please sign in to comment.