Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split setting screen into options and advanced options issue #704 #714

Merged
merged 4 commits into from
Nov 30, 2016
Merged

Split setting screen into options and advanced options issue #704 #714

merged 4 commits into from
Nov 30, 2016

Conversation

mhussien86
Copy link
Contributor

This commit is solving the reorganizing of the setting screen into options and advanced options, change in the category name of Advanced settings maybe needed in the future.

@@ -52,6 +52,11 @@
android:theme="@style/QuranToolBar"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity
android:name=".AdvancedQuranPreferenceActivity"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this should follow existing file naming convention. So, probably, should be named as QuranAdvancedPreferenceActivity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

setContentView(R.layout.preferences);

final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.menu_settings);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "Advanced settings" title.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thiught about using the exsting string as we will need a localization String for any new String will do this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use R.string.prefs_category_advanced for now

import rx.schedulers.Schedulers;
import timber.log.Timber;

public class QuranAdvancedSettingsFragment extends PreferenceFragment implements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are to use an additional fragment, is it possible to just have one original activity and let it utilize two fragments?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep it as 2 and clean it up later since this is mostly a straight forward move of code - perhaps in another PR if it makes sense?

Copy link
Contributor Author

@mhussien86 mhussien86 Nov 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree for now, just to avoid more checks and conditions.

@@ -147,29 +147,16 @@
</PreferenceCategory>

<PreferenceCategory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to handle PreferenceCategory clicks and launch advanced settings thereof, and get rid of additional Preference below?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in an ideal world, the patch would have been as simple as Mohamed's original patch where he'd just add PreferenceScreen around it - unfortunately though it doesn't work. maybe it would work with support-v7 fragments, but we can try that later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate more ? do we need to change something here ?

Copy link
Contributor

@ahmedre ahmedre Nov 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think @ozbek was saying, since PreferenceCategory extends Preference, instead of having the PreferenceCategory have a nested Preference for advanced settings, can you just make PreferenceCategory handle advanced settings without adding a child in xml?

i.e. instead of what you have now:

<PreferenceCategory android:key="">
   <Preference android:key="">
        <intent android:targetPackage="" />
   </Preference>
</PreferenceCategory>

instead, would it work if you move everything on the Preference up to the PreferenceCategory instead and remove the preference? i.e.

<PreferenceCategory android:key="">
    <intent android:targetPackage="" />
</PreferenceCategory>

update - after more thought, i don't think that this will work the way we want, because the PreferenceCategory causes a group style ui to be drawn.

@ozbek
Copy link
Contributor

ozbek commented Nov 29, 2016

Also, while you are at it, please consider implementing all the changes mentioned in #704.

}

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

import timber.log.Timber;

public class QuranAdvancedSettingsFragment extends PreferenceFragment implements
SharedPreferences.OnSharedPreferenceChangeListener {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need the implements SharedPreferences.OnSharedPreferenceChangeListener here.

import rx.schedulers.Schedulers;
import timber.log.Timber;

public class QuranAdvancedSettingsFragment extends PreferenceFragment implements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep it as 2 and clean it up later since this is mostly a straight forward move of code - perhaps in another PR if it makes sense?

@@ -147,29 +147,16 @@
</PreferenceCategory>

<PreferenceCategory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in an ideal world, the patch would have been as simple as Mohamed's original patch where he'd just add PreferenceScreen around it - unfortunately though it doesn't work. maybe it would work with support-v7 fragments, but we can try that later?

@@ -52,6 +52,11 @@
android:theme="@style/QuranToolBar"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity
android:name=".AdvancedQuranPreferenceActivity"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@ahmedre
Copy link
Contributor

ahmedre commented Nov 29, 2016

re #704 agree, but split them into separate patches - let's get this one merged first and then if you're cool with continuing, would love more PRs about this insha'Allah?

@ahmedre
Copy link
Contributor

ahmedre commented Nov 29, 2016

jazakAllah khairan - +1 from me, but will wait for @ozbek's +1 before merging.

Copy link
Contributor

@ozbek ozbek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we can't have a single activity with two fragments?

</PreferenceCategory>
</PreferenceScreen>


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line

<intent
android:targetPackage="com.quran.labs.androidquran"
android:targetClass="com.quran.labs.androidquran.QuranAdvancedPreferenceActivity"
android:action="com.quran.labs.androidquran.PREFS_ONE" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this action?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right unneeded action will remove it. also about the one activity with two fragments won't it be a one level of navigation what do you think i prefer advanced options to be in a second level of navigation.

@ozbek
Copy link
Contributor

ozbek commented Nov 29, 2016

also about the one activity with two fragments won't it be a one level of navigation what do you think i prefer advanced options to be in a second level of navigation.

That's basically what I am asking about :)

Is it possible to have your desired behaviour without adding QuranAdvancedPreferenceActivity?

@mhussien86
Copy link
Contributor Author

Yes possible but not cleaner it will be with some hacks, like sending string value from setting fragment and restart setting activity with string value to replace setting fragment with advanced settings fragment ! , the current we have is more separated and better.

@ozbek
Copy link
Contributor

ozbek commented Nov 29, 2016

OK, please cleanup the unused code. Thank you :)

@ahmedre
Copy link
Contributor

ahmedre commented Nov 30, 2016

i'll go ahead and merge and then please send another PR removing whatever should be removed. jazakAllah khairan for doing this @mhussien86 !

@ahmedre ahmedre merged commit cb566e1 into quran:master Nov 30, 2016
ahmedre added a commit that referenced this pull request Oct 14, 2017
Split setting screen into options and advanced options issue  #704
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants