Skip to content

Commit

Permalink
fixed some bugs and made some changes to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulkumar66 committed Apr 3, 2016
1 parent aa18544 commit 6c68b2b
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions androidCommon/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 8
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.rattlehead666.performancetweaker.app"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.rattlehead666.performancetweaker.app.ui.fragments;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.os.Bundle;
Expand All @@ -27,7 +26,6 @@ public class CpuFrequencyFragment extends PreferenceFragment
Preference preference;
Context context;
ProgressBar progressBar;
Fragment f;

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Expand All @@ -40,7 +38,7 @@ public class CpuFrequencyFragment extends PreferenceFragment
setHasOptionsMenu(true);
addPreferencesFromResource(R.xml.cpu_freq_preference);
context = getActivity().getBaseContext();
f = this;

CpuMaxFreqPreference = (ListPreference) findPreference("cpu_max_freq_pref");
CpuMinFreqPreference = (ListPreference) findPreference("cpu_min_freq_pref");
GovernorPreference = (ListPreference) findPreference("governor_pref");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,55 @@
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import com.rattlehead666.performancetweaker.app.R;
import com.rattlehead666.performancetweaker.app.utils.CpuFrequencyUtils;
import com.rattlehead666.performancetweaker.app.utils.GovernorProperty;

public class GovernorTuningFragment extends PreferenceFragment
implements Preference.OnPreferenceChangeListener {
implements Preference.OnPreferenceChangeListener, SwipeRefreshLayout.OnRefreshListener {

public static String TAG = "GOVERNOR_TUNING";
PreferenceCategory preferenceCategory;
EditTextPreference editTextPreferences[];
GovernorProperty[] governorProperties;
FrameLayout governorPropertiesContainer;
Context context;
ProgressBar progressBar;
View view;
SwipeRefreshLayout swipeRefreshLayout;

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_pref_container, container, false);
view = inflater.inflate(R.layout.fragment_pref_refresh_container, container, false);
swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
return view;
}

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@Override public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

addPreferencesFromResource(R.xml.governor_tuning_preferences);

preferenceCategory = (PreferenceCategory) findPreference("governor_tune_pref");
governorPropertiesContainer =
(FrameLayout) getActivity().findViewById(R.id.frame_layout_preference);
progressBar = (ProgressBar) getActivity().findViewById(R.id.loading);
context = getActivity();

new GetGovernorPropertiesTask().execute();
swipeRefreshLayout.setOnRefreshListener(this);

//We are posting SwipeRefreshLayout it to a time in the future
new Handler().postDelayed(new Runnable() {

@Override public void run() {
swipeRefreshLayout.setRefreshing(true);
new GetGovernorPropertiesTask().execute();
}
}, 500);
}

@Override public boolean onPreferenceChange(Preference preference, Object o) {
Expand All @@ -52,14 +61,11 @@ public class GovernorTuningFragment extends PreferenceFragment
return true;
}

private class GetGovernorPropertiesTask extends AsyncTask<Void, Void, GovernorProperty[]> {

@Override protected void onPreExecute() {
super.onPreExecute();
@Override public void onRefresh() {
new GetGovernorPropertiesTask().execute();
}

// progressBar.setVisibility(View.VISIBLE);
// governorPropertiesContainer.setVisibility(View.GONE);
}
private class GetGovernorPropertiesTask extends AsyncTask<Void, Void, GovernorProperty[]> {

@Override protected GovernorProperty[] doInBackground(Void... params) {
governorProperties = CpuFrequencyUtils.getGovernorProperties();
Expand All @@ -69,9 +75,6 @@ private class GetGovernorPropertiesTask extends AsyncTask<Void, Void, GovernorPr
@Override protected void onPostExecute(GovernorProperty[] governorProperties) {
super.onPostExecute(governorProperties);

// progressBar.setVisibility(View.GONE);
// governorPropertiesContainer.setVisibility(View.VISIBLE);

if (governorProperties != null && governorProperties.length != 0) {
editTextPreferences = new EditTextPreference[governorProperties.length];
for (int i = 0; i < editTextPreferences.length; i++) {
Expand All @@ -86,6 +89,7 @@ private class GetGovernorPropertiesTask extends AsyncTask<Void, Void, GovernorPr
preferenceCategory.addPreference(editTextPreferences[i]);
}
}
swipeRefreshLayout.setRefreshing(false);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 0 additions & 34 deletions app/src/main/res/layout/activity_governor_tune_preference.xml

This file was deleted.

4 changes: 3 additions & 1 deletion app/src/main/res/layout/drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="172dp"
android:background="@color/material_deep_teal_200"
android:background="@drawable/navigation_bar_header"
android:gravity="bottom"
android:orientation="vertical"
>

<!--
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
Expand All @@ -24,4 +25,5 @@
android:textSize="25sp"
/>
</LinearLayout>
-->
</LinearLayout>
30 changes: 30 additions & 0 deletions app/src/main/res/layout/fragment_pref_refresh_container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
>
<!-- Dirty hack to inflate a preferences inside a cardview-->
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
/>
</android.support.v4.widget.SwipeRefreshLayout>

</android.support.v7.widget.CardView>
</LinearLayout>

0 comments on commit 6c68b2b

Please sign in to comment.