Fix spinner with push notification
This commit is contained in:
parent
a2bfe754e3
commit
39e12ceef9
|
@ -66,7 +66,6 @@ public class SettingsActivity extends BaseActivity {
|
|||
public static boolean needRestart;
|
||||
protected int res;
|
||||
private int style;
|
||||
private int liveNotificationCount;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -368,7 +367,6 @@ public class SettingsActivity extends BaseActivity {
|
|||
});
|
||||
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
|
@ -378,7 +376,10 @@ public class SettingsActivity extends BaseActivity {
|
|||
|
||||
//Live notification mode
|
||||
final Spinner set_live_type = findViewById(R.id.set_live_type);
|
||||
|
||||
String[] labels = {getString(R.string.push_notif), getString(R.string.no_live_notif)};
|
||||
ArrayAdapter<String> adapterLabels = new ArrayAdapter<>(SettingsActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, labels);
|
||||
set_live_type.setAdapter(adapterLabels);
|
||||
|
||||
TextView set_live_type_indication = findViewById(R.id.set_live_type_indication);
|
||||
if (Helper.liveNotifType(SettingsActivity.this) == Helper.NOTIF_NONE) {
|
||||
|
@ -386,31 +387,27 @@ public class SettingsActivity extends BaseActivity {
|
|||
} else {
|
||||
set_live_type_indication.setText(R.string.set_push_notifications);
|
||||
}
|
||||
set_live_type.setSelection(Helper.liveNotifType(SettingsActivity.this));
|
||||
liveNotificationCount = 0;
|
||||
set_live_type.setSelection(Helper.liveNotifInt(SettingsActivity.this), false);
|
||||
|
||||
set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (liveNotificationCount > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case Helper.NOTIF_PUSH:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, true);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.set_push_notifications);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, true);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.set_push_notifications);
|
||||
|
||||
break;
|
||||
case Helper.NOTIF_NONE:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, false);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.no_live_indication);
|
||||
break;
|
||||
}
|
||||
PushHelper.startStreaming(SettingsActivity.this);
|
||||
} else {
|
||||
liveNotificationCount++;
|
||||
break;
|
||||
case 1:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, false);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.no_live_indication);
|
||||
break;
|
||||
}
|
||||
PushHelper.startStreaming(SettingsActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -72,6 +72,7 @@ import java.util.Set;
|
|||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.BaseMainActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.PeertubeEditUploadActivity;
|
||||
import app.fedilab.android.asynctasks.RetrieveRelationshipAsyncTask;
|
||||
import app.fedilab.android.asynctasks.RetrieveRemoteDataAsyncTask;
|
||||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
|
@ -119,7 +120,6 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
private final List<Account> translators = new ArrayList<>();
|
||||
private type type;
|
||||
private Context context;
|
||||
private int countTrans, countLanguage, notificationCount, ledCount, videoSpinnerCount, liveNotificationCount;
|
||||
private AccountSearchDevAdapter translatorManager;
|
||||
private TextView set_folder;
|
||||
private EditText your_api_key;
|
||||
|
@ -285,10 +285,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
if (requestCode == ACTIVITY_CHOOSE_FILE) {
|
||||
Uri treeUri = data.getData();
|
||||
Uri docUri = null;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
docUri = DocumentsContract.buildDocumentUriUsingTree(treeUri,
|
||||
DocumentsContract.getTreeDocumentId(treeUri));
|
||||
}
|
||||
docUri = DocumentsContract.buildDocumentUriUsingTree(treeUri,
|
||||
DocumentsContract.getTreeDocumentId(treeUri));
|
||||
try {
|
||||
String path = getPath(context, docUri);
|
||||
if (path == null)
|
||||
|
@ -772,26 +770,21 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
default:
|
||||
positionNotificationAntion = 0;
|
||||
}
|
||||
notificationCount = 0;
|
||||
action_notification.setSelection(positionNotificationAntion);
|
||||
action_notification.setSelection(positionNotificationAntion, false);
|
||||
action_notification.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (notificationCount > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.putInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_ACTIVE);
|
||||
editor.apply();
|
||||
break;
|
||||
case 1:
|
||||
editor.putInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_SILENT);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
notificationCount++;
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.putInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_ACTIVE);
|
||||
editor.apply();
|
||||
break;
|
||||
case 1:
|
||||
editor.putInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_SILENT);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -879,20 +872,15 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
ArrayAdapter<CharSequence> adapterLEDColour = ArrayAdapter.createFromResource(Objects.requireNonNull(getActivity()), R.array.led_colours, android.R.layout.simple_spinner_dropdown_item);
|
||||
led_colour_spinner.setAdapter(adapterLEDColour);
|
||||
int positionSpinnerLEDColour = (sharedpreferences.getInt(Helper.SET_LED_COLOUR, Helper.LED_COLOUR));
|
||||
led_colour_spinner.setSelection(positionSpinnerLEDColour);
|
||||
led_colour_spinner.setSelection(positionSpinnerLEDColour, false);
|
||||
|
||||
|
||||
ledCount = 0;
|
||||
led_colour_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ledCount > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putInt(Helper.SET_LED_COLOUR, position);
|
||||
editor.apply();
|
||||
} else {
|
||||
ledCount++;
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putInt(Helper.SET_LED_COLOUR, position);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -934,7 +922,9 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
//Live notification mode
|
||||
final Spinner set_live_type = rootView.findViewById(R.id.set_live_type);
|
||||
String[] labels = {context.getString(R.string.push_notif), context.getString(R.string.no_live_notif)};
|
||||
|
||||
ArrayAdapter<String> adapterLabels = new ArrayAdapter<>(context,
|
||||
android.R.layout.simple_spinner_dropdown_item, labels);
|
||||
set_live_type.setAdapter(adapterLabels);
|
||||
|
||||
TextView set_live_type_indication = rootView.findViewById(R.id.set_live_type_indication);
|
||||
switch (Helper.liveNotifType(context)) {
|
||||
|
@ -945,31 +935,26 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
set_live_type_indication.setText(R.string.no_live_indication);
|
||||
break;
|
||||
}
|
||||
set_live_type.setSelection(Helper.liveNotifType(context));
|
||||
liveNotificationCount = 0;
|
||||
set_live_type.setSelection(Helper.liveNotifInt(context), false);
|
||||
set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (liveNotificationCount > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case Helper.NOTIF_PUSH:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, true);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.set_push_notifications);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, true);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.set_push_notifications);
|
||||
|
||||
break;
|
||||
case Helper.NOTIF_NONE:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, false);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.no_live_indication);
|
||||
break;
|
||||
}
|
||||
PushHelper.startStreaming(context);
|
||||
} else {
|
||||
liveNotificationCount++;
|
||||
break;
|
||||
case 1:
|
||||
editor.putBoolean(Helper.SET_PUSH_NOTIFICATIONS, false);
|
||||
editor.commit();
|
||||
set_live_type_indication.setText(R.string.no_live_indication);
|
||||
break;
|
||||
}
|
||||
PushHelper.startStreaming(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1139,50 +1124,45 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
your_api_key.setVisibility(View.VISIBLE);
|
||||
positionSpinnerTrans = 0;
|
||||
}
|
||||
translation_layout_spinner.setSelection(positionSpinnerTrans);
|
||||
countTrans = 0;
|
||||
translation_layout_spinner.setSelection(positionSpinnerTrans, false);
|
||||
translation_layout_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (countTrans > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
your_api_key.setVisibility(View.GONE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
your_api_key.setVisibility(View.GONE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
|
||||
|
||||
break;
|
||||
case 1:
|
||||
your_api_key.setVisibility(View.VISIBLE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
|
||||
break;
|
||||
case 1:
|
||||
your_api_key.setVisibility(View.VISIBLE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
your_api_key.setVisibility(View.VISIBLE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
|
||||
break;
|
||||
case 3:
|
||||
your_api_key.setVisibility(View.VISIBLE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_SYSTRAN);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
|
||||
break;
|
||||
case 4:
|
||||
your_api_key.setVisibility(View.GONE);
|
||||
set_trans_forced.isChecked();
|
||||
editor.putBoolean(Helper.SET_TRANS_FORCED, false);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_NONE);
|
||||
editor.commit();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
countTrans++;
|
||||
break;
|
||||
case 2:
|
||||
your_api_key.setVisibility(View.VISIBLE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
|
||||
break;
|
||||
case 3:
|
||||
your_api_key.setVisibility(View.VISIBLE);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_SYSTRAN);
|
||||
editor.commit();
|
||||
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
|
||||
break;
|
||||
case 4:
|
||||
your_api_key.setVisibility(View.GONE);
|
||||
set_trans_forced.isChecked();
|
||||
editor.putBoolean(Helper.SET_TRANS_FORCED, false);
|
||||
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_NONE);
|
||||
editor.commit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1288,11 +1268,11 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
boolean console_mode = Helper.getSharedValue(context, Helper.SET_CONSOLE_MODE);
|
||||
|
||||
if (compact_mode) {
|
||||
set_mode.setSelection(1);
|
||||
set_mode.setSelection(1, false);
|
||||
} else if (console_mode) {
|
||||
set_mode.setSelection(2);
|
||||
set_mode.setSelection(2, false);
|
||||
} else {
|
||||
set_mode.setSelection(0);
|
||||
set_mode.setSelection(0, false);
|
||||
}
|
||||
|
||||
set_mode.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
@ -1562,25 +1542,20 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
int positionVideoMode = 0;
|
||||
if (videoMode == Helper.VIDEO_MODE_DIRECT)
|
||||
positionVideoMode = 1;
|
||||
videoSpinnerCount = 0;
|
||||
video_mode_spinner.setSelection(positionVideoMode);
|
||||
video_mode_spinner.setSelection(positionVideoMode, false);
|
||||
video_mode_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (videoSpinnerCount > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_WEBVIEW);
|
||||
editor.apply();
|
||||
break;
|
||||
case 1:
|
||||
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_DIRECT);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
videoSpinnerCount++;
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_WEBVIEW);
|
||||
editor.apply();
|
||||
break;
|
||||
case 1:
|
||||
editor.putInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_DIRECT);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2371,119 +2346,115 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
set_change_locale.setAdapter(adapterLocale);
|
||||
|
||||
int positionSpinnerLanguage = Helper.languageSpinnerPosition(context);
|
||||
set_change_locale.setSelection(positionSpinnerLanguage);
|
||||
countLanguage = 0;
|
||||
set_change_locale.setSelection(positionSpinnerLanguage, false);
|
||||
|
||||
set_change_locale.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (countLanguage > 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.remove(Helper.SET_DEFAULT_LOCALE_NEW);
|
||||
editor.commit();
|
||||
break;
|
||||
case 1:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "en");
|
||||
editor.commit();
|
||||
break;
|
||||
case 2:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "fr");
|
||||
editor.commit();
|
||||
break;
|
||||
case 3:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "de");
|
||||
editor.commit();
|
||||
break;
|
||||
case 4:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "it");
|
||||
editor.commit();
|
||||
break;
|
||||
case 5:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ja");
|
||||
editor.commit();
|
||||
break;
|
||||
case 6:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "zh-TW");
|
||||
editor.commit();
|
||||
break;
|
||||
case 7:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "zh-CN");
|
||||
editor.commit();
|
||||
break;
|
||||
case 8:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "eu");
|
||||
editor.commit();
|
||||
break;
|
||||
case 9:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ar");
|
||||
editor.commit();
|
||||
break;
|
||||
case 10:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "nl");
|
||||
editor.commit();
|
||||
break;
|
||||
case 11:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "gl");
|
||||
editor.commit();
|
||||
break;
|
||||
case 12:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "el");
|
||||
editor.commit();
|
||||
break;
|
||||
case 13:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "pt");
|
||||
editor.commit();
|
||||
break;
|
||||
case 14:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "es");
|
||||
editor.commit();
|
||||
break;
|
||||
case 15:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "pl");
|
||||
editor.commit();
|
||||
break;
|
||||
case 16:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "sr");
|
||||
editor.commit();
|
||||
break;
|
||||
case 17:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "uk");
|
||||
editor.commit();
|
||||
break;
|
||||
case 18:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ru");
|
||||
editor.commit();
|
||||
break;
|
||||
case 19:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "no");
|
||||
editor.commit();
|
||||
break;
|
||||
case 20:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "kab");
|
||||
editor.commit();
|
||||
break;
|
||||
case 21:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ca");
|
||||
editor.commit();
|
||||
break;
|
||||
case 22:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "szl");
|
||||
editor.commit();
|
||||
break;
|
||||
}
|
||||
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
|
||||
assert intent != null;
|
||||
ComponentName componentName = intent.getComponent();
|
||||
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
|
||||
startActivity(mainIntent);
|
||||
Runtime.getRuntime().exit(0);
|
||||
} else {
|
||||
countLanguage++;
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
switch (position) {
|
||||
case 0:
|
||||
editor.remove(Helper.SET_DEFAULT_LOCALE_NEW);
|
||||
editor.commit();
|
||||
break;
|
||||
case 1:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "en");
|
||||
editor.commit();
|
||||
break;
|
||||
case 2:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "fr");
|
||||
editor.commit();
|
||||
break;
|
||||
case 3:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "de");
|
||||
editor.commit();
|
||||
break;
|
||||
case 4:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "it");
|
||||
editor.commit();
|
||||
break;
|
||||
case 5:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ja");
|
||||
editor.commit();
|
||||
break;
|
||||
case 6:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "zh-TW");
|
||||
editor.commit();
|
||||
break;
|
||||
case 7:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "zh-CN");
|
||||
editor.commit();
|
||||
break;
|
||||
case 8:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "eu");
|
||||
editor.commit();
|
||||
break;
|
||||
case 9:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ar");
|
||||
editor.commit();
|
||||
break;
|
||||
case 10:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "nl");
|
||||
editor.commit();
|
||||
break;
|
||||
case 11:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "gl");
|
||||
editor.commit();
|
||||
break;
|
||||
case 12:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "el");
|
||||
editor.commit();
|
||||
break;
|
||||
case 13:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "pt");
|
||||
editor.commit();
|
||||
break;
|
||||
case 14:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "es");
|
||||
editor.commit();
|
||||
break;
|
||||
case 15:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "pl");
|
||||
editor.commit();
|
||||
break;
|
||||
case 16:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "sr");
|
||||
editor.commit();
|
||||
break;
|
||||
case 17:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "uk");
|
||||
editor.commit();
|
||||
break;
|
||||
case 18:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ru");
|
||||
editor.commit();
|
||||
break;
|
||||
case 19:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "no");
|
||||
editor.commit();
|
||||
break;
|
||||
case 20:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "kab");
|
||||
editor.commit();
|
||||
break;
|
||||
case 21:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "ca");
|
||||
editor.commit();
|
||||
break;
|
||||
case 22:
|
||||
editor.putString(Helper.SET_DEFAULT_LOCALE_NEW, "szl");
|
||||
editor.commit();
|
||||
break;
|
||||
}
|
||||
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
|
||||
assert intent != null;
|
||||
ComponentName componentName = intent.getComponent();
|
||||
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
|
||||
startActivity(mainIntent);
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -595,6 +595,15 @@ public class BaseHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static int liveNotifInt(Context context) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean push = sharedpreferences.getBoolean(SET_PUSH_NOTIFICATIONS, BuildConfig.push);
|
||||
if (push) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Check if the user is connected to Internet
|
||||
|
@ -1332,7 +1341,7 @@ public class BaseHelper {
|
|||
for (final Account account : accounts) {
|
||||
|
||||
if (!currrentUserId.equals(account.getId()) || !getLiveInstance(activity).equals(account.getInstance())) {
|
||||
if (!lastInstance.trim().toUpperCase().equals(account.getInstance().trim().toUpperCase())) {
|
||||
if (!lastInstance.trim().equalsIgnoreCase(account.getInstance().trim())) {
|
||||
lastInstance = account.getInstance().toUpperCase();
|
||||
currentSubmenu = mainMenu.addSubMenu(account.getInstance().toUpperCase());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue