mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Add StartServer activity
Create activity_start_server layout Add textview and zim_list Add menu button Host Books in MainActivity Add values in strings.xml
This commit is contained in:
parent
047dd4cd81
commit
5ae358c3d0
@ -69,6 +69,8 @@ dependencies {
|
|||||||
implementation "androidx.collection:collection-ktx:1.1.0"
|
implementation "androidx.collection:collection-ktx:1.1.0"
|
||||||
|
|
||||||
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
|
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
|
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
||||||
@ -126,7 +128,6 @@ dependencies {
|
|||||||
// Leak canary
|
// Leak canary
|
||||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-2'
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-2'
|
||||||
|
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
|
||||||
implementation "android.arch.lifecycle:extensions:1.1.1"
|
implementation "android.arch.lifecycle:extensions:1.1.1"
|
||||||
implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
|
implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
|
||||||
@ -253,8 +254,8 @@ android {
|
|||||||
'DuplicateStrings',
|
'DuplicateStrings',
|
||||||
'LogConditional'
|
'LogConditional'
|
||||||
warning 'UnknownNullness',
|
warning 'UnknownNullness',
|
||||||
'SelectableText',
|
'SelectableText',
|
||||||
'IconDensities'
|
'IconDensities'
|
||||||
baseline file("lint-baseline.xml")
|
baseline file("lint-baseline.xml")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,7 +471,7 @@ play {
|
|||||||
resolutionStrategy = "fail"
|
resolutionStrategy = "fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
ktlint{
|
ktlint {
|
||||||
android = true
|
android = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
android:normalScreens="true"
|
android:normalScreens="true"
|
||||||
android:resizeable="true"
|
android:resizeable="true"
|
||||||
android:smallScreens="true"/>
|
android:smallScreens="true"/>
|
||||||
|
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:anyDensity="true"
|
android:anyDensity="true"
|
||||||
android:largeScreens="true"
|
android:largeScreens="true"
|
||||||
@ -24,13 +23,9 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> <!-- Devices with version >= Oreo need location permission to start/stop the hotspot -->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Device with versions >= Pie need this permission -->
|
||||||
<!-- Devices with version >= Oreo need location permission to start/stop the hotspot -->
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
||||||
|
|
||||||
<!-- Device with versions >= Pie need this permission -->
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".KiwixApplication"
|
android:name=".KiwixApplication"
|
||||||
@ -41,7 +36,8 @@
|
|||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
<activity android:name=".webserver.StartServer">
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".splash.SplashActivity"
|
android:name=".splash.SplashActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@ -55,8 +51,7 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.shortcuts"
|
android:name="android.app.shortcuts"
|
||||||
android:resource="@xml/shortcuts"/>
|
android:resource="@xml/shortcuts"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".main.MainActivity"
|
android:name=".main.MainActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
@ -159,6 +154,7 @@
|
|||||||
android:name=".zim_manager.ZimManageActivity"
|
android:name=".zim_manager.ZimManageActivity"
|
||||||
android:label="@string/choose_file"
|
android:label="@string/choose_file"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop">
|
||||||
|
|
||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.GET_CONTENT"/>
|
<action android:name="android.intent.action.GET_CONTENT"/>
|
||||||
@ -215,7 +211,6 @@
|
|||||||
android:resource="@xml/provider_paths"/>
|
android:resource="@xml/provider_paths"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
|
|
||||||
<activity android:name=".intro.IntroActivity"/>
|
<activity android:name=".intro.IntroActivity"/>
|
||||||
<activity android:name=".language.LanguageActivity"/>
|
<activity android:name=".language.LanguageActivity"/>
|
||||||
<activity android:name=".history.HistoryActivity"/>
|
<activity android:name=".history.HistoryActivity"/>
|
||||||
@ -231,4 +226,5 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
|
||||||
|
</manifest>
|
@ -124,6 +124,7 @@ import org.kiwix.kiwixmobile.utils.LanguageUtils;
|
|||||||
import org.kiwix.kiwixmobile.utils.NetworkUtils;
|
import org.kiwix.kiwixmobile.utils.NetworkUtils;
|
||||||
import org.kiwix.kiwixmobile.utils.StyleUtils;
|
import org.kiwix.kiwixmobile.utils.StyleUtils;
|
||||||
import org.kiwix.kiwixmobile.utils.files.FileUtils;
|
import org.kiwix.kiwixmobile.utils.files.FileUtils;
|
||||||
|
import org.kiwix.kiwixmobile.webserver.StartServer;
|
||||||
import org.kiwix.kiwixmobile.webserver.WebServerHelper;
|
import org.kiwix.kiwixmobile.webserver.WebServerHelper;
|
||||||
import org.kiwix.kiwixmobile.wifi_hotspot.HotspotService;
|
import org.kiwix.kiwixmobile.wifi_hotspot.HotspotService;
|
||||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity;
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity;
|
||||||
@ -946,6 +947,12 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
Intent intentSupportKiwix = new Intent(Intent.ACTION_VIEW, uriSupportKiwix);
|
Intent intentSupportKiwix = new Intent(Intent.ACTION_VIEW, uriSupportKiwix);
|
||||||
intentSupportKiwix.putExtra(EXTRA_EXTERNAL_LINK, true);
|
intentSupportKiwix.putExtra(EXTRA_EXTERNAL_LINK, true);
|
||||||
openExternalUrl(intentSupportKiwix);
|
openExternalUrl(intentSupportKiwix);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.menu_host_books:
|
||||||
|
Intent intent = new Intent(MainActivity.this, StartServer.class);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
|
||||||
case R.id.menu_wifi_hotspot:
|
case R.id.menu_wifi_hotspot:
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
@ -1911,6 +1918,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
menu.findItem(R.id.menu_random_article).setVisible(false);
|
menu.findItem(R.id.menu_random_article).setVisible(false);
|
||||||
menu.findItem(R.id.menu_searchintext).setVisible(false);
|
menu.findItem(R.id.menu_searchintext).setVisible(false);
|
||||||
menu.findItem(R.id.menu_wifi_hotspot).setVisible(false);
|
menu.findItem(R.id.menu_wifi_hotspot).setVisible(false);
|
||||||
|
menu.findItem(R.id.menu_host_books).setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
menu.findItem(R.id.menu_read_aloud).setVisible(true);
|
menu.findItem(R.id.menu_read_aloud).setVisible(true);
|
||||||
menu.findItem(R.id.menu_home).setVisible(true);
|
menu.findItem(R.id.menu_home).setVisible(true);
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package org.kiwix.kiwixmobile.webserver;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import org.kiwix.kiwixmobile.R;
|
||||||
|
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment;
|
||||||
|
|
||||||
|
public class StartServer extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_start_server);
|
||||||
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
|
ZimFileSelectFragment fragment = new ZimFileSelectFragment();
|
||||||
|
fragmentTransaction.add(R.id.frameLayoutServer, fragment);
|
||||||
|
fragmentTransaction.commit();
|
||||||
|
setUpToolbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpToolbar() {
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setTitle(getString(R.string.menu_host_books));
|
||||||
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||||
|
}
|
||||||
|
}
|
55
app/src/main/res/layout/activity_start_server.xml
Normal file
55
app/src/main/res/layout/activity_start_server.xml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/constraintLayoutId"
|
||||||
|
tools:context=".webserver.StartServer"
|
||||||
|
>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBarLayout2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
/>
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/server_textview_default_message"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/appBarLayout2"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frameLayoutServer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||||
|
tools:layout_editor_absoluteX="0dp"
|
||||||
|
></FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -79,6 +79,11 @@
|
|||||||
android:visible="false"
|
android:visible="false"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_host_books"
|
||||||
|
android:title="@string/menu_host_books"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_help"
|
android:id="@+id/menu_help"
|
||||||
android:title="@string/menu_help"
|
android:title="@string/menu_help"
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<string name="menu_read_aloud_stop">Stop reading aloud</string>
|
<string name="menu_read_aloud_stop">Stop reading aloud</string>
|
||||||
<string name="menu_support_kiwix">Support Kiwix</string>
|
<string name="menu_support_kiwix">Support Kiwix</string>
|
||||||
<string name="menu_wifi_hotspot">Wifi Hotspot</string>
|
<string name="menu_wifi_hotspot">Wifi Hotspot</string>
|
||||||
|
<string name="menu_host_books">Host Books</string>
|
||||||
<string name="save_media">Save Media</string>
|
<string name="save_media">Save Media</string>
|
||||||
<string name="save_media_error">An error occurred when trying to save the media!</string>
|
<string name="save_media_error">An error occurred when trying to save the media!</string>
|
||||||
<string name="save_media_saved">Saved media as %s to Android/media/org.kiwix…/</string>
|
<string name="save_media_saved">Saved media as %s to Android/media/org.kiwix…/</string>
|
||||||
@ -31,6 +32,7 @@
|
|||||||
<string name="hotspot_ssid_label">SSID : </string>
|
<string name="hotspot_ssid_label">SSID : </string>
|
||||||
<string name="hotspot_pass_label">Pass : </string>
|
<string name="hotspot_pass_label">Pass : </string>
|
||||||
<string name="port_hint">8080</string>
|
<string name="port_hint">8080</string>
|
||||||
|
<string name="server_textview_default_message">Select the files you wish to host on the server</string>
|
||||||
<string name="start_server_dialog_title">Start server</string>
|
<string name="start_server_dialog_title">Start server</string>
|
||||||
<string name="start_server_dialog_message">You can now start the server using this ip address and port no.</string>
|
<string name="start_server_dialog_message">You can now start the server using this ip address and port no.</string>
|
||||||
<string name="mobile_data_enabled">Warning: Mobile data enabled</string>
|
<string name="mobile_data_enabled">Warning: Mobile data enabled</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user