Browse Source

Navigation fixes

pull/61/merge
Ezerous 6 years ago
parent
commit
c5442218f0
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 4
      app/src/main/AndroidManifest.xml
  2. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java
  4. 33
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

4
app/src/main/AndroidManifest.xml

@ -113,11 +113,12 @@
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" /> android:value=".activities.upload.UploadActivity" />
</activity> </activity>
<activity <activity
android:name=".activities.bookmarks.BookmarkActivity" android:name=".activities.bookmarks.BookmarkActivity"
android:parentActivityName=".activities.main.MainActivity" android:parentActivityName=".activities.main.MainActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
@ -126,6 +127,7 @@
<activity <activity
android:name=".activities.settings.SettingsActivity" android:name=".activities.settings.SettingsActivity"
android:parentActivityName=".activities.main.MainActivity" android:parentActivityName=".activities.main.MainActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.PreferenceTheme"> android:theme="@style/AppTheme.PreferenceTheme">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"

12
app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java

@ -3,8 +3,10 @@ package gr.thmmy.mthmmy.activities;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.preference.PreferenceManager; import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.AppCompatButton; import android.support.v7.widget.AppCompatButton;
import android.view.ActionMode;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
@ -77,9 +79,7 @@ public class LoginActivity extends BaseActivity {
}); });
//Guest Button Action //Guest Button Action
btnGuest.setOnClickListener(new View.OnClickListener() { btnGuest.setOnClickListener(view -> {
public void onClick(View view) {
//Session data update //Session data update
sessionManager.guestLogin(); sessionManager.guestLogin();
@ -88,17 +88,17 @@ public class LoginActivity extends BaseActivity {
startActivity(intent); startActivity(intent);
finish(); finish();
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
}
}); });
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
// Disable going back to the MainActivity super.onBackPressed();
moveTaskToBack(true);
if (loginTask != null && loginTask.getStatus() == AsyncTask.Status.RUNNING) { if (loginTask != null && loginTask.getStatus() == AsyncTask.Status.RUNNING) {
loginTask.cancel(true); loginTask.cancel(true);
} }
if(!isTaskRoot())
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
} }
private void onLoginFailed() { private void onLoginFailed() {

2
app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java

@ -32,8 +32,6 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
private static final String SELECTED_NOTIFICATIONS_SOUND = "pref_notifications_select_sound_key"; private static final String SELECTED_NOTIFICATIONS_SOUND = "pref_notifications_select_sound_key";
private static final String POSTING_CATEGORY = "pref_category_posting_key"; private static final String POSTING_CATEGORY = "pref_category_posting_key";
private static final String UPLOADING_CATEGORY = "pref_category_uploading_key"; private static final String UPLOADING_CATEGORY = "pref_category_uploading_key";
public static final String PRIVACY_CRASHLYTICS_ENABLE_KEY = "pref_privacy_crashlytics_enable_key";
public static final String PRIVACY_ANALYTICS_ENABLE_KEY = "pref_privacy_analytics_enable_key";
//SharedPreferences keys //SharedPreferences keys
private static final int REQUEST_CODE_ALERT_RINGTONE = 2; private static final int REQUEST_CODE_ALERT_RINGTONE = 2;

33
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -35,8 +35,6 @@ import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder; import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -329,9 +327,7 @@ public abstract class BaseActivity extends AppCompatActivity {
.withDrawerWidthDp((int) BaseApplication.getInstance().getDpWidth() / 2) .withDrawerWidthDp((int) BaseApplication.getInstance().getDpWidth() / 2)
.withSliderBackgroundColor(ContextCompat.getColor(this, R.color.primary_light)) .withSliderBackgroundColor(ContextCompat.getColor(this, R.color.primary_light))
.withAccountHeader(accountHeader) .withAccountHeader(accountHeader)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { .withOnDrawerItemClickListener((view, position, drawerItem) -> {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem.equals(HOME_ID)) { if (drawerItem.equals(HOME_ID)) {
if (!(BaseActivity.this instanceof MainActivity)) { if (!(BaseActivity.this instanceof MainActivity)) {
Intent intent = new Intent(BaseActivity.this, MainActivity.class); Intent intent = new Intent(BaseActivity.this, MainActivity.class);
@ -354,6 +350,7 @@ public abstract class BaseActivity extends AppCompatActivity {
} else if (drawerItem.equals(BOOKMARKS_ID)) { } else if (drawerItem.equals(BOOKMARKS_ID)) {
if (!(BaseActivity.this instanceof BookmarkActivity)) { if (!(BaseActivity.this instanceof BookmarkActivity)) {
Intent intent = new Intent(BaseActivity.this, BookmarkActivity.class); Intent intent = new Intent(BaseActivity.this, BookmarkActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent); startActivity(intent);
} }
} else if (drawerItem.equals(LOG_ID)) { } else if (drawerItem.equals(LOG_ID)) {
@ -364,18 +361,19 @@ public abstract class BaseActivity extends AppCompatActivity {
} else if (drawerItem.equals(ABOUT_ID)) { } else if (drawerItem.equals(ABOUT_ID)) {
if (!(BaseActivity.this instanceof AboutActivity)) { if (!(BaseActivity.this instanceof AboutActivity)) {
Intent intent = new Intent(BaseActivity.this, AboutActivity.class); Intent intent = new Intent(BaseActivity.this, AboutActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent); startActivity(intent);
} }
} else if (drawerItem.equals(SETTINGS_ID)) { } else if (drawerItem.equals(SETTINGS_ID)) {
if (!(BaseActivity.this instanceof SettingsActivity)) { if (!(BaseActivity.this instanceof SettingsActivity)) {
Intent intent = new Intent(BaseActivity.this, SettingsActivity.class); Intent intent = new Intent(BaseActivity.this, SettingsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent); startActivity(intent);
} }
} }
drawer.closeDrawer(); drawer.closeDrawer();
return true; return true;
}
}); });
if (sessionManager.isLoggedIn()) if (sessionManager.isLoggedIn())
@ -388,12 +386,9 @@ public abstract class BaseActivity extends AppCompatActivity {
if (!(BaseActivity.this instanceof MainActivity)) if (!(BaseActivity.this instanceof MainActivity))
drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false); drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);
drawer.setOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() { drawer.setOnDrawerNavigationListener(clickedView -> {
@Override
public boolean onNavigationClickListener(View clickedView) {
onBackPressed(); onBackPressed();
return true; return true;
}
}); });
} }
@ -696,15 +691,8 @@ public abstract class BaseActivity extends AppCompatActivity {
Button cancelButton = view.findViewById(R.id.cancel); Button cancelButton = view.findViewById(R.id.cancel);
Button openButton = view.findViewById(R.id.open); Button openButton = view.findViewById(R.id.open);
Button downloadButton = view.findViewById(R.id.download); Button downloadButton = view.findViewById(R.id.download);
cancelButton.setOnClickListener(new View.OnClickListener() { cancelButton.setOnClickListener(v -> dialog.dismiss());
@Override openButton.setOnClickListener(v -> {
public void onClick(View v) {
dialog.dismiss();
}
});
openButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss(); dialog.dismiss();
try { try {
String fileName = thmmyFile.getFilename(); String fileName = thmmyFile.getFilename();
@ -718,14 +706,10 @@ public abstract class BaseActivity extends AppCompatActivity {
Toast.makeText(getBaseContext(), "Couldn't open file...", Toast.LENGTH_SHORT).show(); Toast.makeText(getBaseContext(), "Couldn't open file...", Toast.LENGTH_SHORT).show();
} }
}
}); });
downloadButton.setOnClickListener(new View.OnClickListener() { downloadButton.setOnClickListener(v -> {
@Override
public void onClick(View v) {
dialog.dismiss(); dialog.dismiss();
DownloadHelper.enqueueDownload(thmmyFile); DownloadHelper.enqueueDownload(thmmyFile);
}
}); });
dialog.show(); dialog.show();
} }
@ -738,7 +722,6 @@ public abstract class BaseActivity extends AppCompatActivity {
private void startLoginActivity(){ private void startLoginActivity(){
Intent intent = new Intent(BaseActivity.this, LoginActivity.class); Intent intent = new Intent(BaseActivity.this, LoginActivity.class);
startActivity(intent); startActivity(intent);
finish();
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
} }
} }

Loading…
Cancel
Save