[Panlingual] Improve and refactor revamped UI

- Remove useless file
 - Make Icon be able to scroll up and down

Bug: 226350483
Test: local test
Change-Id: I4564f432143e7e31ba5beff1dd32d7bc7764f9bf
This commit is contained in:
tom hsu
2022-03-23 22:28:39 +08:00
parent d80171d2b4
commit ded10f8e24
3 changed files with 54 additions and 52 deletions

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 The Android Open Source Project
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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/app_locale_detail_container"
android:orientation="vertical">
<FrameLayout
android:id="@+id/app_locale_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/app_locale_picker_with_region"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View File

@@ -37,4 +37,7 @@
<!-- For a menu item allowing users to edit a SIM display name -->
<item type="id" name="edit_sim_name" />
<!-- For a layout container to add AppLocaleDetails into -->
<item type="id" name="layout_app_locale_details" />
</resources>

View File

@@ -18,12 +18,16 @@ package com.android.settings.localepicker;
import android.app.FragmentTransaction;
import android.app.LocaleManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.LocaleList;
import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.LocalePickerWithRegion;
import com.android.internal.app.LocaleStore;
import com.android.settings.R;
@@ -39,11 +43,19 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
private static final String TAG = AppLocalePickerActivity.class.getSimpleName();
private String mPackageName;
private LocalePickerWithRegion mLocalePickerWithRegion;
private AppLocaleDetails mAppLocaleDetails;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPackageName = getIntent().getData().getSchemeSpecificPart();
Uri data = getIntent().getData();
if (data == null) {
Log.d(TAG, "There is no uri data.");
finish();
return;
}
mPackageName = data.getSchemeSpecificPart();
if (TextUtils.isEmpty(mPackageName)) {
Log.d(TAG, "There is no package name.");
finish();
@@ -51,25 +63,13 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
}
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.app_locale_picker);
// Create App locale info detail part.
AppLocaleDetails appLocaleDetails = AppLocaleDetails.newInstance(mPackageName);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.app_locale_detail, appLocaleDetails)
.commit();
// Create Locale picker part.
final LocalePickerWithRegion selector = LocalePickerWithRegion.createLanguagePicker(
mLocalePickerWithRegion = LocalePickerWithRegion.createLanguagePicker(
this, AppLocalePickerActivity.this, false /* translate only */, mPackageName);
// LocalePickerWithRegion use android.app.ListFragment. Thus, it can not user
// getSupportFragmentManager() to add this into container.
getFragmentManager()
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.replace(R.id.app_locale_picker_with_region, selector)
.commit();
mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName);
// Launch Locale picker part.
launchLocalePickerPage();
}
@Override
@@ -114,5 +114,37 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
}
localeManager.setApplicationLocales(mPackageName, LocaleList.forLanguageTags(languageTag));
}
}
private View launchAppLocaleDetailsPage() {
FrameLayout appLocaleDetailsContainer = new FrameLayout(this);
appLocaleDetailsContainer.setId(R.id.layout_app_locale_details);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.layout_app_locale_details, mAppLocaleDetails)
.commit();
return appLocaleDetailsContainer;
}
@VisibleForTesting
void launchLocalePickerPage() {
// LocalePickerWithRegion use android.app.ListFragment. Thus, it can not use
// getSupportFragmentManager() to add this into container.
android.app.FragmentManager fragmentManager = getFragmentManager();
fragmentManager.registerFragmentLifecycleCallbacks(
new android.app.FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentViewCreated(
android.app.FragmentManager fm,
android.app.Fragment f,
View v,
Bundle savedInstanceState) {
super.onFragmentViewCreated(fm, f, v, savedInstanceState);
mLocalePickerWithRegion.getListView().addHeaderView(launchAppLocaleDetailsPage());
}
}, true);
fragmentManager.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.replace(R.id.content_frame, mLocalePickerWithRegion)
.commit();
}
}