Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Commit

Permalink
Profiles bugfix and lower minSdkVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
claha committed Feb 9, 2015
1 parent 8ffa05b commit f858d11
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 44 deletions.
2 changes: 2 additions & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
Expand All @@ -24,6 +25,7 @@
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "com.claha.showtimeremote"
minSdkVersion 16
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
Expand Down
27 changes: 2 additions & 25 deletions app/src/main/java/com/claha/showtimeremote/SettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.MenuItem;

import com.claha.showtimeremote.base.BaseActivity;
Expand Down Expand Up @@ -38,8 +36,6 @@ public boolean onOptionsItemSelected(MenuItem item) {

public static class SettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {

private final static int PREFERENCE_RESOURCE = R.xml.fragment_settings;

private final static int PROFILES = 0;
private final static int PROFILES_CHOOSE = 0;
private final static int PROFILES_ADD = 1;
Expand All @@ -64,8 +60,7 @@ public SettingsFragment() {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(PREFERENCE_RESOURCE);
PreferenceManager.setDefaultValues(getActivity(), PREFERENCE_RESOURCE, false);
addPreferencesFromResource(R.xml.fragment_settings);

// Settings
showtimeSettings = new ShowtimeSettings(getActivity());
Expand Down Expand Up @@ -93,7 +88,7 @@ public void onCreate(final Bundle savedInstanceState) {
networkIPAddress = (EditTextPreference) network.getPreference(NETWORK_IP_ADDRESS);

// About
PreferenceCategory about = (PreferenceCategory)root.getPreference(3);
PreferenceCategory about = (PreferenceCategory) root.getPreference(3);
aboutVersion = about.getPreference(0);
aboutVersion.setOnPreferenceClickListener(this);
}
Expand Down Expand Up @@ -169,29 +164,11 @@ private void updateProfiles() {
}
}



@Override
public boolean onPreferenceClick(Preference preference) {
if (preference == profilesAdd) {
profilesAdd.getEditText().setText("");
return true;
} else if (preference == aboutVersion) {
String message = "==========SETTINGS INFORMATION ==========\n";
message += "List of profiles:\n" + showtimeSettings.getProfiles().toPrettyStringList() + "\n";
if (profilesChoose.getEntries() != null) {
for (CharSequence i : profilesChoose.getEntries()) {
message += i + ", ";
}
}

message += "\nCurrent profile:\n" + showtimeSettings.getCurrentProfile().toPrettyString() + "\n" + profilesChoose.getValue();

message += "\nIP:\n" + showtimeSettings.getIPAddress() + "\n" + networkIPAddress.getText();

Log.d("ShowtimeDebug", message);


}
return false;
}
Expand Down
21 changes: 14 additions & 7 deletions app/src/main/java/com/claha/showtimeremote/ShowtimeRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.preference.PreferenceManager;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -46,9 +43,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_showtime_remote);

viewPagerBottom = (ViewPager)findViewById(R.id.viewPagerBottom);
viewPagerMain = (ViewPager)findViewById(R.id.viewPagerMain);
viewPagerIndicator = (BaseViewPagerIndicator)findViewById(R.id.viewPagerIndicator);
PreferenceManager.setDefaultValues(this, R.xml.fragment_settings, false);

viewPagerBottom = (ViewPager) findViewById(R.id.viewPagerBottom);
viewPagerMain = (ViewPager) findViewById(R.id.viewPagerMain);
viewPagerIndicator = (BaseViewPagerIndicator) findViewById(R.id.viewPagerIndicator);

showtimeHTTP = new ShowtimeHTTP(getApplicationContext());
showtimeSettings = new ShowtimeSettings(getApplicationContext());
Expand All @@ -58,6 +57,13 @@ protected void onCreate(Bundle savedInstanceState) {
setupNotifications();
}

@Override
protected void onResume() {
super.onResume();
showtimeSettings = new ShowtimeSettings(getApplicationContext());
setupAdapters();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_showtime_remote, menu);
Expand Down Expand Up @@ -86,6 +92,7 @@ private void setupAdapters() {
viewPagerBottom.setAdapter(adapter);

int index = showtimeSettings.getCurrentProfileIndex() + 1;

viewPagerBottom.setCurrentItem(index);

List<Class<? extends BaseFragment>> fragments = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,4 @@ public int getItemPosition(Object object) {
return PagerAdapter.POSITION_NONE;
}

public void setFragments(List<Class<? extends BaseFragment>> fragments) {
this.fragments = fragments;
notifyDataSetChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public ShowtimeSettings(Context context) {
}

private void loadPreferences() {
Log.d("ShowtimeDebug", "loadPreferences");
loadProfiles();
loadCurrentProfile();
}
Expand All @@ -41,6 +40,7 @@ private void loadProfiles() {

private void loadCurrentProfile() {
currentProfile = profiles.getByName(getString(R.string.settings_profiles_choose_key));
Log.d("ShowtimeDebug", "loadCurrentProfile: " + currentProfile);
}

private void saveProfile() {
Expand Down Expand Up @@ -105,6 +105,7 @@ public Profile getCurrentProfile() {
}

public int getCurrentProfileIndex() {
Log.d("ShowtimeDebug", "getCurrentProfileIndex: " + currentProfile);
return profiles.indexOf(currentProfile);
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_showtime_remote.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
android:id="@+id/viewPagerIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/viewPagerBottom"/>
android:layout_above="@+id/viewPagerBottom"
android:layout_centerHorizontal="true" />

<android.support.v4.view.ViewPager
android:id="@+id/viewPagerBottom"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppTheme.Base.DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:alertDialogTheme">@style/AppTheme.Base.DialogTheme</item>
</style>

<style name="AppTheme.Base.DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="horizontal_center_layout">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.android.tools.build:gradle:1.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 1 addition & 3 deletions showtimeremote.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
Expand Down

0 comments on commit f858d11

Please sign in to comment.