Commit 5a4be02f authored by Habib Kazemi's avatar Habib Kazemi Committed by Geoffrey Métais

Convert about to kotlin

Signed-off-by: default avatarGeoffrey Métais <geoffrey.metais@gmail.com>
parent 631a730c
......@@ -10,7 +10,8 @@
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/sliding_tabs">
android:layout_below="@+id/sliding_tabs"
android:layout_marginBottom="16dp">
<include layout="@layout/about_main" />
<include layout="@layout/about_licence" />
......
......@@ -3,6 +3,5 @@
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"/>
</merge>
\ No newline at end of file
/*****************************************************************************
* AboutActivity.java
*****************************************************************************
* Copyright © 2011-2012 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package org.videolan.vlc.gui;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.audio.AudioPagerAdapter;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.WorkersKt;
public class AboutFragment extends Fragment {
public final static String TAG = "VLC/AboutActivity";
public final static int MODE_ABOUT = 0;
public final static int MODE_LICENCE = 1;
public final static int MODE_TOTAL = 2; // Number of audio browser modes
private ViewPager mViewPager;
private TabLayout mTabLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.about, container, false);
}
@Override
public void onViewCreated(final View v, @Nullable Bundle savedInstanceState) {
super.onViewCreated(v, savedInstanceState);
if (getActivity() instanceof AppCompatActivity)
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("VLC " + BuildConfig.VERSION_NAME);
//Fix android 7 Locale problem with webView
//https://stackoverflow.com/questions/40398528/android-webview-locale-changes-abruptly-on-android-n
if (AndroidUtil.isNougatOrLater)
UiTools.setLocale(getActivity());
final View aboutMain = v.findViewById(R.id.about_main);
final WebView webView = v.findViewById(R.id.webview);
final String revision = getString(R.string.build_revision);
View[] lists = new View[]{aboutMain, webView};
String[] titles = new String[] {getString(R.string.about), getString(R.string.licence)};
mViewPager = v.findViewById(R.id.pager);
mViewPager.setOffscreenPageLimit(MODE_TOTAL-1);
mViewPager.setAdapter(new AudioPagerAdapter(lists, titles));
mTabLayout = v.findViewById(R.id.sliding_tabs);
mTabLayout.setupWithViewPager(mViewPager);
WorkersKt.runBackground(new Runnable() {
@Override
public void run() {
final String asset = Util.readAsset("licence.htm", "").replace("!COMMITID!",revision);
WorkersKt.runOnMainThread(new Runnable() {
@Override
public void run() {
UiTools.fillAboutView(v);
webView.loadData(asset, "text/html", "UTF8");
}
});
}
});
}
}
/*****************************************************************************
* AboutFragment.kt
*
* Copyright © 2018 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*/
package org.videolan.vlc.gui
import android.os.Bundle
import android.support.design.widget.TabLayout
import android.support.v4.app.Fragment
import android.support.v4.view.ViewPager
import android.support.v7.app.AppCompatActivity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import android.widget.ScrollView
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.withContext
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.gui.audio.AudioPagerAdapter
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.util.Util
import org.videolan.vlc.util.VLCIO
private const val TAG = "VLC/AboutFragment"
private const val MODE_TOTAL = 2 // Number of audio browser modes
class AboutFragment : Fragment() {
private lateinit var viewPager: ViewPager
private lateinit var tabLayout: TabLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return inflater.inflate(R.layout.about, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as? AppCompatActivity)?.supportActionBar?.title = "VLC ${BuildConfig.VERSION_NAME}"
//Fix android 7 Locale problem with webView
//https://stackoverflow.com/questions/40398528/android-webview-locale-changes-abruptly-on-android-n
if (AndroidUtil.isNougatOrLater)
UiTools.setLocale(activity)
val aboutMain = view.findViewById<ScrollView>(R.id.about_main)
val webView = view.findViewById<WebView>(R.id.webview)
val revision = getString(R.string.build_revision)
val lists = arrayOf(aboutMain, webView)
val titles = arrayOf(getString(R.string.about), getString(R.string.licence))
viewPager = view.findViewById(R.id.pager)
viewPager.offscreenPageLimit = MODE_TOTAL - 1
viewPager.adapter = AudioPagerAdapter(lists, titles)
tabLayout = view.findViewById(R.id.sliding_tabs)
tabLayout.setupWithViewPager(viewPager)
launch(UI.immediate) {
val asset = withContext(VLCIO) {
Util.readAsset("licence.htm", "").replace("!COMMITID!", revision)
}
UiTools.fillAboutView(view)
webView.loadData(asset, "text/html", "UTF8")
}
}
}
package org.videolan.vlc.gui.tv;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.helpers.UiTools;
public class AboutActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_main);
UiTools.fillAboutView(getWindow().getDecorView().getRootView());
TvUtil.INSTANCE.applyOverscanMargin(this);
TimeUpdaterKt.registerTimeView(this, (TextView) findViewById(R.id.tv_time));
}
}
package org.videolan.vlc.gui.tv
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.widget.TextView
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.UiTools
class AboutActivity : FragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.about_main)
UiTools.fillAboutView(window.decorView.rootView)
TvUtil.applyOverscanMargin(this)
this.registerTimeView(findViewById(R.id.tv_time))
}
}
package org.videolan.vlc.gui.tv;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.webkit.WebView;
import org.videolan.vlc.R;
import org.videolan.vlc.util.Util;
public class LicenceActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String revision = getString(R.string.build_revision);
WebView licence = new WebView(this);
licence.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");
setContentView(licence);
((View)licence.getParent()).setBackgroundColor(Color.LTGRAY);
TvUtil.INSTANCE.applyOverscanMargin(this);
}
}
package org.videolan.vlc.gui.tv
import android.graphics.Color
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.view.View
import android.webkit.WebView
import org.videolan.vlc.R
import org.videolan.vlc.util.Util
class LicenceActivity : FragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val revision = getString(R.string.build_revision)
val licence = WebView(this)
licence.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8")
setContentView(licence)
(licence.parent as View).setBackgroundColor(Color.LTGRAY)
TvUtil.applyOverscanMargin(this)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment