mirror of
https://github.com/gsantner/dandelion
synced 2024-11-21 20:02:07 +01:00
.
This commit is contained in:
parent
586875e32b
commit
a88dc5d13c
3 changed files with 21 additions and 18 deletions
|
@ -71,10 +71,10 @@ import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
|
||||||
import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver;
|
import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver;
|
||||||
import com.github.dfa.diaspora_android.ui.BadgeDrawable;
|
import com.github.dfa.diaspora_android.ui.BadgeDrawable;
|
||||||
import com.github.dfa.diaspora_android.ui.PodSelectionDialog;
|
import com.github.dfa.diaspora_android.ui.PodSelectionDialog;
|
||||||
import com.github.dfa.diaspora_android.ui.theme.CustomFragment;
|
|
||||||
import com.github.dfa.diaspora_android.ui.theme.ThemeHelper;
|
import com.github.dfa.diaspora_android.ui.theme.ThemeHelper;
|
||||||
import com.github.dfa.diaspora_android.ui.theme.ThemedActivity;
|
import com.github.dfa.diaspora_android.ui.theme.ThemedActivity;
|
||||||
import com.github.dfa.diaspora_android.ui.theme.ThemedAlertDialogBuilder;
|
import com.github.dfa.diaspora_android.ui.theme.ThemedAlertDialogBuilder;
|
||||||
|
import com.github.dfa.diaspora_android.ui.theme.ThemedFragment;
|
||||||
import com.github.dfa.diaspora_android.util.ActivityUtils;
|
import com.github.dfa.diaspora_android.util.ActivityUtils;
|
||||||
import com.github.dfa.diaspora_android.util.AndroidBug5497Workaround;
|
import com.github.dfa.diaspora_android.util.AndroidBug5497Workaround;
|
||||||
import com.github.dfa.diaspora_android.util.AppLog;
|
import com.github.dfa.diaspora_android.util.AppLog;
|
||||||
|
@ -199,7 +199,7 @@ public class MainActivity extends ThemedActivity
|
||||||
brOpenExternalLink = new OpenExternalLinkReceiver(this);
|
brOpenExternalLink = new OpenExternalLinkReceiver(this);
|
||||||
brSetTitle = new UpdateTitleReceiver(app, urls, new UpdateTitleReceiver.TitleCallback() {
|
brSetTitle = new UpdateTitleReceiver(app, urls, new UpdateTitleReceiver.TitleCallback() {
|
||||||
public void setTitle(String url, int resId) {
|
public void setTitle(String url, int resId) {
|
||||||
CustomFragment top = getTopFragment();
|
ThemedFragment top = getTopFragment();
|
||||||
if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
||||||
MainActivity.this.setTitle(resId);
|
MainActivity.this.setTitle(resId);
|
||||||
showLastVisitedTimestampMessageIfNeeded(url);
|
showLastVisitedTimestampMessageIfNeeded(url);
|
||||||
|
@ -207,7 +207,7 @@ public class MainActivity extends ThemedActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String url, String title) {
|
public void setTitle(String url, String title) {
|
||||||
CustomFragment top = getTopFragment();
|
ThemedFragment top = getTopFragment();
|
||||||
if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
||||||
MainActivity.this.setTitle(title);
|
MainActivity.this.setTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -292,15 +292,15 @@ public class MainActivity extends ThemedActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an instance of the CustomFragment with the tag fragmentTag.
|
* Get an instance of the ThemedFragment with the tag fragmentTag.
|
||||||
* If there was no instance so far, create a new one and add it to the FragmentManagers pool.
|
* If there was no instance so far, create a new one and add it to the FragmentManagers pool.
|
||||||
* If there is no Fragment with the corresponding Tag, return the top fragment.
|
* If there is no Fragment with the corresponding Tag, return the top fragment.
|
||||||
*
|
*
|
||||||
* @param fragmentTag tag
|
* @param fragmentTag tag
|
||||||
* @return corresponding Fragment
|
* @return corresponding Fragment
|
||||||
*/
|
*/
|
||||||
protected CustomFragment getFragment(String fragmentTag) {
|
protected ThemedFragment getFragment(String fragmentTag) {
|
||||||
CustomFragment fragment = (CustomFragment) fm.findFragmentByTag(fragmentTag);
|
ThemedFragment fragment = (ThemedFragment) fm.findFragmentByTag(fragmentTag);
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
return fragment;
|
return fragment;
|
||||||
} else {
|
} else {
|
||||||
|
@ -358,9 +358,9 @@ public class MainActivity extends ThemedActivity
|
||||||
*
|
*
|
||||||
* @param fragment Fragment to show
|
* @param fragment Fragment to show
|
||||||
*/
|
*/
|
||||||
protected void showFragment(CustomFragment fragment) {
|
protected void showFragment(ThemedFragment fragment) {
|
||||||
AppLog.v(this, "showFragment()");
|
AppLog.v(this, "showFragment()");
|
||||||
CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container);
|
ThemedFragment currentTop = (ThemedFragment) fm.findFragmentById(R.id.fragment_container);
|
||||||
if (currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
|
if (currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
|
||||||
AppLog.v(this, "Fragment was not visible. Replace it.");
|
AppLog.v(this, "Fragment was not visible. Replace it.");
|
||||||
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
||||||
|
@ -591,8 +591,8 @@ public class MainActivity extends ThemedActivity
|
||||||
*
|
*
|
||||||
* @return top fragment or null if there is none displayed
|
* @return top fragment or null if there is none displayed
|
||||||
*/
|
*/
|
||||||
private CustomFragment getTopFragment() {
|
private ThemedFragment getTopFragment() {
|
||||||
return (CustomFragment) fm.findFragmentById(R.id.fragment_container);
|
return (ThemedFragment) fm.findFragmentById(R.id.fragment_container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -605,7 +605,7 @@ public class MainActivity extends ThemedActivity
|
||||||
navDrawer.closeDrawer(navView);
|
navDrawer.closeDrawer(navView);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CustomFragment top = getTopFragment();
|
ThemedFragment top = getTopFragment();
|
||||||
if (top != null) {
|
if (top != null) {
|
||||||
AppLog.v(this, "Top Fragment is not null");
|
AppLog.v(this, "Top Fragment is not null");
|
||||||
if (!top.onBackPressed()) {
|
if (!top.onBackPressed()) {
|
||||||
|
@ -683,7 +683,7 @@ public class MainActivity extends ThemedActivity
|
||||||
//Clear the menus
|
//Clear the menus
|
||||||
menu.clear();
|
menu.clear();
|
||||||
|
|
||||||
CustomFragment top = getTopFragment();
|
ThemedFragment top = getTopFragment();
|
||||||
if (top != null) {
|
if (top != null) {
|
||||||
if (!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
if (!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
||||||
cache = _appSettings.isExtendedNotificationsActivated();
|
cache = _appSettings.isExtendedNotificationsActivated();
|
||||||
|
|
|
@ -21,6 +21,8 @@ package com.github.dfa.diaspora_android.ui.theme;
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.util.AppSettings;
|
import com.github.dfa.diaspora_android.util.AppSettings;
|
||||||
|
|
||||||
|
import net.gsantner.opoc.activity.CustomFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment that supports color schemes
|
* Fragment that supports color schemes
|
||||||
* Created by vanitas on 06.10.16.
|
* Created by vanitas on 06.10.16.
|
||||||
|
@ -39,4 +41,9 @@ public abstract class ThemedFragment extends CustomFragment {
|
||||||
ThemeHelper.getInstance(getAppSettings());
|
ThemeHelper.getInstance(getAppSettings());
|
||||||
applyColorToViews();
|
applyColorToViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isAllowedIntellihide() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.github.dfa.diaspora_android.ui.theme;
|
package net.gsantner.opoc.activity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -28,7 +28,7 @@ import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
public abstract class CustomFragment extends Fragment {
|
public abstract class CustomFragment extends Fragment {
|
||||||
|
|
||||||
public static final String TAG = "com.github.dfa.diaspora_android.ui.theme.CustomFragment";
|
public static final String TAG = "net.gsantner.opoc.activity.CustomFragment";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We have an optionsMenu
|
* We have an optionsMenu
|
||||||
|
@ -55,9 +55,5 @@ public abstract class CustomFragment extends Fragment {
|
||||||
* @return did we react to the back press?
|
* @return did we react to the back press?
|
||||||
*/
|
*/
|
||||||
public abstract boolean onBackPressed();
|
public abstract boolean onBackPressed();
|
||||||
|
|
||||||
public boolean isAllowedIntellihide() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue