2013-01-08 06:41:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2013-01-08 06:41:46 +00:00
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2013-01-08 06:41:46 +00:00
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
2013-01-21 12:52:57 +00:00
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2013-01-08 06:41:46 +00:00
|
|
|
*/
|
|
|
|
|
2013-07-22 03:43:37 +00:00
|
|
|
package com.android.inputmethod.latin.settings;
|
2013-01-08 06:41:46 +00:00
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
2014-09-12 03:24:32 +00:00
|
|
|
import android.preference.Preference;
|
2013-01-08 06:41:46 +00:00
|
|
|
import android.preference.PreferenceScreen;
|
2014-06-20 00:47:11 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
2013-01-08 06:41:46 +00:00
|
|
|
|
2013-07-22 03:43:37 +00:00
|
|
|
import com.android.inputmethod.latin.R;
|
2014-09-16 21:56:34 +00:00
|
|
|
import com.android.inputmethod.latin.define.ProductionFlags;
|
2013-07-05 09:23:22 +00:00
|
|
|
import com.android.inputmethod.latin.utils.ApplicationUtils;
|
2013-06-23 16:11:32 +00:00
|
|
|
import com.android.inputmethod.latin.utils.FeedbackUtils;
|
2013-01-08 06:41:46 +00:00
|
|
|
import com.android.inputmethodcommon.InputMethodSettingsFragment;
|
|
|
|
|
2014-07-29 06:33:40 +00:00
|
|
|
public final class SettingsFragment extends InputMethodSettingsFragment {
|
2014-08-07 11:26:34 +00:00
|
|
|
// We don't care about menu grouping.
|
|
|
|
private static final int NO_MENU_GROUP = Menu.NONE;
|
|
|
|
// The first menu item id and order.
|
2014-08-08 12:25:39 +00:00
|
|
|
private static final int MENU_ABOUT = Menu.FIRST;
|
2014-08-07 11:26:34 +00:00
|
|
|
// The second menu item id and order.
|
2014-08-08 12:25:39 +00:00
|
|
|
private static final int MENU_HELP_AND_FEEDBACK = Menu.FIRST + 1;
|
2014-06-20 00:47:11 +00:00
|
|
|
|
2013-01-08 06:41:46 +00:00
|
|
|
@Override
|
|
|
|
public void onCreate(final Bundle icicle) {
|
|
|
|
super.onCreate(icicle);
|
2014-06-20 00:47:11 +00:00
|
|
|
setHasOptionsMenu(true);
|
2013-01-08 06:41:46 +00:00
|
|
|
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
|
|
|
|
setSubtypeEnablerTitle(R.string.select_language);
|
|
|
|
addPreferencesFromResource(R.xml.prefs);
|
2013-03-22 05:53:03 +00:00
|
|
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
2014-07-10 16:33:20 +00:00
|
|
|
preferenceScreen.setTitle(
|
|
|
|
ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
|
2014-09-12 03:24:32 +00:00
|
|
|
if (!Settings.SHOW_MULTILINGUAL_SETTINGS) {
|
|
|
|
final Preference multilingualOptions = findPreference(Settings.SCREEN_MULTILINGUAL);
|
|
|
|
preferenceScreen.removePreference(multilingualOptions);
|
|
|
|
}
|
2014-09-16 21:56:34 +00:00
|
|
|
if (!ProductionFlags.ENABLE_ACCOUNT_SIGN_IN) {
|
|
|
|
final Preference accountsPreference = findPreference(Settings.SCREEN_ACCOUNTS);
|
|
|
|
preferenceScreen.removePreference(accountsPreference);
|
|
|
|
}
|
2013-01-08 06:41:46 +00:00
|
|
|
}
|
2013-04-24 08:43:26 +00:00
|
|
|
|
2014-06-20 00:47:11 +00:00
|
|
|
@Override
|
|
|
|
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
2014-08-07 11:26:34 +00:00
|
|
|
if (FeedbackUtils.isHelpAndFeedbackFormSupported()) {
|
|
|
|
menu.add(NO_MENU_GROUP, MENU_HELP_AND_FEEDBACK /* itemId */,
|
|
|
|
MENU_HELP_AND_FEEDBACK /* order */, R.string.help_and_feedback);
|
2014-06-20 00:47:11 +00:00
|
|
|
}
|
|
|
|
final int aboutResId = FeedbackUtils.getAboutKeyboardTitleResId();
|
|
|
|
if (aboutResId != 0) {
|
|
|
|
menu.add(NO_MENU_GROUP, MENU_ABOUT /* itemId */, MENU_ABOUT /* order */, aboutResId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
|
|
|
final int itemId = item.getItemId();
|
2014-08-07 11:26:34 +00:00
|
|
|
if (itemId == MENU_HELP_AND_FEEDBACK) {
|
|
|
|
FeedbackUtils.showHelpAndFeedbackForm(getActivity());
|
2014-06-20 00:47:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (itemId == MENU_ABOUT) {
|
|
|
|
final Intent aboutIntent = FeedbackUtils.getAboutKeyboardIntent(getActivity());
|
|
|
|
if (aboutIntent != null) {
|
|
|
|
startActivity(aboutIntent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
2013-01-08 06:41:46 +00:00
|
|
|
}
|