fixed main activiy title and home button
This commit is contained in:
@@ -55,6 +55,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Intent intent = new Intent(this, PreferenceActivity.class);
|
Intent intent = new Intent(this, PreferenceActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
} else if(item.getItemId() == android.R.id.home) {
|
||||||
|
onBackPressed();
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@@ -67,13 +69,19 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.addToBackStack(NotificationCreationFragment.class.getSimpleName())
|
.addToBackStack(NotificationCreationFragment.class.getSimpleName())
|
||||||
.commit();
|
.commit();
|
||||||
mFAB.setVisibility(View.GONE);
|
mFAB.setVisibility(View.GONE);
|
||||||
|
getSupportActionBar().setTitle(getString(R.string.title_create_notification));
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
// make fab visible if we come back to first fragment
|
// make fab visible and change title if we come back to first fragment
|
||||||
if(getSupportFragmentManager().getBackStackEntryCount() == 1)
|
if(getSupportFragmentManager().getBackStackEntryCount() == 1) {
|
||||||
mFAB.setVisibility(View.VISIBLE);
|
mFAB.setVisibility(View.VISIBLE);
|
||||||
|
getSupportActionBar().setTitle(getString(R.string.app_name));
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
}
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package net.headlezz.notificationlogger;
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -22,10 +20,4 @@ public class NotificationCreationFragment extends Fragment {
|
|||||||
return textView;
|
return textView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
((AppCompatActivity) activity).getSupportActionBar().setTitle(getString(R.string.title_create_notification));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package net.headlezz.notificationlogger;
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -22,10 +20,4 @@ public class NotificationListFragment extends Fragment {
|
|||||||
return textView;
|
return textView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
((AppCompatActivity) activity).getSupportActionBar().setTitle(getString(R.string.app_name));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user