Skip to content

Commit

Permalink
fragments: fix subfragment setTitle()
Browse files Browse the repository at this point in the history
Now the title for subfragments will be set correctly and
changes back to the parentfragment when the back button is
pressed.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
  • Loading branch information
Blechd0se committed Jun 13, 2015
1 parent 8a277cc commit 9523d4a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 36 deletions.
2 changes: 0 additions & 2 deletions AeroControl/src/com/aero/control/fragments/CPUFragment.java
Expand Up @@ -127,7 +127,6 @@ public void run() {
.replace(R.id.content_frame, mHotplugFragment)
.addToBackStack("Hotplug")
.commit();
mHotplugFragment.setTitle();
}
},AeroActivity.genHelper.getDefaultDelay());
return true;
Expand Down Expand Up @@ -157,7 +156,6 @@ public void run() {
.replace(R.id.content_frame, mVoltageFragment)
.addToBackStack("Voltage")
.commit();
mVoltageFragment.setTitle();
}
},AeroActivity.genHelper.getDefaultDelay());
return true;
Expand Down
@@ -1,5 +1,6 @@
package com.aero.control.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
Expand All @@ -19,7 +20,6 @@ public class CPUHotplugFragment extends PlaceHolderFragment {

private PreferenceScreen root;
private PreferenceCategory PrefCat;
private TextView mActionBarTitle;
private String mHotplugPath;

@Override
Expand All @@ -28,23 +28,19 @@ public void onCreate(Bundle savedInstanceState) {
// Load the preferences from an XML resource
addPreferencesFromResource(R.layout.empty_preference);
root = this.getPreferenceScreen();
mActionBarTitle = (TextView) getActivity().findViewById(getResources().getIdentifier("action_bar_title", "id", "android"));
setTitle();

for (String s : FilePath.HOTPLUG_PATH) {
if (AeroActivity.genHelper.doesExist(s))
mHotplugPath = s;
}

// Set title
setTitle(getActivity().getText(R.string.perf_cpu_hotplug_driver).toString());

// Load our custom preferences;
loadHotplug();
}

public final void setTitle() {
if (mActionBarTitle != null)
mActionBarTitle.setText(R.string.perf_cpu_hotplug_driver);
}

public void loadHotplug() {

String completeParamterList[] = AeroActivity.shell.getDirInfo(mHotplugPath, true);
Expand Down
Expand Up @@ -180,7 +180,6 @@ public void run() {
.replace(R.id.content_frame, mGPUGovernorFragment)
.addToBackStack("GPU Governor")
.commit();
mGPUGovernorFragment.setTitle();
}
},AeroActivity.genHelper.getDefaultDelay());
return true;
Expand Down
Expand Up @@ -19,26 +19,19 @@ public class GPUGovernorFragment extends PlaceHolderFragment {

private PreferenceScreen root;
private PreferenceCategory PrefCat;
private TextView mActionBarTitle;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.layout.empty_preference);
root = this.getPreferenceScreen();
mActionBarTitle = (TextView) getActivity().findViewById(getResources().getIdentifier("action_bar_title", "id", "android"));
setTitle();
setTitle(getActivity().getText(R.string.perf_gpu_gov).toString());

// Load our custom preferences;
loadGPUGov();
}

public final void setTitle() {
if (mActionBarTitle != null)
mActionBarTitle.setText(R.string.perf_gpu_gov);
}

public void loadGPUGov() {

String completeParamterList[] = AeroActivity.shell.getDirInfo(FilePath.GPU_GOV_PATH, true);
Expand Down
Expand Up @@ -18,26 +18,19 @@ public class MemoryDalvikFragment extends PlaceHolderFragment {

private PreferenceScreen root;
private PreferenceCategory PrefCat;
private TextView mActionBarTitle;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.layout.empty_preference);
root = this.getPreferenceScreen();
mActionBarTitle = (TextView) getActivity().findViewById(getResources().getIdentifier("action_bar_title", "id", "android"));
setTitle();
setTitle(getActivity().getText(R.string.pref_dalvik_setttings).toString());

// Load our custom preferences;
loadDalvik();
}

public final void setTitle() {
if (mActionBarTitle != null)
mActionBarTitle.setText(R.string.pref_dalvik_setttings);
}

public void loadDalvik() {

String completeParamterList[] = AeroActivity.shell.getDirInfo(FilePath.DALVIK_TWEAK, true);
Expand Down
Expand Up @@ -377,7 +377,6 @@ public void run() {
.replace(R.id.content_frame, mMemoryDalvikFragment)
.addToBackStack("Memory")
.commit();
mMemoryDalvikFragment.setTitle();
}
},AeroActivity.genHelper.getDefaultDelay());
}
Expand Down
Expand Up @@ -7,6 +7,8 @@
import android.view.ViewGroup;
import android.widget.ListView;

import com.aero.control.AeroActivity;

/**
* Created by Alexander Christ on 12.06.15.
* Allows the hold various generic stuff for all fragments.
Expand All @@ -28,4 +30,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
return v;
}

/**
* Sets the title of the action bar
* @param title String
*/
public final void setTitle(String title) {
((AeroActivity)getActivity()).setActionBarTitle(title);
}


}
Expand Up @@ -29,7 +29,6 @@ public class VoltageFragment extends PlaceHolderFragment {
private PreferenceCategory PrefCat;
private final ArrayList<String> voltList = new ArrayList<String>();
private SharedPreferences mPrefs;
private TextView mActionBarTitle;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -38,18 +37,12 @@ public void onCreate(Bundle savedInstanceState) {
// Load the preferences from an XML resource
addPreferencesFromResource(R.layout.empty_preference);
root = this.getPreferenceScreen();
mActionBarTitle = (TextView) getActivity().findViewById(getResources().getIdentifier("action_bar_title", "id", "android"));
setTitle();
setTitle(getActivity().getText(R.string.perf_voltage_control).toString());

// Load our custom preferences;
loadVoltage();
}

public final void setTitle() {
if (mActionBarTitle != null)
mActionBarTitle.setText(R.string.perf_voltage_control);
}

// Create our options menu;
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Expand Down

0 comments on commit 9523d4a

Please sign in to comment.