Skip to content

Commit

Permalink
Merge pull request #19 from lolet/fix-locale-controller
Browse files Browse the repository at this point in the history
Remove LocaleController
  • Loading branch information
TangXiaoLv authored Jan 4, 2017
2 parents 40e351f + 67ef786 commit 1426c55
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 988 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.tangxiaolv.telegramgallery.Theme;
import com.tangxiaolv.telegramgallery.Utils.AndroidUtilities;
import com.tangxiaolv.telegramgallery.Utils.LayoutHelper;
import com.tangxiaolv.telegramgallery.Utils.LocaleController;

import java.lang.reflect.Field;

Expand Down Expand Up @@ -215,7 +214,7 @@ public void onDispatchKeyEvent(KeyEvent keyEvent) {
TextView textView = new TextView(getContext());
textView.setTextColor(0xff212121);
textView.setBackgroundResource(R.drawable.list_selector);
if (!LocaleController.isRTL) {
if (!AndroidUtilities.isRTL()) {
textView.setGravity(Gravity.CENTER_VERTICAL);
} else {
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
Expand All @@ -227,7 +226,7 @@ public void onDispatchKeyEvent(KeyEvent keyEvent) {
textView.setText(text);
if (icon != 0) {
textView.setCompoundDrawablePadding(AndroidUtilities.dp(12));
if (!LocaleController.isRTL) {
if (!AndroidUtilities.isRTL()) {
textView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(icon), null, null, null);
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(icon), null);
Expand All @@ -236,7 +235,7 @@ public void onDispatchKeyEvent(KeyEvent keyEvent) {
popupLayout.setShowedFromBotton(showFromBottom);
popupLayout.addView(textView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
if (LocaleController.isRTL) {
if (AndroidUtilities.isRTL()) {
layoutParams.gravity = Gravity.RIGHT;
}
layoutParams.width = LayoutHelper.MATCH_PARENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import com.tangxiaolv.telegramgallery.Utils.AndroidUtilities;
import com.tangxiaolv.telegramgallery.Utils.LayoutHelper;
import com.tangxiaolv.telegramgallery.Utils.LocaleController;
import com.tangxiaolv.telegramgallery.R;

public class PhotoPickerSearchCell extends LinearLayout {
Expand Down Expand Up @@ -78,8 +77,8 @@ public PhotoPickerSearchCell(Context context, boolean allowGifs) {
setOrientation(HORIZONTAL);

SearchButton searchButton = new SearchButton(context);
searchButton.textView1.setText(LocaleController.getString("SearchImages", R.string.SearchImages));
searchButton.textView2.setText(LocaleController.getString("SearchImagesInfo", R.string.SearchImagesInfo));
searchButton.textView1.setText(R.string.SearchImages);
searchButton.textView2.setText(R.string.SearchImagesInfo);
searchButton.imageView.setImageResource(R.drawable.search_web);
addView(searchButton);
LayoutParams layoutParams = (LayoutParams) searchButton.getLayoutParams();
Expand Down Expand Up @@ -107,7 +106,7 @@ public void onClick(View v) {
frameLayout.setLayoutParams(layoutParams);

searchButton = new SearchButton(context);
searchButton.textView1.setText(LocaleController.getString("SearchGifs", R.string.SearchGifs));
searchButton.textView1.setText(R.string.SearchGifs);
searchButton.textView2.setText("GIPHY");
searchButton.imageView.setImageResource(R.drawable.search_gif);
addView(searchButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.tangxiaolv.telegramgallery.Theme;
import com.tangxiaolv.telegramgallery.Utils.AndroidUtilities;
import com.tangxiaolv.telegramgallery.Utils.LayoutHelper;
import com.tangxiaolv.telegramgallery.Utils.LocaleController;

public class PickerBottomLayout extends FrameLayout {

Expand Down Expand Up @@ -43,7 +42,7 @@ public PickerBottomLayout(Context context, boolean darkTheme) {
Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR
: Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
cancelButton.setText(LocaleController.getString("Preview", R.string.Preview).toUpperCase());
cancelButton.setText(R.string.Preview);
// cancelButton.getPaint().setFakeBoldText(true);
addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
Expand Down Expand Up @@ -74,7 +73,7 @@ public PickerBottomLayout(Context context, boolean darkTheme) {
doneButtonTextView.setTextColor(isDarkTheme ? 0xffffffff : 0xff007aff);
doneButtonTextView.setGravity(Gravity.CENTER);
doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase());
doneButtonTextView.setText(R.string.Send);
// doneButtonTextView.getPaint().setFakeBoldText(true);
doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.tangxiaolv.telegramgallery.Components.PhotoPickerSearchCell;
import com.tangxiaolv.telegramgallery.Utils.AndroidUtilities;
import com.tangxiaolv.telegramgallery.Utils.LayoutHelper;
import com.tangxiaolv.telegramgallery.Utils.LocaleController;
import com.tangxiaolv.telegramgallery.Utils.MediaController;
import com.tangxiaolv.telegramgallery.Utils.NotificationCenter;

Expand Down Expand Up @@ -114,7 +113,7 @@ public View createView(Context context) {
actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
// actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackText(LocaleController.getString("Cancel", R.string.Cancel));
actionBar.setBackText(context.getString(R.string.Cancel));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
Expand All @@ -131,17 +130,17 @@ public void onItemClick(int id) {
}
selectedMode = 0;
dropDown.setText(
LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
R.string.PickerPhotos);
emptyView.setText(R.string.NoPhotos);
listAdapter.notifyDataSetChanged();
} else if (id == item_video) {
if (selectedMode == 1) {
return;
}
selectedMode = 1;
dropDown.setText(
LocaleController.getString("PickerVideo", R.string.PickerVideo));
emptyView.setText(LocaleController.getString("NoVideo", R.string.NoVideo));
R.string.PickerVideo);
emptyView.setText(R.string.NoVideo);
listAdapter.notifyDataSetChanged();
}
}
Expand All @@ -159,10 +158,10 @@ public void onItemClick(int id) {
ActionBarMenu menu = actionBar.createMenu();
dropDownContainer = new ActionBarMenuItem(context, menu, 0);
dropDownContainer.setSubMenuOpenSide(1);
dropDownContainer.addSubItem(item_photos,
LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0);
dropDownContainer.addSubItem(item_video,
LocaleController.getString("PickerVideo", R.string.PickerVideo), 0);
dropDownContainer.addSubItem(item_photos,context.getString(
R.string.PickerPhotos), 0);
dropDownContainer.addSubItem(item_video,context.getString(
R.string.PickerVideo), 0);
actionBar.addView(dropDownContainer);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer
.getLayoutParams();
Expand Down Expand Up @@ -191,7 +190,7 @@ public void onClick(View view) {
0);
dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
// dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
dropDown.setText(R.string.PickerPhotos);
dropDownContainer.addView(dropDown);
layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
layoutParams.width = LayoutHelper.WRAP_CONTENT;
Expand All @@ -200,7 +199,7 @@ public void onClick(View view) {
layoutParams.gravity = Gravity.CENTER_VERTICAL;
dropDown.setLayoutParams(layoutParams);
} else {
actionBar.setTitle(LocaleController.getString("Album", R.string.Album));
actionBar.setTitle(context.getString(R.string.Album));
}

listView = new ListView(context);
Expand Down Expand Up @@ -229,7 +228,7 @@ public void onClick(View view) {
emptyView.setTextSize(20);
emptyView.setGravity(Gravity.CENTER);
emptyView.setVisibility(View.GONE);
emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
emptyView.setText(R.string.NoPhotos);
frameLayout.addView(emptyView);
layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.tangxiaolv.telegramgallery.Utils.AndroidUtilities;
import com.tangxiaolv.telegramgallery.Utils.FileLoader;
import com.tangxiaolv.telegramgallery.Utils.LayoutHelper;
import com.tangxiaolv.telegramgallery.Utils.LocaleController;
import com.tangxiaolv.telegramgallery.Utils.MediaController;
import com.tangxiaolv.telegramgallery.Utils.NotificationCenter;

Expand Down Expand Up @@ -147,7 +146,7 @@ public void onItemClick(int id) {
LinearLayout.LayoutParams cancelParams = LayoutHelper
.createLinear(LayoutHelper.WRAP_CONTENT, -1);
cancel.setTextSize(18);
cancel.setText(LocaleController.getString("Cancel", R.string.Cancel));
cancel.setText(R.string.Cancel);
cancel.setTextColor(0xffffffff);
cancel.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
cancelParams.setMargins(0, 0, AndroidUtilities.dp(8), 0);
Expand All @@ -163,11 +162,10 @@ public void onClick(View v) {

if (selectedAlbum == null) {
if (type == 0) {
searchItem.getSearchField().setHint(LocaleController.getString("SearchImagesTitle",
R.string.SearchImagesTitle));
searchItem.getSearchField().setHint(R.string.SearchImagesTitle);
} else if (type == 1) {
searchItem.getSearchField().setHint(
LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle));
R.string.SearchGifsTitle);
}
}

Expand Down Expand Up @@ -240,11 +238,11 @@ public boolean onItemLongClick(AdapterView<?> parent, View view, int position,
long id) {
if (searchResult.isEmpty() && lastSearchString == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.app_name));
builder.setMessage(
LocaleController.getString("ClearSearch", R.string.ClearSearch));
builder.setPositiveButton(LocaleController
.getString("ClearButton", R.string.ClearButton).toUpperCase(),
builder.setTitle(R.string.app_name)
.setMessage(
R.string.ClearSearch)
.setPositiveButton(
R.string.ClearButton,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Expand All @@ -253,9 +251,9 @@ public void onClick(DialogInterface dialogInterface, int i) {
listAdapter.notifyDataSetChanged();
}
}
});
builder.setNegativeButton(
LocaleController.getString("Cancel", R.string.Cancel), null);
})
.setNegativeButton(
R.string.Cancel, null);
showDialog(builder.create());
return true;
}
Expand All @@ -270,14 +268,14 @@ public void onClick(DialogInterface dialogInterface, int i) {
emptyView.setGravity(Gravity.CENTER);
emptyView.setVisibility(View.GONE);
if (selectedAlbum != null) {
emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
emptyView.setText(R.string.NoPhotos);
} else {
if (type == 0) {
emptyView.setText(
LocaleController.getString("NoRecentPhotos", R.string.NoRecentPhotos));
R.string.NoRecentPhotos);
} else if (type == 1) {
emptyView
.setText(LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
.setText(R.string.NoRecentGIFs);
}
}
frameLayout.addView(emptyView);
Expand Down
Loading

0 comments on commit 1426c55

Please sign in to comment.